shipengine_ruby 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/Gemfile.lock +5 -5
- data/lib/shipengine/enums/webhooks_types.rb +8 -1
- data/lib/shipengine/exceptions.rb +10 -7
- data/lib/shipengine/faraday/raise_http_exception.rb +14 -0
- data/lib/shipengine/version.rb +1 -1
- data/shipengine.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 623cec2a7f40bf13f4f6094812d11e4b5a929bf8ce81f67a8472493fdef3bd6d
|
4
|
+
data.tar.gz: 84cd4bf666bb3c72f89b3c0a051ba2362e41bfe07092f90c3234700877491b3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 062cc63359517d87dc76ffd2a0c6853da7eff55e6c0565b1f4452ad2029c1a51fce1f619fdccdc0472e38655550adc9ab1cc3afabea39f189456e21167abd294
|
7
|
+
data.tar.gz: d7eb59f62036b13b3b632f75c11bfd1285a6eef21a96d4aff3b31f3b4d1ae96b06baa75f962b1ff9172d25ce9ec141a39ecec0e8e93c9599ec0b35b127ff21bc
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.7
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shipengine_ruby (0.0.
|
4
|
+
shipengine_ruby (0.0.7)
|
5
5
|
faraday (~> 1.0)
|
6
6
|
faraday_middleware (~> 1.0)
|
7
|
-
hashie (~>
|
7
|
+
hashie (~> 5.0)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
crack (0.4.5)
|
17
17
|
rexml
|
18
18
|
diff-lcs (1.5.0)
|
19
|
-
faraday (1.10.
|
19
|
+
faraday (1.10.3)
|
20
20
|
faraday-em_http (~> 1.0)
|
21
21
|
faraday-em_synchrony (~> 1.0)
|
22
22
|
faraday-excon (~> 1.1)
|
@@ -42,9 +42,9 @@ GEM
|
|
42
42
|
faraday_middleware (1.2.0)
|
43
43
|
faraday (~> 1.0)
|
44
44
|
hashdiff (1.0.1)
|
45
|
-
hashie (
|
45
|
+
hashie (5.0.0)
|
46
46
|
method_source (1.0.0)
|
47
|
-
multipart-post (2.
|
47
|
+
multipart-post (2.3.0)
|
48
48
|
parallel (1.22.1)
|
49
49
|
parser (3.1.2.1)
|
50
50
|
ast (~> 2.4.1)
|
@@ -1,42 +1,49 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShipEngine
|
4
4
|
module Enums
|
5
5
|
module WebhooksTypes
|
6
6
|
##
|
7
7
|
# Batch completed
|
8
8
|
# #/
|
9
9
|
API_BATCH = "batch"
|
10
|
+
API_BATCH_RESOURCE_TYPE = "API_BATCH"
|
10
11
|
|
11
12
|
##
|
12
13
|
# Shipment rate updated
|
13
14
|
# #/
|
14
15
|
API_RATE = "rate"
|
16
|
+
API_RATE_RESOURCE_TYPE = "API_RATE"
|
15
17
|
|
16
18
|
##
|
17
19
|
# Any tracking event
|
18
20
|
# #/
|
19
21
|
API_TRACK = "track"
|
22
|
+
API_TRACK_RESOURCE_TYPE = "API_TRACK"
|
20
23
|
|
21
24
|
##
|
22
25
|
# Carrier connected
|
23
26
|
# #/
|
24
27
|
API_CARRIER_CONNECTED = "carrier_connected"
|
28
|
+
API_CARRIER_CONNECTED_RESOURCE_TYPE = "API_CARRIER_CONNECTED"
|
25
29
|
|
26
30
|
##
|
27
31
|
# Sales Orders imported (Beta)
|
28
32
|
# #/
|
29
33
|
API_SALES_ORDERS_IMPORTED = "sales_orders_imported"
|
34
|
+
API_SALES_ORDERS_IMPORTED_RESOURCE_TYPE = "API_SALES_ORDERS_IMPORTED"
|
30
35
|
|
31
36
|
##
|
32
37
|
# Order Source refresh complete (Beta)
|
33
38
|
# #/
|
34
39
|
API_ORDER_SOURCE_REFRESH_COMPLETE = "order_source_refresh_complete"
|
40
|
+
API_ORDER_SOURCE_REFRESH_COMPLETE_RESOURCE_TYPE = "API_ORDER_SOURCE_REFRESH_COMPLETE"
|
35
41
|
|
36
42
|
##
|
37
43
|
# A requested report is ready
|
38
44
|
# #/
|
39
45
|
API_REPORT_COMPLETE = "report_complete"
|
46
|
+
API_REPORT_COMPLETE_RESOURCE_TYPE = "API_REPORT_COMPLETE"
|
40
47
|
|
41
48
|
ALL = [
|
42
49
|
API_BATCH,
|
@@ -8,12 +8,13 @@ module ShipEngine
|
|
8
8
|
module Exceptions
|
9
9
|
class ShipEngineError < StandardError
|
10
10
|
# message is inherited
|
11
|
-
attr_reader :source, :type, :code, :url
|
11
|
+
attr_reader :source, :type, :code, :request_id, :url
|
12
12
|
|
13
|
-
def initialize(message:, source:, type:, code:, url: nil)
|
13
|
+
def initialize(message:, source:, type:, code:, request_id: nil, url: nil)
|
14
14
|
code = ShipEngine::Errors::ErrorCode.get(code) if code.is_a?(String)
|
15
15
|
source = ShipEngine::Errors::ErrorSource.get(source) if source.is_a?(String)
|
16
16
|
super(message)
|
17
|
+
@request_id = request_id
|
17
18
|
@source = source
|
18
19
|
@type = type
|
19
20
|
@code = code
|
@@ -46,32 +47,34 @@ module ShipEngine
|
|
46
47
|
source: source,
|
47
48
|
message: message,
|
48
49
|
type: ShipEngine::Errors::ErrorType.get(:VALIDATION),
|
49
|
-
|
50
|
+
)
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
54
|
class SystemError < ShipEngineError
|
54
|
-
def initialize(message:, code:, source: nil, url: nil)
|
55
|
+
def initialize(message:, code:, source: nil, url: nil, request_id: nil)
|
55
56
|
super(
|
56
57
|
url: url,
|
57
58
|
code: code,
|
58
59
|
source: source,
|
59
60
|
message: message,
|
61
|
+
request_id: request_id,
|
60
62
|
type: ShipEngine::Errors::ErrorType.get(:SYSTEM),
|
61
|
-
|
63
|
+
)
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
67
|
class RateLimitError < SystemError
|
66
68
|
attr_reader :retries
|
67
69
|
|
68
|
-
def initialize(retries: nil, message: "You have exceeded the rate limit.", source: nil)
|
70
|
+
def initialize(retries: nil, message: "You have exceeded the rate limit.", source: nil, request_id: nil)
|
69
71
|
super(
|
70
72
|
message: message,
|
71
73
|
code: ShipEngine::Errors::ErrorCode.get(:RATE_LIMIT_EXCEEDED),
|
72
74
|
source: source,
|
75
|
+
request_id: request_id,
|
73
76
|
url: URI("https://www.shipengine.com/docs/rate-limits"),
|
74
|
-
|
77
|
+
)
|
75
78
|
@retries = retries
|
76
79
|
end
|
77
80
|
end
|
@@ -14,11 +14,13 @@ module ShipEngine
|
|
14
14
|
source: error_source(response[:body]),
|
15
15
|
type: error_type(response[:body]),
|
16
16
|
code: error_code(response[:body]),
|
17
|
+
request_id: error_request_id(response[:body]),
|
17
18
|
url: response[:url].to_s
|
18
19
|
)
|
19
20
|
elsif [429].include?(status_code)
|
20
21
|
raise ShipEngine::Exceptions::RateLimitError.new(
|
21
22
|
retries: env.request_headers["Retries"].to_i,
|
23
|
+
request_id: error_request_id(response[:body]),
|
22
24
|
source: error_source(response[:body])
|
23
25
|
)
|
24
26
|
end
|
@@ -78,6 +80,18 @@ module ShipEngine
|
|
78
80
|
body["errors"][0]["error_code"]
|
79
81
|
end
|
80
82
|
end
|
83
|
+
|
84
|
+
def error_request_id(body)
|
85
|
+
if !body.nil? && !body.empty? && body.is_a?(String)
|
86
|
+
body = JSON.parse(body)
|
87
|
+
end
|
88
|
+
|
89
|
+
if body.nil?
|
90
|
+
nil
|
91
|
+
elsif body["request_id"]
|
92
|
+
body["request_id"]
|
93
|
+
end
|
94
|
+
end
|
81
95
|
end
|
82
96
|
end
|
83
97
|
end
|
data/lib/shipengine/version.rb
CHANGED
data/shipengine.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.add_runtime_dependency("faraday", "~> 1.0")
|
30
30
|
spec.add_runtime_dependency("faraday_middleware", "~> 1.0")
|
31
|
-
spec.add_runtime_dependency("hashie", "~>
|
31
|
+
spec.add_runtime_dependency("hashie", "~> 5.0")
|
32
32
|
|
33
33
|
spec.add_development_dependency("bundler", "~> 1.17")
|
34
34
|
spec.add_development_dependency("pry", "~> 0.14")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipengine_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohammed Abdel Raouf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '5.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '5.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- ".gitignore"
|
175
175
|
- ".rspec"
|
176
176
|
- ".rubocop.yml"
|
177
|
+
- ".tool-versions"
|
177
178
|
- CODE_OF_CONDUCT.md
|
178
179
|
- Gemfile
|
179
180
|
- Gemfile.lock
|
@@ -241,8 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
242
|
- !ruby/object:Gem::Version
|
242
243
|
version: '0'
|
243
244
|
requirements: []
|
244
|
-
|
245
|
-
rubygems_version: 2.7.6.2
|
245
|
+
rubygems_version: 3.4.6
|
246
246
|
signing_key:
|
247
247
|
specification_version: 4
|
248
248
|
summary: Ruby SDK for ShipEngine
|