friendly_shipping 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +18 -5
  3. data/.env.template +1 -1
  4. data/.rubocop.yml +4 -1
  5. data/CHANGELOG.md +14 -3
  6. data/README.md +1 -1
  7. data/friendly_shipping.gemspec +6 -7
  8. data/lib/friendly_shipping/api_error.rb +14 -0
  9. data/lib/friendly_shipping/api_error_handler.rb +30 -0
  10. data/lib/friendly_shipping/http_client.rb +9 -27
  11. data/lib/friendly_shipping/request.rb +5 -3
  12. data/lib/friendly_shipping/response.rb +27 -1
  13. data/lib/friendly_shipping/services/ship_engine/parse_label_response.rb +8 -2
  14. data/lib/friendly_shipping/services/ship_engine/parse_rate_estimate_response.rb +28 -6
  15. data/lib/friendly_shipping/services/ship_engine.rb +9 -5
  16. data/lib/friendly_shipping/services/ups/parse_shipment_accept_response.rb +1 -1
  17. data/lib/friendly_shipping/services/ups/parse_shipment_confirm_response.rb +1 -1
  18. data/lib/friendly_shipping/services/ups/parse_void_shipment_response.rb +1 -1
  19. data/lib/friendly_shipping/services/ups/rate_estimate_options.rb +1 -1
  20. data/lib/friendly_shipping/services/ups/rate_estimate_package_options.rb +1 -1
  21. data/lib/friendly_shipping/services/ups/shipping_methods.rb +4 -0
  22. data/lib/friendly_shipping/services/ups.rb +10 -2
  23. data/lib/friendly_shipping/services/ups_freight/api_error.rb +36 -0
  24. data/lib/friendly_shipping/services/ups_freight/generate_delivery_options_hash.rb +6 -4
  25. data/lib/friendly_shipping/services/ups_freight/generate_freight_ship_request_hash.rb +5 -2
  26. data/lib/friendly_shipping/services/ups_freight/generate_location_hash.rb +6 -9
  27. data/lib/friendly_shipping/services/ups_freight/generate_pickup_options_hash.rb +4 -3
  28. data/lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb +27 -0
  29. data/lib/friendly_shipping/services/ups_freight/label_delivery_options.rb +7 -1
  30. data/lib/friendly_shipping/services/ups_freight/label_options.rb +28 -2
  31. data/lib/friendly_shipping/services/ups_freight/label_pickup_options.rb +3 -0
  32. data/lib/friendly_shipping/services/ups_freight/parse_freight_label_response.rb +27 -8
  33. data/lib/friendly_shipping/services/ups_freight/parse_shipment_document.rb +1 -1
  34. data/lib/friendly_shipping/services/ups_freight/shipment_information.rb +5 -2
  35. data/lib/friendly_shipping/services/ups_freight.rb +8 -5
  36. data/lib/friendly_shipping/services/usps/parse_package_rate.rb +16 -1
  37. data/lib/friendly_shipping/services/usps/rate_estimate_options.rb +1 -1
  38. data/lib/friendly_shipping/services/usps/rate_estimate_package_options.rb +23 -19
  39. data/lib/friendly_shipping/services/usps/serialize_rate_request.rb +2 -0
  40. data/lib/friendly_shipping/services/usps.rb +2 -1
  41. data/lib/friendly_shipping/version.rb +1 -1
  42. data/lib/friendly_shipping.rb +1 -0
  43. metadata +18 -35
  44. data/lib/friendly_shipping/services/ups_freight/restful_api_error_handler.rb +0 -30
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly_shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-27 00:00:00.000000000 Z
11
+ date: 2022-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: data_uri
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.0.3
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.0.3
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: dry-monads
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -75,7 +61,7 @@ dependencies:
75
61
  version: '0.4'
76
62
  - - ">="
77
63
  - !ruby/object:Gem::Version
78
- version: 0.4.4
64
+ version: 0.4.5
79
65
  type: :runtime
80
66
  prerelease: false
81
67
  version_requirements: !ruby/object:Gem::Requirement
@@ -85,7 +71,7 @@ dependencies:
85
71
  version: '0.4'
86
72
  - - ">="
87
73
  - !ruby/object:Gem::Version
88
- version: 0.4.4
74
+ version: 0.4.5
89
75
  - !ruby/object:Gem::Dependency
90
76
  name: rest-client
91
77
  requirement: !ruby/object:Gem::Requirement
@@ -106,7 +92,7 @@ dependencies:
106
92
  requirements:
107
93
  - - ">="
108
94
  - !ruby/object:Gem::Version
109
- version: '1.17'
95
+ version: 2.1.4
110
96
  - - "<"
111
97
  - !ruby/object:Gem::Version
112
98
  version: '3'
@@ -116,7 +102,7 @@ dependencies:
116
102
  requirements:
117
103
  - - ">="
118
104
  - !ruby/object:Gem::Version
119
- version: '1.17'
105
+ version: 2.1.4
120
106
  - - "<"
121
107
  - !ruby/object:Gem::Version
122
108
  version: '3'
@@ -140,14 +126,14 @@ dependencies:
140
126
  requirements:
141
127
  - - "~>"
142
128
  - !ruby/object:Gem::Version
143
- version: '5.0'
129
+ version: '6.2'
144
130
  type: :development
145
131
  prerelease: false
146
132
  version_requirements: !ruby/object:Gem::Requirement
147
133
  requirements:
148
134
  - - "~>"
149
135
  - !ruby/object:Gem::Version
150
- version: '5.0'
136
+ version: '6.2'
151
137
  - !ruby/object:Gem::Dependency
152
138
  name: pry
153
139
  requirement: !ruby/object:Gem::Requirement
@@ -210,20 +196,14 @@ dependencies:
210
196
  requirements:
211
197
  - - ">="
212
198
  - !ruby/object:Gem::Version
213
- version: '0.80'
214
- - - "<"
215
- - !ruby/object:Gem::Version
216
- version: '1'
199
+ version: '0'
217
200
  type: :development
218
201
  prerelease: false
219
202
  version_requirements: !ruby/object:Gem::Requirement
220
203
  requirements:
221
204
  - - ">="
222
205
  - !ruby/object:Gem::Version
223
- version: '0.80'
224
- - - "<"
225
- - !ruby/object:Gem::Version
226
- version: '1'
206
+ version: '0'
227
207
  - !ruby/object:Gem::Dependency
228
208
  name: simplecov
229
209
  requirement: !ruby/object:Gem::Requirement
@@ -244,14 +224,14 @@ dependencies:
244
224
  requirements:
245
225
  - - "~>"
246
226
  - !ruby/object:Gem::Version
247
- version: '5.0'
227
+ version: '6.0'
248
228
  type: :development
249
229
  prerelease: false
250
230
  version_requirements: !ruby/object:Gem::Requirement
251
231
  requirements:
252
232
  - - "~>"
253
233
  - !ruby/object:Gem::Version
254
- version: '5.0'
234
+ version: '6.0'
255
235
  - !ruby/object:Gem::Dependency
256
236
  name: webmock
257
237
  requirement: !ruby/object:Gem::Requirement
@@ -291,6 +271,8 @@ files:
291
271
  - bin/setup
292
272
  - friendly_shipping.gemspec
293
273
  - lib/friendly_shipping.rb
274
+ - lib/friendly_shipping/api_error.rb
275
+ - lib/friendly_shipping/api_error_handler.rb
294
276
  - lib/friendly_shipping/api_failure.rb
295
277
  - lib/friendly_shipping/api_result.rb
296
278
  - lib/friendly_shipping/carrier.rb
@@ -344,6 +326,7 @@ files:
344
326
  - lib/friendly_shipping/services/ups/shipping_methods.rb
345
327
  - lib/friendly_shipping/services/ups/timing_options.rb
346
328
  - lib/friendly_shipping/services/ups_freight.rb
329
+ - lib/friendly_shipping/services/ups_freight/api_error.rb
347
330
  - lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
348
331
  - lib/friendly_shipping/services/ups_freight/generate_delivery_options_hash.rb
349
332
  - lib/friendly_shipping/services/ups_freight/generate_document_options_hash.rb
@@ -353,6 +336,7 @@ files:
353
336
  - lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
354
337
  - lib/friendly_shipping/services/ups_freight/generate_pickup_options_hash.rb
355
338
  - lib/friendly_shipping/services/ups_freight/generate_pickup_request_hash.rb
339
+ - lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb
356
340
  - lib/friendly_shipping/services/ups_freight/label_delivery_options.rb
357
341
  - lib/friendly_shipping/services/ups_freight/label_document_options.rb
358
342
  - lib/friendly_shipping/services/ups_freight/label_email_options.rb
@@ -367,7 +351,6 @@ files:
367
351
  - lib/friendly_shipping/services/ups_freight/rates_item_options.rb
368
352
  - lib/friendly_shipping/services/ups_freight/rates_options.rb
369
353
  - lib/friendly_shipping/services/ups_freight/rates_package_options.rb
370
- - lib/friendly_shipping/services/ups_freight/restful_api_error_handler.rb
371
354
  - lib/friendly_shipping/services/ups_freight/shipment_document.rb
372
355
  - lib/friendly_shipping/services/ups_freight/shipment_information.rb
373
356
  - lib/friendly_shipping/services/ups_freight/shipping_methods.rb
@@ -405,14 +388,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
405
388
  requirements:
406
389
  - - ">="
407
390
  - !ruby/object:Gem::Version
408
- version: '2.5'
391
+ version: '2.7'
409
392
  required_rubygems_version: !ruby/object:Gem::Requirement
410
393
  requirements:
411
394
  - - ">="
412
395
  - !ruby/object:Gem::Version
413
396
  version: '0'
414
397
  requirements: []
415
- rubygems_version: 3.0.3
398
+ rubygems_version: 3.3.26
416
399
  signing_key:
417
400
  specification_version: 4
418
401
  summary: An integration layer for shipping services
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FriendlyShipping
4
- module Services
5
- class UpsFreight
6
- class RestfulApiErrorHandler
7
- extend Dry::Monads::Result::Mixin
8
-
9
- def self.call(error, original_request: nil, original_response: nil)
10
- parsed_json = JSON.parse(error.response.body)
11
- errors = parsed_json.dig('response', 'errors')
12
-
13
- failure_string = errors.map do |err|
14
- status = err['code']
15
- desc = err['message']
16
- [status, desc].compact.join(": ").presence || 'UPS could not process the request.'
17
- end.join("\n")
18
-
19
- Failure(
20
- ApiFailure.new(
21
- failure_string,
22
- original_request: original_request,
23
- original_response: original_response
24
- )
25
- )
26
- end
27
- end
28
- end
29
- end
30
- end