friendly_shipping 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.rubocop.yml +6 -0
- data/README.md +1 -1
- data/friendly_shipping.gemspec +7 -7
- data/lib/friendly_shipping/access_token.rb +24 -0
- data/lib/friendly_shipping/api_error.rb +4 -2
- data/lib/friendly_shipping/api_error_handler.rb +4 -6
- data/lib/friendly_shipping/api_failure.rb +2 -11
- data/lib/friendly_shipping/api_result.rb +10 -0
- data/lib/friendly_shipping/http_client.rb +4 -10
- data/lib/friendly_shipping/label.rb +0 -2
- data/lib/friendly_shipping/services/rl/api_error.rb +0 -2
- data/lib/friendly_shipping/services/rl/bol_options.rb +0 -4
- data/lib/friendly_shipping/services/rl/item_options.rb +0 -2
- data/lib/friendly_shipping/services/rl/package_options.rb +0 -2
- data/lib/friendly_shipping/services/rl/parse_create_bol_response.rb +0 -3
- data/lib/friendly_shipping/services/rl/parse_invoice_response.rb +0 -3
- data/lib/friendly_shipping/services/rl/parse_print_bol_response.rb +0 -3
- data/lib/friendly_shipping/services/rl/parse_print_shipping_labels_response.rb +0 -3
- data/lib/friendly_shipping/services/rl/parse_rate_quote_response.rb +31 -4
- data/lib/friendly_shipping/services/rl/parse_transit_times_response.rb +0 -3
- data/lib/friendly_shipping/services/rl/rate_quote_options.rb +0 -4
- data/lib/friendly_shipping/services/rl/serialize_location.rb +9 -2
- data/lib/friendly_shipping/services/rl/shipment_options.rb +0 -2
- data/lib/friendly_shipping/services/rl.rb +4 -21
- data/lib/friendly_shipping/services/ship_engine/api_error.rb +0 -2
- data/lib/friendly_shipping/services/ship_engine/label_item_options.rb +0 -2
- data/lib/friendly_shipping/services/ship_engine/label_options.rb +0 -4
- data/lib/friendly_shipping/services/ship_engine/label_package_options.rb +0 -3
- data/lib/friendly_shipping/services/ship_engine/parse_address_validation_response.rb +3 -5
- data/lib/friendly_shipping/services/ship_engine/parse_carrier_response.rb +0 -2
- data/lib/friendly_shipping/services/ship_engine/parse_label_response.rb +0 -2
- data/lib/friendly_shipping/services/ship_engine/parse_rate_estimates_response.rb +2 -4
- data/lib/friendly_shipping/services/ship_engine/parse_rates_response.rb +2 -4
- data/lib/friendly_shipping/services/ship_engine/parse_void_response.rb +2 -2
- data/lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb +0 -2
- data/lib/friendly_shipping/services/ship_engine/rates_item_options.rb +0 -2
- data/lib/friendly_shipping/services/ship_engine/rates_options.rb +0 -2
- data/lib/friendly_shipping/services/ship_engine/rates_package_options.rb +0 -2
- data/lib/friendly_shipping/services/ship_engine.rb +11 -28
- data/lib/friendly_shipping/services/ship_engine_ltl/parse_carrier_response.rb +1 -3
- data/lib/friendly_shipping/services/ship_engine_ltl/parse_quote_response.rb +1 -3
- data/lib/friendly_shipping/services/ship_engine_ltl.rb +5 -17
- data/lib/friendly_shipping/services/tforce_freight/access_token.rb +3 -18
- data/lib/friendly_shipping/services/tforce_freight/api_error.rb +0 -2
- data/lib/friendly_shipping/services/tforce_freight/generate_create_bol_request_hash.rb +2 -14
- data/lib/friendly_shipping/services/tforce_freight/generate_pickup_request_hash.rb +0 -2
- data/lib/friendly_shipping/services/tforce_freight/generate_rates_request_hash.rb +0 -2
- data/lib/friendly_shipping/services/tforce_freight/package_options.rb +0 -2
- data/lib/friendly_shipping/services/tforce_freight/parse_create_bol_response.rb +0 -4
- data/lib/friendly_shipping/services/tforce_freight/parse_rates_response.rb +4 -12
- data/lib/friendly_shipping/services/tforce_freight/parse_shipment_document.rb +0 -2
- data/lib/friendly_shipping/services/tforce_freight/rates_item_options.rb +0 -2
- data/lib/friendly_shipping/services/tforce_freight/rates_options.rb +0 -3
- data/lib/friendly_shipping/services/tforce_freight/rates_package_options.rb +0 -2
- data/lib/friendly_shipping/services/tforce_freight/shipment_options.rb +0 -2
- data/lib/friendly_shipping/services/tforce_freight.rb +1 -27
- data/lib/friendly_shipping/services/ups/label_item_options.rb +0 -2
- data/lib/friendly_shipping/services/ups/label_options.rb +0 -3
- data/lib/friendly_shipping/services/ups/label_package_options.rb +0 -2
- data/lib/friendly_shipping/services/ups/parse_address_validation_response.rb +1 -1
- data/lib/friendly_shipping/services/ups/parse_rate_response.rb +0 -4
- data/lib/friendly_shipping/services/ups/parse_shipment_accept_response.rb +0 -3
- data/lib/friendly_shipping/services/ups/parse_shipment_confirm_response.rb +0 -2
- data/lib/friendly_shipping/services/ups/parse_void_shipment_response.rb +0 -2
- data/lib/friendly_shipping/services/ups/parse_xml_response.rb +1 -1
- data/lib/friendly_shipping/services/ups/rate_estimate_options.rb +0 -2
- data/lib/friendly_shipping/services/ups/rate_estimate_package_options.rb +0 -2
- data/lib/friendly_shipping/services/ups/serialize_access_request.rb +0 -2
- data/lib/friendly_shipping/services/ups/serialize_rating_service_selection_request.rb +0 -4
- data/lib/friendly_shipping/services/ups/serialize_shipment_confirm_request.rb +0 -3
- data/lib/friendly_shipping/services/ups.rb +1 -23
- data/lib/friendly_shipping/services/ups_freight/api_error.rb +0 -2
- data/lib/friendly_shipping/services/ups_freight/generate_freight_rate_request_hash.rb +0 -4
- data/lib/friendly_shipping/services/ups_freight/generate_freight_ship_request_hash.rb +0 -8
- data/lib/friendly_shipping/services/ups_freight/parse_freight_label_response.rb +0 -3
- data/lib/friendly_shipping/services/ups_freight/parse_freight_rate_response.rb +0 -4
- data/lib/friendly_shipping/services/ups_freight/parse_shipment_document.rb +0 -2
- data/lib/friendly_shipping/services/ups_freight/rates_options.rb +0 -4
- data/lib/friendly_shipping/services/ups_freight/rates_package_options.rb +0 -2
- data/lib/friendly_shipping/services/ups_freight/rates_structure_options.rb +0 -2
- data/lib/friendly_shipping/services/ups_freight/shipment_options.rb +0 -2
- data/lib/friendly_shipping/services/ups_freight.rb +1 -21
- data/lib/friendly_shipping/services/ups_json/access_token.rb +3 -12
- data/lib/friendly_shipping/services/ups_json/api_error.rb +0 -2
- data/lib/friendly_shipping/services/ups_json/generate_city_state_lookup_payload.rb +23 -0
- data/lib/friendly_shipping/services/ups_json/generate_labels_payload.rb +0 -3
- data/lib/friendly_shipping/services/ups_json/generate_rates_payload.rb +2 -4
- data/lib/friendly_shipping/services/ups_json/label_item_options.rb +0 -2
- data/lib/friendly_shipping/services/ups_json/label_options.rb +0 -3
- data/lib/friendly_shipping/services/ups_json/label_package_options.rb +0 -2
- data/lib/friendly_shipping/services/ups_json/parse_city_state_lookup_response.rb +44 -0
- data/lib/friendly_shipping/services/ups_json/parse_json_response.rb +13 -6
- data/lib/friendly_shipping/services/ups_json/parse_labels_response.rb +4 -4
- data/lib/friendly_shipping/services/ups_json/parse_money_hash.rb +1 -1
- data/lib/friendly_shipping/services/ups_json/parse_rate_modifier_hash.rb +2 -2
- data/lib/friendly_shipping/services/ups_json/parse_rates_response.rb +19 -17
- data/lib/friendly_shipping/services/ups_json/rates_item_options.rb +0 -2
- data/lib/friendly_shipping/services/ups_json/rates_options.rb +0 -2
- data/lib/friendly_shipping/services/ups_json.rb +23 -23
- data/lib/friendly_shipping/services/usps/parse_rate_response.rb +0 -4
- data/lib/friendly_shipping/services/usps/parse_time_in_transit_response.rb +0 -3
- data/lib/friendly_shipping/services/usps/parse_xml_response.rb +1 -1
- data/lib/friendly_shipping/services/usps/rate_estimate_options.rb +0 -2
- data/lib/friendly_shipping/services/usps/rate_estimate_package_options.rb +0 -2
- data/lib/friendly_shipping/services/usps/serialize_rate_request.rb +0 -2
- data/lib/friendly_shipping/services/usps.rb +1 -12
- data/lib/friendly_shipping/services/usps_international/parse_rate_response.rb +0 -3
- data/lib/friendly_shipping/services/usps_international/rate_estimate_options.rb +0 -2
- data/lib/friendly_shipping/services/usps_international/rate_estimate_package_options.rb +0 -2
- data/lib/friendly_shipping/services/usps_international/serialize_rate_request.rb +0 -2
- data/lib/friendly_shipping/services/usps_international.rb +1 -5
- data/lib/friendly_shipping/services/usps_ship/access_token.rb +3 -18
- data/lib/friendly_shipping/services/usps_ship/api_error.rb +0 -2
- data/lib/friendly_shipping/services/usps_ship/machinable_package.rb +6 -4
- data/lib/friendly_shipping/services/usps_ship/parse_rate_estimates_response.rb +3 -3
- data/lib/friendly_shipping/services/usps_ship/parse_timings_response.rb +14 -12
- data/lib/friendly_shipping/services/usps_ship/rate_estimate_package_options.rb +0 -2
- data/lib/friendly_shipping/services/usps_ship/serialize_rate_estimates_request.rb +0 -2
- data/lib/friendly_shipping/services/usps_ship.rb +1 -15
- data/lib/friendly_shipping/version.rb +1 -1
- data/lib/friendly_shipping.rb +20 -21
- metadata +7 -4
@@ -1,25 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require 'friendly_shipping/http_client'
|
5
|
-
require 'friendly_shipping/services/ship_engine/api_error'
|
6
|
-
require 'friendly_shipping/services/ship_engine/parse_carrier_response'
|
7
|
-
require 'friendly_shipping/services/ship_engine/serialize_address_validation_request'
|
8
|
-
require 'friendly_shipping/services/ship_engine/serialize_label_shipment'
|
9
|
-
require 'friendly_shipping/services/ship_engine/serialize_rate_estimate_request'
|
10
|
-
require 'friendly_shipping/services/ship_engine/serialize_rates_request'
|
11
|
-
require 'friendly_shipping/services/ship_engine/serialize_address_residential_indicator'
|
12
|
-
require 'friendly_shipping/services/ship_engine/parse_address_validation_response'
|
13
|
-
require 'friendly_shipping/services/ship_engine/parse_label_response'
|
14
|
-
require 'friendly_shipping/services/ship_engine/parse_void_response'
|
15
|
-
require 'friendly_shipping/services/ship_engine/parse_rate_estimates_response'
|
16
|
-
require 'friendly_shipping/services/ship_engine/parse_rates_response'
|
17
|
-
require 'friendly_shipping/services/ship_engine/rate_estimates_options'
|
18
|
-
require 'friendly_shipping/services/ship_engine/rates_item_options'
|
19
|
-
require 'friendly_shipping/services/ship_engine/rates_package_options'
|
20
|
-
require 'friendly_shipping/services/ship_engine/rates_options'
|
21
|
-
require 'friendly_shipping/services/ship_engine/label_options'
|
22
|
-
require 'friendly_shipping/services/ship_engine/label_package_options'
|
3
|
+
require "json"
|
23
4
|
|
24
5
|
module FriendlyShipping
|
25
6
|
module Services
|
@@ -49,7 +30,7 @@ module FriendlyShipping
|
|
49
30
|
# Get configured carriers.
|
50
31
|
#
|
51
32
|
# @param debug [Boolean] whether to attach debugging information to the response
|
52
|
-
# @return [ApiResult<Array<Carrier>>, Failure<
|
33
|
+
# @return [ApiResult<Array<Carrier>>, Failure<ApiResult>] carriers configured in your account
|
53
34
|
def carriers(debug: false)
|
54
35
|
request = FriendlyShipping::Request.new(
|
55
36
|
url: API_BASE + API_PATHS[:carriers],
|
@@ -67,7 +48,7 @@ module FriendlyShipping
|
|
67
48
|
# @param shipment [Physical::Shipment] the shipment for which we're getting rates
|
68
49
|
# @param options [RatesOptions] the options for getting rates (see object description)
|
69
50
|
#
|
70
|
-
# @return [Success<ApiResult<Array<Rate>>>, Failure<
|
51
|
+
# @return [Success<ApiResult<Array<Rate>>>, Failure<ApiResult<Array<String>>] When successfully parsing, an
|
71
52
|
# array of rates in a Success Monad. When the parsing is not successful or ShipEngine can't give us rates,
|
72
53
|
# a Failure monad containing something that can be serialized into an error message using `to_s`.
|
73
54
|
def rates(shipment, options:, debug: false)
|
@@ -88,7 +69,7 @@ module FriendlyShipping
|
|
88
69
|
# @param shipment [Physical::Shipment] the shipment for which we're getting rate estimates
|
89
70
|
# @param options [RateEstimatesOptions] the options for getting rate estimates (see object description)
|
90
71
|
#
|
91
|
-
# @return [Success<ApiResult<Array<Rate>>>, Failure<
|
72
|
+
# @return [Success<ApiResult<Array<Rate>>>, Failure<ApiResult<Array<String>>>] When successfully parsing, an
|
92
73
|
# array of rates in a Success Monad. When the parsing is not successful or ShipEngine can't give us rates,
|
93
74
|
# a Failure monad containing something that can be serialized into an error message using `to_s`.
|
94
75
|
def rate_estimates(shipment, options: FriendlyShipping::Services::ShipEngine::RateEstimatesOptions.new, debug: false)
|
@@ -113,13 +94,15 @@ module FriendlyShipping
|
|
113
94
|
# Note: Some ShipEngine carriers, notably USPS, only support one package per shipment, and that's
|
114
95
|
# all that the integration supports at this point.
|
115
96
|
# @param options [LabelOptions] the options for getting labels (see object description)
|
116
|
-
# @
|
117
|
-
|
97
|
+
# @param debug [Boolean] whether to attach debugging information to the response
|
98
|
+
# @return [ApiResult<Array<Label>>, Failure<ApiResult>] the shipping labels
|
99
|
+
def labels(shipment, options:, debug: false)
|
118
100
|
request = FriendlyShipping::Request.new(
|
119
101
|
url: API_BASE + API_PATHS[:labels],
|
120
102
|
http_method: "POST",
|
121
103
|
body: SerializeLabelShipment.call(shipment: shipment, options: options, test: test).to_json,
|
122
|
-
headers: request_headers
|
104
|
+
headers: request_headers,
|
105
|
+
debug: debug
|
123
106
|
)
|
124
107
|
client.post(request).fmap do |response|
|
125
108
|
ParseLabelResponse.call(request: request, response: response)
|
@@ -130,7 +113,7 @@ module FriendlyShipping
|
|
130
113
|
#
|
131
114
|
# @param label [Label] the label to void
|
132
115
|
# @param debug [Boolean] whether to include debugging information in the result
|
133
|
-
# @return [Success<ApiResult<String>>, Failure<
|
116
|
+
# @return [Success<ApiResult<String>>, Failure<ApiResult<String>>] the success or failure message
|
134
117
|
def void(label, debug: false)
|
135
118
|
request = FriendlyShipping::Request.new(
|
136
119
|
url: "#{API_BASE}labels/#{label.id}/void",
|
@@ -147,7 +130,7 @@ module FriendlyShipping
|
|
147
130
|
# Validate an address using ShipEngine
|
148
131
|
#
|
149
132
|
# @param location [Physical::Location] the address to validate
|
150
|
-
# @return [Success<ApiResult<Array<Physical::Location>>>, Failure<
|
133
|
+
# @return [Success<ApiResult<Array<Physical::Location>>>, Failure<ApiResult>]
|
151
134
|
def validate_address(location, debug: false)
|
152
135
|
request = FriendlyShipping::Request.new(
|
153
136
|
url: "#{API_BASE}addresses/validate",
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'json'
|
4
|
-
|
5
3
|
module FriendlyShipping
|
6
4
|
module Services
|
7
5
|
class ShipEngineLTL
|
@@ -12,7 +10,7 @@ module FriendlyShipping
|
|
12
10
|
class << self
|
13
11
|
# @param request [Request] the request to attach to the API result
|
14
12
|
# @param response [Response] the response to parse
|
15
|
-
# @return [Success<ApiResult<Array<Carrier>>>, Failure<
|
13
|
+
# @return [Success<ApiResult<Array<Carrier>>>, Failure<ApiResult<Array<String>>>] the parsed carriers or errors
|
16
14
|
def call(request:, response:)
|
17
15
|
parsed_json = JSON.parse(response.body)
|
18
16
|
carriers = parsed_json.fetch('carriers', []).map do |carrier_data|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'json'
|
4
|
-
|
5
3
|
module FriendlyShipping
|
6
4
|
module Services
|
7
5
|
class ShipEngineLTL
|
@@ -12,7 +10,7 @@ module FriendlyShipping
|
|
12
10
|
class << self
|
13
11
|
# @param request [Request] the request to attach to the API result
|
14
12
|
# @param response [Response] the response to parse
|
15
|
-
# @return [Success<ApiResult<Array<Rate>>>, Failure<
|
13
|
+
# @return [Success<ApiResult<Array<Rate>>>, Failure<ApiResult<Array<String>>>] the parsed rates or errors
|
16
14
|
def call(request:, response:)
|
17
15
|
parsed_json = JSON.parse(response.body)
|
18
16
|
rates = build_rates(parsed_json)
|
@@ -1,18 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require 'friendly_shipping/http_client'
|
5
|
-
require 'friendly_shipping/services/ship_engine_ltl/api_error'
|
6
|
-
require 'friendly_shipping/services/ship_engine_ltl/parse_carrier_response'
|
7
|
-
require 'friendly_shipping/services/ship_engine_ltl/parse_quote_response'
|
8
|
-
require 'friendly_shipping/services/ship_engine_ltl/serialize_packages'
|
9
|
-
require 'friendly_shipping/services/ship_engine_ltl/serialize_quote_request'
|
10
|
-
require 'friendly_shipping/services/ship_engine_ltl/serialize_structures'
|
11
|
-
require 'friendly_shipping/services/ship_engine_ltl/shipment_options'
|
12
|
-
require 'friendly_shipping/services/ship_engine_ltl/quote_options'
|
13
|
-
require 'friendly_shipping/services/ship_engine_ltl/structure_options'
|
14
|
-
require 'friendly_shipping/services/ship_engine_ltl/package_options'
|
15
|
-
require 'friendly_shipping/services/ship_engine_ltl/item_options'
|
3
|
+
require "json"
|
16
4
|
|
17
5
|
module FriendlyShipping
|
18
6
|
module Services
|
@@ -45,7 +33,7 @@ module FriendlyShipping
|
|
45
33
|
# Get configured LTL carriers.
|
46
34
|
#
|
47
35
|
# @param debug [Boolean] whether to attach debugging information to the response
|
48
|
-
# @return [Success<ApiResult<Array<Carrier>>>, Failure<
|
36
|
+
# @return [Success<ApiResult<Array<Carrier>>>, Failure<ApiResult<Array<String>>>] On success,
|
49
37
|
# LTL carriers configured in your account. On failure, a list of error messages.
|
50
38
|
def carriers(debug: false)
|
51
39
|
request = FriendlyShipping::Request.new(
|
@@ -64,7 +52,7 @@ module FriendlyShipping
|
|
64
52
|
# @param scac [String] Standard Carrier Alpha Code
|
65
53
|
# @see https://nmfta.org/scac/ SCAC
|
66
54
|
# @param debug [Boolean] whether to attach debugging information to the response
|
67
|
-
# @return [Success<ApiResult<Hash>>, Failure<
|
55
|
+
# @return [Success<ApiResult<Hash>>, Failure<ApiResult<String>>] the carrier or error message
|
68
56
|
def connect_carrier(credentials, scac, debug: false)
|
69
57
|
request = FriendlyShipping::Request.new(
|
70
58
|
url: API_BASE + API_PATHS[:connections] + "/#{scac}",
|
@@ -90,7 +78,7 @@ module FriendlyShipping
|
|
90
78
|
# @see https://nmfta.org/scac/ SCAC
|
91
79
|
# @param carrier_id [String] the ID for the carrier you want to update
|
92
80
|
# @param debug [Boolean] whether to attach debugging information to the response
|
93
|
-
# @return [Success<ApiResult<Hash>>, Failure<
|
81
|
+
# @return [Success<ApiResult<Hash>>, Failure<ApiResult<String>>] the carrier or error message
|
94
82
|
def update_carrier(credentials, scac, carrier_id, debug: false)
|
95
83
|
request = FriendlyShipping::Request.new(
|
96
84
|
url: API_BASE + API_PATHS[:connections] + "/#{scac}/#{carrier_id}",
|
@@ -115,7 +103,7 @@ module FriendlyShipping
|
|
115
103
|
# @param shipment [Physical::Shipment] the shipment to quote
|
116
104
|
# @param options [QuoteOptions] the options for the quote
|
117
105
|
# @param debug [Boolean] whether to attach debugging information to the response
|
118
|
-
# @return [Success<ApiResult<Hash>>, Failure<
|
106
|
+
# @return [Success<ApiResult<Hash>>, Failure<ApiResult<String>>] the quote or error message
|
119
107
|
def request_quote(carrier_id, shipment, options, debug: false)
|
120
108
|
request = FriendlyShipping::Request.new(
|
121
109
|
url: API_BASE + API_PATHS[:quotes] + "/#{carrier_id}",
|
@@ -7,35 +7,20 @@ module FriendlyShipping
|
|
7
7
|
class TForceFreight
|
8
8
|
# Represents an access token returned by TForce Freight. The access token can be
|
9
9
|
# used to make API requests. Once it expires, a new token must be created.
|
10
|
-
class AccessToken
|
10
|
+
class AccessToken < FriendlyShipping::AccessToken
|
11
11
|
# @return [String] the token's type
|
12
12
|
attr_reader :token_type
|
13
13
|
|
14
|
-
# @return [Integer] the token's expiration
|
15
|
-
attr_reader :expires_in
|
16
|
-
|
17
14
|
# @return [Integer] the token's extended expiration
|
18
15
|
attr_reader :ext_expires_in
|
19
16
|
|
20
|
-
# @return [String] the raw JWT token
|
21
|
-
attr_reader :raw_token
|
22
|
-
|
23
17
|
# @param token_type [String] the token's type (typically "Bearer")
|
24
|
-
# @param expires_in [Integer] the token's expiration
|
25
18
|
# @param ext_expires_in [Integer] the token's extended expiration (only applicable during a service outage)
|
26
19
|
# @see https://github.com/AzureAD/azure-activedirectory-library-for-android/issues/675 Service Outage Resiliency Support
|
27
|
-
|
28
|
-
def initialize(token_type:, expires_in:, ext_expires_in:, raw_token:)
|
20
|
+
def initialize(token_type:, ext_expires_in:, **other_kwargs)
|
29
21
|
@token_type = token_type
|
30
|
-
@expires_in = expires_in
|
31
22
|
@ext_expires_in = ext_expires_in
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
# Decodes and returns the raw JWT token.
|
36
|
-
# @return [Array<Hash>] the decoded token
|
37
|
-
def decoded_token
|
38
|
-
@_decoded_token = JWT.decode(raw_token, nil, false)
|
23
|
+
super(**other_kwargs)
|
39
24
|
end
|
40
25
|
end
|
41
26
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'friendly_shipping/services/tforce_freight/generate_location_hash'
|
4
|
-
|
5
3
|
module FriendlyShipping
|
6
4
|
module Services
|
7
5
|
class TForceFreight
|
@@ -46,7 +44,7 @@ module FriendlyShipping
|
|
46
44
|
# @return [Hash]
|
47
45
|
def location(location)
|
48
46
|
{
|
49
|
-
name:
|
47
|
+
name: truncate(location.company_name.presence || location.name),
|
50
48
|
contact: truncate(location.name),
|
51
49
|
email: truncate(location.email, length: 50),
|
52
50
|
phone: {
|
@@ -127,7 +125,7 @@ module FriendlyShipping
|
|
127
125
|
# @return [Hash]
|
128
126
|
def requester(location)
|
129
127
|
{
|
130
|
-
companyName:
|
128
|
+
companyName: truncate(location.company_name.presence || location.name),
|
131
129
|
contactName: truncate(location.name),
|
132
130
|
email: truncate(location.email, length: 50),
|
133
131
|
phone: {
|
@@ -148,16 +146,6 @@ module FriendlyShipping
|
|
148
146
|
def truncate(value, length: 35)
|
149
147
|
value && value[0..(length - 1)].strip
|
150
148
|
end
|
151
|
-
|
152
|
-
# TForce does not support special characters like &, <, or > in company names.
|
153
|
-
#
|
154
|
-
# @param name [String]
|
155
|
-
# @return [String]
|
156
|
-
def clean_company_name(name)
|
157
|
-
return if name.nil?
|
158
|
-
|
159
|
-
truncate(CGI.escapeHTML(name).strip)
|
160
|
-
end
|
161
149
|
end
|
162
150
|
end
|
163
151
|
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'friendly_shipping/rate'
|
4
|
-
require 'friendly_shipping/api_result'
|
5
|
-
require 'friendly_shipping/services/tforce_freight/shipping_methods'
|
6
|
-
|
7
3
|
module FriendlyShipping
|
8
4
|
module Services
|
9
5
|
class TForceFreight
|
@@ -25,15 +21,11 @@ module FriendlyShipping
|
|
25
21
|
total_currency = detail.dig("shipmentCharges", "total", "currency")
|
26
22
|
total = Money.new(total_amount.to_f * 100, total_currency)
|
27
23
|
|
28
|
-
|
29
|
-
data = rates.each_with_object({}) do |rate, result|
|
30
|
-
result[rate['code'].downcase.to_sym] = rate['value'].to_f
|
31
|
-
end
|
32
|
-
|
33
|
-
data.merge(
|
24
|
+
data = {
|
34
25
|
customer_context: transaction_id,
|
35
|
-
commodities: Array.wrap(json['commodities'])
|
36
|
-
|
26
|
+
commodities: Array.wrap(json['commodities']),
|
27
|
+
cost_breakdown: detail['rate'].map { |rate| rate.slice(*%w[code description value unit]) }
|
28
|
+
}
|
37
29
|
|
38
30
|
days_in_transit = detail.dig("timeInTransit", "timeInTransit")
|
39
31
|
data[:days_in_transit] = days_in_transit.to_i if days_in_transit
|
@@ -1,32 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require 'friendly_shipping/http_client'
|
5
|
-
require 'friendly_shipping/services/tforce_freight/access_token'
|
6
|
-
require 'friendly_shipping/services/tforce_freight/shipping_methods'
|
7
|
-
require 'friendly_shipping/services/tforce_freight/shipment_document'
|
8
|
-
require 'friendly_shipping/services/tforce_freight/shipment_information'
|
9
|
-
require 'friendly_shipping/services/tforce_freight/shipment_options'
|
10
|
-
require 'friendly_shipping/services/tforce_freight/rates_options'
|
11
|
-
require 'friendly_shipping/services/tforce_freight/structure_options'
|
12
|
-
require 'friendly_shipping/services/tforce_freight/package_options'
|
13
|
-
require 'friendly_shipping/services/tforce_freight/rates_package_options'
|
14
|
-
require 'friendly_shipping/services/tforce_freight/item_options'
|
15
|
-
require 'friendly_shipping/services/tforce_freight/rates_item_options'
|
16
|
-
require 'friendly_shipping/services/tforce_freight/pickup_options'
|
17
|
-
require 'friendly_shipping/services/tforce_freight/bol_options'
|
18
|
-
require 'friendly_shipping/services/tforce_freight/document_options'
|
19
|
-
require 'friendly_shipping/services/tforce_freight/parse_rates_response'
|
20
|
-
require 'friendly_shipping/services/tforce_freight/parse_pickup_response'
|
21
|
-
require 'friendly_shipping/services/tforce_freight/parse_create_bol_response'
|
22
|
-
require 'friendly_shipping/services/tforce_freight/parse_shipment_document'
|
23
|
-
require 'friendly_shipping/services/tforce_freight/generate_rates_request_hash'
|
24
|
-
require 'friendly_shipping/services/tforce_freight/generate_pickup_request_hash'
|
25
|
-
require 'friendly_shipping/services/tforce_freight/generate_create_bol_request_hash'
|
26
|
-
require 'friendly_shipping/services/tforce_freight/generate_handling_units_hash'
|
27
|
-
require 'friendly_shipping/services/tforce_freight/generate_reference_hash'
|
28
|
-
require 'friendly_shipping/services/tforce_freight/generate_document_options_hash'
|
29
|
-
require 'friendly_shipping/services/tforce_freight/api_error'
|
3
|
+
require "json"
|
30
4
|
|
31
5
|
module FriendlyShipping
|
32
6
|
module Services
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'friendly_shipping/services/ups/label_package_options'
|
4
|
-
require 'friendly_shipping/services/ups/label_billing_options'
|
5
|
-
|
6
3
|
module FriendlyShipping
|
7
4
|
module Services
|
8
5
|
# Option container for a generating UPS labels for a shipment
|
@@ -15,7 +15,7 @@ module FriendlyShipping
|
|
15
15
|
parsing_result.bind do |xml|
|
16
16
|
if xml.at('NoCandidatesIndicator')
|
17
17
|
Failure(
|
18
|
-
FriendlyShipping::
|
18
|
+
FriendlyShipping::ApiResult.new(
|
19
19
|
'Address is probably invalid. No similar valid addresses found.',
|
20
20
|
original_request: request,
|
21
21
|
original_response: response
|
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'friendly_shipping/services/ups/parse_xml_response'
|
4
|
-
require 'friendly_shipping/services/ups/parse_money_element'
|
5
|
-
require 'friendly_shipping/services/ups/parse_modifier_element'
|
6
|
-
|
7
3
|
module FriendlyShipping
|
8
4
|
module Services
|
9
5
|
class Ups
|
@@ -1,28 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'friendly_shipping/http_client'
|
5
|
-
require 'friendly_shipping/services/ups/serialize_access_request'
|
6
|
-
require 'friendly_shipping/services/ups/serialize_city_state_lookup_request'
|
7
|
-
require 'friendly_shipping/services/ups/serialize_address_validation_request'
|
8
|
-
require 'friendly_shipping/services/ups/serialize_rating_service_selection_request'
|
9
|
-
require 'friendly_shipping/services/ups/serialize_shipment_accept_request'
|
10
|
-
require 'friendly_shipping/services/ups/serialize_shipment_confirm_request'
|
11
|
-
require 'friendly_shipping/services/ups/serialize_time_in_transit_request'
|
12
|
-
require 'friendly_shipping/services/ups/serialize_void_shipment_request'
|
13
|
-
require 'friendly_shipping/services/ups/parse_address_validation_response'
|
14
|
-
require 'friendly_shipping/services/ups/parse_address_classification_response'
|
15
|
-
require 'friendly_shipping/services/ups/parse_city_state_lookup_response'
|
16
|
-
require 'friendly_shipping/services/ups/parse_rate_response'
|
17
|
-
require 'friendly_shipping/services/ups/parse_shipment_confirm_response'
|
18
|
-
require 'friendly_shipping/services/ups/parse_shipment_accept_response'
|
19
|
-
require 'friendly_shipping/services/ups/parse_time_in_transit_response'
|
20
|
-
require 'friendly_shipping/services/ups/parse_void_shipment_response'
|
21
|
-
require 'friendly_shipping/services/ups/shipping_methods'
|
22
|
-
require 'friendly_shipping/services/ups/label'
|
23
|
-
require 'friendly_shipping/services/ups/label_options'
|
24
|
-
require 'friendly_shipping/services/ups/rate_estimate_options'
|
25
|
-
require 'friendly_shipping/services/ups/timing_options'
|
3
|
+
require 'nokogiri'
|
26
4
|
|
27
5
|
module FriendlyShipping
|
28
6
|
module Services
|
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'friendly_shipping/services/ups_freight/generate_location_hash'
|
4
|
-
require 'friendly_shipping/services/ups_freight/generate_pickup_request_hash'
|
5
|
-
require 'friendly_shipping/services/ups_freight/generate_handling_units_hash'
|
6
|
-
|
7
3
|
module FriendlyShipping
|
8
4
|
module Services
|
9
5
|
class UpsFreight
|