freight_kit 0.1.25 → 0.1.26
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/Gemfile.lock +74 -40
- data/VERSION +1 -1
- data/lib/freight_kit/carriers/champs_freight_solutions.rb +13 -0
- data/lib/freight_kit/carriers.rb +1 -0
- data/lib/freight_kit/http_client/safe_retries.rb +11 -7
- data/lib/freight_kit/http_client.rb +5 -2
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e5aa8fde24e214ab02b8ae57a88edee7db8cb0525d2cabdea293d222c4fca8e
|
|
4
|
+
data.tar.gz: 1adf8e899362c771fe118cf7410065872f5d3769befce9bec76a3a7dd619d7fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64f97af95e8acd7cf94f81a6c1c0ee6014bad35b18281e1a7bd7fc6845dacfee3bb5ae04beef86285ca7bc1fe5567347ed8233b5caf37461d814376c57ab9bd2
|
|
7
|
+
data.tar.gz: 5b434e6dd2b7946bbb54f258022d1c346d50f63c68b371e8350f375b31675317428d09d7fe421c910a6e9475e18eb01841f13b30476f124d0b0adf8dcf6c80ae
|
data/Gemfile.lock
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
freight_kit (0.1.
|
|
4
|
+
freight_kit (0.1.25)
|
|
5
|
+
StreetAddress (~> 2.0)
|
|
5
6
|
active_utils (>= 3.3.1, < 3.7.0)
|
|
6
7
|
activemodel (>= 7.1, < 8.1.5)
|
|
7
8
|
activesupport (>= 7.1, < 8.1.5)
|
|
8
9
|
benchmark (~> 0.5.0)
|
|
10
|
+
brotli (>= 0.9.2, < 1)
|
|
9
11
|
business_time (~> 0.13.0)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
countries (~> 8.1)
|
|
13
|
+
graphql (>= 2.0, < 3)
|
|
14
|
+
graphql-client (>= 0.23.0, < 1)
|
|
15
|
+
httpx (>= 1.9.0, < 2, != 1.9.1)
|
|
16
|
+
json (< 3)
|
|
17
|
+
measured (>= 2.0, < 3.2.3)
|
|
12
18
|
mimemagic (~> 0.4.3)
|
|
19
|
+
multi_xml (>= 0.9.1, < 1)
|
|
13
20
|
nokogiri (>= 1.6, < 1.20)
|
|
14
21
|
place_kit (~> 0.0.6)
|
|
15
|
-
savon (>= 2.17, < 2.
|
|
22
|
+
savon (>= 2.17, < 2.19)
|
|
16
23
|
tzinfo-data (~> 1.2023, >= 1.2023.3)
|
|
17
24
|
watir (>= 7.0, < 7.4)
|
|
18
25
|
zeitwerk (>= 2.6.0, < 2.8.4)
|
|
26
|
+
zstd-ruby (>= 2.0.10, < 3)
|
|
19
27
|
|
|
20
28
|
GEM
|
|
21
29
|
remote: https://rubygems.org/
|
|
22
30
|
specs:
|
|
31
|
+
StreetAddress (2.0.0)
|
|
23
32
|
active_utils (3.4.1)
|
|
24
33
|
activesupport (>= 4.2)
|
|
25
34
|
i18n
|
|
@@ -48,12 +57,15 @@ GEM
|
|
|
48
57
|
base64 (0.3.0)
|
|
49
58
|
benchmark (0.5.0)
|
|
50
59
|
bigdecimal (3.3.1)
|
|
60
|
+
brotli (0.9.2)
|
|
51
61
|
builder (3.3.0)
|
|
52
62
|
business_time (0.13.0)
|
|
53
63
|
activesupport (>= 3.2.0)
|
|
54
64
|
tzinfo
|
|
55
65
|
concurrent-ruby (1.3.6)
|
|
56
66
|
connection_pool (3.0.2)
|
|
67
|
+
countries (8.1.0)
|
|
68
|
+
unaccent (~> 0.3)
|
|
57
69
|
csv (3.3.5)
|
|
58
70
|
date (3.5.1)
|
|
59
71
|
diff-lcs (1.5.0)
|
|
@@ -66,21 +78,30 @@ GEM
|
|
|
66
78
|
logger
|
|
67
79
|
faraday-net_http (3.4.4)
|
|
68
80
|
net-http (~> 0.5)
|
|
81
|
+
fiber-storage (1.0.1)
|
|
82
|
+
graphql (2.6.14)
|
|
83
|
+
base64
|
|
84
|
+
fiber-storage
|
|
85
|
+
logger
|
|
86
|
+
graphql-client (0.26.0)
|
|
87
|
+
activesupport (>= 3.0)
|
|
88
|
+
graphql (>= 1.13.0)
|
|
69
89
|
gyoku (1.4.0)
|
|
70
90
|
builder (>= 2.1.2)
|
|
71
91
|
rexml (~> 3.0)
|
|
72
|
-
|
|
73
|
-
mini_mime (>= 1.0.0)
|
|
74
|
-
multi_xml (>= 0.5.2)
|
|
92
|
+
http-2 (1.3.0)
|
|
75
93
|
httpi (4.0.4)
|
|
76
94
|
base64
|
|
77
95
|
mutex_m
|
|
78
96
|
nkf
|
|
79
97
|
rack (>= 2.0, < 4)
|
|
98
|
+
httpx (1.9.0)
|
|
99
|
+
http-2 (>= 1.2.0)
|
|
80
100
|
i18n (1.14.8)
|
|
81
101
|
concurrent-ruby (~> 1.0)
|
|
82
102
|
json (2.7.2)
|
|
83
103
|
language_server-protocol (3.17.0.3)
|
|
104
|
+
lint_roller (1.1.0)
|
|
84
105
|
logger (1.7.0)
|
|
85
106
|
mail (2.9.0)
|
|
86
107
|
logger
|
|
@@ -97,8 +118,8 @@ GEM
|
|
|
97
118
|
minitest (6.0.6)
|
|
98
119
|
drb (~> 2.0)
|
|
99
120
|
prism (~> 1.5)
|
|
100
|
-
multi_xml (0.
|
|
101
|
-
bigdecimal (
|
|
121
|
+
multi_xml (0.9.1)
|
|
122
|
+
bigdecimal (>= 3.1, < 5)
|
|
102
123
|
mutex_m (0.3.0)
|
|
103
124
|
net-http (0.9.1)
|
|
104
125
|
uri (>= 0.11.1)
|
|
@@ -117,7 +138,7 @@ GEM
|
|
|
117
138
|
nori (2.7.1)
|
|
118
139
|
bigdecimal
|
|
119
140
|
parallel (1.25.1)
|
|
120
|
-
parser (3.3.
|
|
141
|
+
parser (3.3.13.0)
|
|
121
142
|
ast (~> 2.4.1)
|
|
122
143
|
racc
|
|
123
144
|
place_kit (0.0.6)
|
|
@@ -130,7 +151,7 @@ GEM
|
|
|
130
151
|
rainbow (3.1.1)
|
|
131
152
|
rake (13.4.2)
|
|
132
153
|
redcarpet (3.6.0)
|
|
133
|
-
regexp_parser (2.
|
|
154
|
+
regexp_parser (2.13.1)
|
|
134
155
|
rexml (3.4.4)
|
|
135
156
|
rspec (3.12.0)
|
|
136
157
|
rspec-core (~> 3.12.0)
|
|
@@ -145,39 +166,49 @@ GEM
|
|
|
145
166
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
146
167
|
rspec-support (~> 3.12.0)
|
|
147
168
|
rspec-support (3.12.1)
|
|
148
|
-
rubocop (1.
|
|
149
|
-
json (
|
|
150
|
-
language_server-protocol (
|
|
151
|
-
|
|
169
|
+
rubocop (1.92.2)
|
|
170
|
+
json (>= 2.3)
|
|
171
|
+
language_server-protocol (~> 3.17.0.2)
|
|
172
|
+
lint_roller (~> 1.1.0)
|
|
173
|
+
parallel (>= 1.10)
|
|
152
174
|
parser (>= 3.3.0.2)
|
|
153
175
|
rainbow (>= 2.2.2, < 4.0)
|
|
154
|
-
regexp_parser (>=
|
|
155
|
-
|
|
156
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
|
176
|
+
regexp_parser (>= 2.11.3, < 3.0)
|
|
177
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
157
178
|
ruby-progressbar (~> 1.7)
|
|
158
|
-
unicode-display_width (>= 2.4.0, <
|
|
159
|
-
rubocop-ast (1.
|
|
160
|
-
parser (>= 3.3.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
rubocop (>= 1.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
rubocop
|
|
168
|
-
rubocop-
|
|
169
|
-
rubocop-
|
|
170
|
-
|
|
179
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
180
|
+
rubocop-ast (1.50.0)
|
|
181
|
+
parser (>= 3.3.7.2)
|
|
182
|
+
prism (~> 1.7)
|
|
183
|
+
rubocop-graphql (1.8.0)
|
|
184
|
+
lint_roller (~> 1.1)
|
|
185
|
+
rubocop (>= 1.89, < 2)
|
|
186
|
+
rubocop-next (1.0.11)
|
|
187
|
+
benchmark
|
|
188
|
+
rubocop (>= 1.91, < 1.93)
|
|
189
|
+
rubocop-graphql (>= 1.6, < 1.9)
|
|
190
|
+
rubocop-rails (>= 2.29, < 2.39)
|
|
191
|
+
rubocop-rake (~> 0.7.0)
|
|
192
|
+
rubocop-rspec (>= 3.5, < 3.11)
|
|
193
|
+
rubocop-rspec_rails (>= 2.31, < 2.34)
|
|
194
|
+
tsort
|
|
195
|
+
rubocop-rails (2.38.0)
|
|
171
196
|
activesupport (>= 4.2.0)
|
|
197
|
+
lint_roller (~> 1.1)
|
|
172
198
|
rack (>= 1.1)
|
|
173
|
-
rubocop (>= 1.
|
|
174
|
-
rubocop-ast (>= 1.
|
|
175
|
-
rubocop-rake (0.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
199
|
+
rubocop (>= 1.89.0, < 2.0)
|
|
200
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
|
201
|
+
rubocop-rake (0.7.1)
|
|
202
|
+
lint_roller (~> 1.1)
|
|
203
|
+
rubocop (>= 1.72.1)
|
|
204
|
+
rubocop-rspec (3.10.2)
|
|
205
|
+
lint_roller (~> 1.1)
|
|
206
|
+
regexp_parser (>= 2.0)
|
|
207
|
+
rubocop (~> 1.86, >= 1.86.2)
|
|
208
|
+
rubocop-rspec_rails (2.33.0)
|
|
209
|
+
lint_roller (~> 1.1)
|
|
210
|
+
rubocop (~> 1.89)
|
|
211
|
+
rubocop-rspec (~> 3.5)
|
|
181
212
|
ruby-progressbar (1.13.0)
|
|
182
213
|
rubyzip (2.3.2)
|
|
183
214
|
savon (2.17.1)
|
|
@@ -195,10 +226,12 @@ GEM
|
|
|
195
226
|
rubyzip (>= 1.2.2, < 3.0)
|
|
196
227
|
websocket (~> 1.0)
|
|
197
228
|
timeout (0.6.1)
|
|
229
|
+
tsort (0.2.0)
|
|
198
230
|
tzinfo (2.0.6)
|
|
199
231
|
concurrent-ruby (~> 1.0)
|
|
200
232
|
tzinfo-data (1.2023.3)
|
|
201
233
|
tzinfo (>= 1.0.0)
|
|
234
|
+
unaccent (0.4.0)
|
|
202
235
|
unicode-display_width (2.5.0)
|
|
203
236
|
uri (1.1.1)
|
|
204
237
|
wasabi (5.1.0)
|
|
@@ -211,6 +244,7 @@ GEM
|
|
|
211
244
|
websocket (1.2.10)
|
|
212
245
|
yard (0.9.34)
|
|
213
246
|
zeitwerk (2.6.11)
|
|
247
|
+
zstd-ruby (2.0.10)
|
|
214
248
|
|
|
215
249
|
PLATFORMS
|
|
216
250
|
arm64-darwin-22
|
|
@@ -225,7 +259,7 @@ DEPENDENCIES
|
|
|
225
259
|
rake (~> 13.4.2)
|
|
226
260
|
redcarpet (~> 3.6.0)
|
|
227
261
|
rspec (~> 3.12)
|
|
228
|
-
rubocop-next (~> 1.0.
|
|
262
|
+
rubocop-next (~> 1.0.9)
|
|
229
263
|
yard (~> 0.9.28)
|
|
230
264
|
|
|
231
265
|
BUNDLED WITH
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.26
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module FreightKit
|
|
2
|
+
module Carriers
|
|
3
|
+
class ChampsFreightSolutions < Platforms::NextTMS
|
|
4
|
+
class << self
|
|
5
|
+
def consider_bol_and_pod_documents_same? = true
|
|
6
|
+
def id = '850ea54e-1547-4ced-a20d-96dc85f47243'
|
|
7
|
+
def name = 'Champs Freight Solutions'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
API = Platforms::NextTMS::API.deep_merge(domain: 'champsfreightsolutions.com').freeze
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/freight_kit/carriers.rb
CHANGED
|
@@ -44,6 +44,7 @@ FreightKit::Carriers.register(:MountainValleyExpress)
|
|
|
44
44
|
FreightKit::Carriers.register(:JFJTransportation)
|
|
45
45
|
FreightKit::Carriers.register(:STG)
|
|
46
46
|
FreightKit::Carriers.register(:TotalTransportation)
|
|
47
|
+
FreightKit::Carriers.register(:ChampsFreightSolutions)
|
|
47
48
|
|
|
48
49
|
# Without an API
|
|
49
50
|
FreightKit::Carriers.register(:AAAExpeditedServices)
|
|
@@ -8,7 +8,9 @@ module FreightKit
|
|
|
8
8
|
# Streams refused by an HTTP/2 GOAWAY are resent by HTTPX itself, independently of retries.
|
|
9
9
|
#
|
|
10
10
|
# A 429 means the server did not process the request, so any request is retried once after its
|
|
11
|
-
# Retry-After seconds, unless that is longer than {MAX_RETRY_AFTER}
|
|
11
|
+
# Retry-After seconds, unless that is longer than {MAX_RETRY_AFTER} or the request's `total_request_timeout`.
|
|
12
|
+
#
|
|
13
|
+
# The `total_request_timeout` runs across retries and is never retried itself, so retries cannot extend a call.
|
|
12
14
|
module SafeRetries
|
|
13
15
|
IDEMPOTENT_METHODS = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT'].freeze
|
|
14
16
|
# Longest wait in seconds. Longer waits return the 429, so callers can reschedule instead of blocking.
|
|
@@ -17,18 +19,20 @@ module FreightKit
|
|
|
17
19
|
module InstanceMethods
|
|
18
20
|
private
|
|
19
21
|
|
|
20
|
-
def rate_limited?(response)
|
|
21
|
-
|
|
22
|
+
def rate_limited?(response, options)
|
|
23
|
+
longest = [MAX_RETRY_AFTER, options.timeout.total_request_timeout].compact.min
|
|
24
|
+
|
|
25
|
+
response.is_a?(HTTPX::Response) && response.status == 429 && retry_after(response)&.between?(0, longest)
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
def retry_after(response) = Integer(response.headers['retry-after'], 10, exception: false)
|
|
25
29
|
|
|
26
|
-
def retryable_request?(request, response,
|
|
27
|
-
rate_limited?(response) || (super && IDEMPOTENT_METHODS.include?(request.verb))
|
|
30
|
+
def retryable_request?(request, response, options)
|
|
31
|
+
rate_limited?(response, options) || (super && IDEMPOTENT_METHODS.include?(request.verb))
|
|
28
32
|
end
|
|
29
33
|
|
|
30
|
-
def retryable_response?(response,
|
|
31
|
-
def when_to_retry(request, response,
|
|
34
|
+
def retryable_response?(response, options) = super || rate_limited?(response, options)
|
|
35
|
+
def when_to_retry(request, response, options) = rate_limited?(response, options) ? retry_after(response) : super
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
class << self
|
|
@@ -7,6 +7,9 @@ module FreightKit
|
|
|
7
7
|
# FreightKit::HTTPClient.cache = Rails.cache
|
|
8
8
|
# FreightKit::HTTPClient.logger = Rails.logger
|
|
9
9
|
class HTTPClient
|
|
10
|
+
# Seconds. A slow carrier must not hold the caller's threads, so the total covers every retry: one connect plus one
|
|
11
|
+
# read. Callers waiting on slow APIs pass a longer `read_timeout:`, which raises the total to match.
|
|
12
|
+
TIMEOUTS = { connect_timeout: 5, read_timeout: 15, total_request_timeout: 20, write_timeout: 15 }.freeze
|
|
10
13
|
USER_AGENT = "freight_kit/#{VERSION} #{HTTPX::Options::USER_AGENT}".freeze
|
|
11
14
|
|
|
12
15
|
@sessions = Concurrent::Map.new
|
|
@@ -32,7 +35,7 @@ module FreightKit
|
|
|
32
35
|
def request(verb, url, body: nil, headers: {}, proxy_url: nil, query: nil, read_timeout: nil)
|
|
33
36
|
options = { headers: }
|
|
34
37
|
options[:params] = query if query.present?
|
|
35
|
-
options[:timeout] = { read_timeout: } if read_timeout
|
|
38
|
+
options[:timeout] = { read_timeout:, total_request_timeout: TIMEOUTS[:connect_timeout] + read_timeout } if read_timeout
|
|
36
39
|
|
|
37
40
|
# Like HTTParty, hashes are form-encoded regardless of the Content-Type header
|
|
38
41
|
if body.is_a?(Hash)
|
|
@@ -67,7 +70,7 @@ module FreightKit
|
|
|
67
70
|
.plugin(:response_cache, response_cache_store: CacheStore.new(cache))
|
|
68
71
|
.plugin(Revalidation)
|
|
69
72
|
.plugin(SafeRetries)
|
|
70
|
-
.with(close_on_fork: true, headers: { 'user-agent' => USER_AGENT })
|
|
73
|
+
.with(close_on_fork: true, headers: { 'user-agent' => USER_AGENT }, timeout: TIMEOUTS)
|
|
71
74
|
|
|
72
75
|
logger = self.logger
|
|
73
76
|
session = session.with(debug: LogDevice.new(logger), debug_level: 2) if logger.level <= ::Logger::DEBUG
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: freight_kit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.26
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Third Party Transportation Systems LLC
|
|
@@ -570,6 +570,7 @@ files:
|
|
|
570
570
|
- lib/freight_kit/carriers/cedar_supply_trucking.rb
|
|
571
571
|
- lib/freight_kit/carriers/central_freight_lines.rb
|
|
572
572
|
- lib/freight_kit/carriers/central_transport.rb
|
|
573
|
+
- lib/freight_kit/carriers/champs_freight_solutions.rb
|
|
573
574
|
- lib/freight_kit/carriers/chicago_suburban_express.rb
|
|
574
575
|
- lib/freight_kit/carriers/city_logistics.rb
|
|
575
576
|
- lib/freight_kit/carriers/clear_lane_freight_systems.rb
|