ghtk 1.0.2 → 1.0.4

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: befe2b34fb39b7a77c38e62d0c64e16660393a216dac6bcd843b891d4683c9f0
4
- data.tar.gz: c5688bfc1b40c2cdf7c449a84c51bad9c91b250f4c824eb8b6b1d21dd3ffbe77
3
+ metadata.gz: a14b2ff87da9ee694ebc7b03aaf07fdc1c38da12f0ed3380db025a23c950eedc
4
+ data.tar.gz: 6d4739b162112562d394b21440a5fbd0344d396b5a6e680c9995ea816ed9446a
5
5
  SHA512:
6
- metadata.gz: 8e61403724fd09d14614b6201265551c2cb34a0894b2acf654654a17fb558e0930cbe019f7e10acdcb85738a69c8e056751a37e1aa979e2561e37354053e3b67
7
- data.tar.gz: bc70a179e8c7249f8c59b437b8a1cbab8e9bf28cef08a4ea9779fe664318dc357affa1ab41fb95082d8ace1fda671abf8c8c7336e40e78fcf6b8e75a0ff20a96
6
+ metadata.gz: abfce6b6bfd62f709cd61560f9d70541bd6be022c1a3fabd1d6097cf7683cb07dde3224e2828273f029ff9cbfa3d037dc8fb49b0671014f7af3618b0361db72b
7
+ data.tar.gz: 42eee5f21a022f8bd165d4ec51e8b4660c7c93cc6c882359e02220734939a23329f281b02a36bd85e84b3fab139a2847227b075f777d038d5a30933fdf255bc1
data/lib/ghtk/error.rb CHANGED
@@ -1,11 +1,6 @@
1
1
  module Ghtk
2
- class Error < StandardError; end
3
- class ForbiddenError < Error; end
4
- class ServerError < Error; end
5
- class CreateOrderError < Error; end
6
- class BadParamsError < Error; end
7
2
 
8
- class RequestError < Error
3
+ class RequestError < StandardError
9
4
 
10
5
  attr_reader :response
11
6
 
@@ -16,6 +11,12 @@ module Ghtk
16
11
 
17
12
  end
18
13
 
14
+ class Error < StandardError; end
15
+ class ForbiddenError < Error; end
16
+ class ServerError < Error; end
17
+ class CreateOrderError < Error; end
18
+ class BadParamsError < Error; end
19
+
19
20
  class OrderIdExistError < RequestError; end
20
21
 
21
22
  end
data/lib/ghtk/order.rb CHANGED
@@ -6,7 +6,7 @@ module Ghtk
6
6
  Ghtk::Validations::OrderValidation.new(create_data).validate!
7
7
  Ghtk::Request.post('/services/shipment/order', create_data)
8
8
  rescue Ghtk::RequestError => e
9
- error_code = e.response.dig('error', 'code')
9
+ error_code = e.response.dig('error', 'code') || 'REQUEST'
10
10
  error_class = "Ghtk::#{error_code.downcase.classify}Error".safe_constantize || Ghtk::RequestError
11
11
  raise error_class, e.response
12
12
  rescue Ghtk::ForbiddenError
data/lib/ghtk/request.rb CHANGED
@@ -1,9 +1,11 @@
1
+ require "http"
2
+
1
3
  module Ghtk
2
4
  class Request
3
5
 
4
6
  def self.post(endpoint, params={})
5
7
  full_endpoint = "#{Ghtk.setup.domain}#{endpoint}?ver=#{Ghtk.setup.version}"
6
- response = Http.headers(
8
+ response = HTTP.headers(
7
9
  content_type: 'application/json',
8
10
  token: Ghtk.setup.access_token,
9
11
  ).post(full_endpoint, json: params)
@@ -15,7 +17,7 @@ module Ghtk
15
17
 
16
18
  def self.get(endpoint, params={})
17
19
  full_endpoint = "#{Ghtk.setup.domain}#{endpoint}?ver=#{Ghtk.setup.version}"
18
- response = Http.headers(
20
+ response = HTTP.headers(
19
21
  content_type: 'aplication/json',
20
22
  token: Ghtk.setup.access_token,
21
23
  ).get(full_endpoint, params: params)
data/lib/ghtk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ghtk
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.4"
3
3
  end
data/lib/ghtk.rb CHANGED
@@ -1,4 +1,3 @@
1
- require "http"
2
1
  require "ghtk/support/hash"
3
2
  require "ghtk/version"
4
3
  require "ghtk/error"
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.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - KhoaRB
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-22 00:00:00.000000000 Z
11
+ date: 2023-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -101,7 +101,7 @@ licenses:
101
101
  - MIT
102
102
  metadata:
103
103
  homepage_uri: https://github.com/ThanhKhoaIT/ghtk
104
- post_install_message:
104
+ post_install_message:
105
105
  rdoc_options: []
106
106
  require_paths:
107
107
  - lib
@@ -116,8 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.0.3
120
- signing_key:
119
+ rubygems_version: 3.2.3
120
+ signing_key:
121
121
  specification_version: 4
122
122
  summary: GHTK API Caller
123
123
  test_files: []