ghtk 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ghtk/error.rb +14 -1
- data/lib/ghtk/order.rb +4 -0
- data/lib/ghtk/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: befe2b34fb39b7a77c38e62d0c64e16660393a216dac6bcd843b891d4683c9f0
|
4
|
+
data.tar.gz: c5688bfc1b40c2cdf7c449a84c51bad9c91b250f4c824eb8b6b1d21dd3ffbe77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e61403724fd09d14614b6201265551c2cb34a0894b2acf654654a17fb558e0930cbe019f7e10acdcb85738a69c8e056751a37e1aa979e2561e37354053e3b67
|
7
|
+
data.tar.gz: bc70a179e8c7249f8c59b437b8a1cbab8e9bf28cef08a4ea9779fe664318dc357affa1ab41fb95082d8ace1fda671abf8c8c7336e40e78fcf6b8e75a0ff20a96
|
data/lib/ghtk/error.rb
CHANGED
@@ -2,7 +2,20 @@ module Ghtk
|
|
2
2
|
class Error < StandardError; end
|
3
3
|
class ForbiddenError < Error; end
|
4
4
|
class ServerError < Error; end
|
5
|
-
class RequestError < Error; end
|
6
5
|
class CreateOrderError < Error; end
|
7
6
|
class BadParamsError < Error; end
|
7
|
+
|
8
|
+
class RequestError < Error
|
9
|
+
|
10
|
+
attr_reader :response
|
11
|
+
|
12
|
+
def initialize(response)
|
13
|
+
@response = response
|
14
|
+
super(response['message'])
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
class OrderIdExistError < RequestError; end
|
20
|
+
|
8
21
|
end
|
data/lib/ghtk/order.rb
CHANGED
@@ -5,6 +5,10 @@ module Ghtk
|
|
5
5
|
create_data = NinjaVan::FlexibleParams.new(serializer).hash
|
6
6
|
Ghtk::Validations::OrderValidation.new(create_data).validate!
|
7
7
|
Ghtk::Request.post('/services/shipment/order', create_data)
|
8
|
+
rescue Ghtk::RequestError => e
|
9
|
+
error_code = e.response.dig('error', 'code')
|
10
|
+
error_class = "Ghtk::#{error_code.downcase.classify}Error".safe_constantize || Ghtk::RequestError
|
11
|
+
raise error_class, e.response
|
8
12
|
rescue Ghtk::ForbiddenError
|
9
13
|
raise Ghtk::CreateOrderError.new(create_data)
|
10
14
|
end
|
data/lib/ghtk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KhoaRB
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -116,8 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
|
120
|
-
rubygems_version: 2.7.10
|
119
|
+
rubygems_version: 3.0.3
|
121
120
|
signing_key:
|
122
121
|
specification_version: 4
|
123
122
|
summary: GHTK API Caller
|