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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4df0ff353b7f46feeda5484a8b2d8360a4479f78f23ba1fe99e24fc1573656b8
4
- data.tar.gz: 0aac5a1d1bab0a652620fa9aeb01cc35c47713f7c22fc0fc9eb89a09b58d3fe5
3
+ metadata.gz: befe2b34fb39b7a77c38e62d0c64e16660393a216dac6bcd843b891d4683c9f0
4
+ data.tar.gz: c5688bfc1b40c2cdf7c449a84c51bad9c91b250f4c824eb8b6b1d21dd3ffbe77
5
5
  SHA512:
6
- metadata.gz: 29f10fdda2c80bd30a7e614ee55cc56f3d89ea1e5d659e5d4173e8cc4cb6c228f38768320002b9dab2e0da824120e8756c44df59dec691ed5acec6c12df31f06
7
- data.tar.gz: 963961413fb2a39e10ea794d29717fb839e54cd301182a2f748d36384e8a7ae38349f23f4646aea93a3c6430d62c7e8bdf67055937bf93814daad8c42dfc38d7
6
+ metadata.gz: 8e61403724fd09d14614b6201265551c2cb34a0894b2acf654654a17fb558e0930cbe019f7e10acdcb85738a69c8e056751a37e1aa979e2561e37354053e3b67
7
+ data.tar.gz: bc70a179e8c7249f8c59b437b8a1cbab8e9bf28cef08a4ea9779fe664318dc357affa1ab41fb95082d8ace1fda671abf8c8c7336e40e78fcf6b8e75a0ff20a96
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Ghtk
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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.1
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-08-24 00:00:00.000000000 Z
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
- rubyforge_project:
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