friendly_shipping 0.8.1 → 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/.env.template +3 -0
- data/.env.test.local.template +6 -0
- data/.gitignore +1 -0
- data/.rubocop-relaxed.yml +7 -23
- data/.rubocop.yml +17 -2
- data/.rubocop_todo.yml +21 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +71 -0
- data/Gemfile +17 -0
- data/README.md +1 -1
- data/friendly_shipping.gemspec +8 -17
- data/lib/friendly_shipping/access_token.rb +24 -0
- data/lib/friendly_shipping/api_error.rb +8 -4
- data/lib/friendly_shipping/api_error_handler.rb +11 -9
- data/lib/friendly_shipping/api_failure.rb +2 -7
- data/lib/friendly_shipping/api_result.rb +26 -4
- data/lib/friendly_shipping/carrier.rb +28 -8
- data/lib/friendly_shipping/http_client.rb +25 -8
- data/lib/friendly_shipping/inflections.rb +10 -0
- data/lib/friendly_shipping/item_options.rb +3 -0
- data/lib/friendly_shipping/label.rb +41 -22
- data/lib/friendly_shipping/package_options.rb +21 -2
- data/lib/friendly_shipping/rate.rb +50 -15
- data/lib/friendly_shipping/request.rb +23 -7
- data/lib/friendly_shipping/response.rb +21 -6
- data/lib/friendly_shipping/services/rl/api_error.rb +31 -0
- data/lib/friendly_shipping/services/rl/bol_options.rb +103 -0
- data/lib/friendly_shipping/services/rl/bol_packages_serializer.rb +32 -0
- data/lib/friendly_shipping/services/rl/bol_structures_serializer.rb +31 -0
- data/lib/friendly_shipping/services/rl/item_options.rb +36 -0
- data/lib/friendly_shipping/services/rl/package_options.rb +38 -0
- data/lib/friendly_shipping/services/rl/parse_create_bol_response.rb +43 -0
- data/lib/friendly_shipping/services/rl/parse_invoice_response.rb +47 -0
- data/lib/friendly_shipping/services/rl/parse_print_bol_response.rb +44 -0
- data/lib/friendly_shipping/services/rl/parse_print_shipping_labels_response.rb +44 -0
- data/lib/friendly_shipping/services/rl/parse_rate_quote_response.rb +93 -0
- data/lib/friendly_shipping/services/rl/parse_transit_times_response.rb +73 -0
- data/lib/friendly_shipping/services/rl/rate_quote_options.rb +82 -0
- data/lib/friendly_shipping/services/rl/rate_quote_packages_serializer.rb +54 -0
- data/lib/friendly_shipping/services/rl/rate_quote_structures_serializer.rb +53 -0
- data/lib/friendly_shipping/services/rl/serialize_create_bol_request.rb +86 -0
- data/lib/friendly_shipping/services/rl/serialize_location.rb +53 -0
- data/lib/friendly_shipping/services/rl/serialize_rate_quote_request.rb +69 -0
- data/lib/friendly_shipping/services/rl/serialize_transit_times_request.rb +38 -0
- data/lib/friendly_shipping/services/rl/shipment_document.rb +40 -0
- data/lib/friendly_shipping/services/rl/shipment_information.rb +41 -0
- data/lib/friendly_shipping/services/rl/shipment_options.rb +48 -0
- data/lib/friendly_shipping/services/rl/shipping_methods.rb +28 -0
- data/lib/friendly_shipping/services/rl/structure_options.rb +13 -0
- data/lib/friendly_shipping/services/rl.rb +187 -0
- data/lib/friendly_shipping/services/ship_engine/api_error.rb +31 -0
- data/lib/friendly_shipping/services/ship_engine/customs_items_serializer.rb +36 -0
- data/lib/friendly_shipping/services/ship_engine/label_customs_options.rb +10 -7
- data/lib/friendly_shipping/services/ship_engine/label_item_options.rb +10 -7
- data/lib/friendly_shipping/services/ship_engine/label_options.rb +30 -17
- data/lib/friendly_shipping/services/ship_engine/label_package_options.rb +18 -14
- data/lib/friendly_shipping/services/ship_engine/parse_address_validation_response.rb +75 -0
- data/lib/friendly_shipping/services/ship_engine/parse_carrier_response.rb +9 -2
- data/lib/friendly_shipping/services/ship_engine/parse_label_response.rb +4 -2
- data/lib/friendly_shipping/services/ship_engine/{parse_rate_estimate_response.rb → parse_rate_estimates_response.rb} +27 -9
- data/lib/friendly_shipping/services/ship_engine/parse_rates_response.rb +99 -0
- data/lib/friendly_shipping/services/ship_engine/parse_void_response.rb +5 -1
- data/lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb +17 -6
- data/lib/friendly_shipping/services/ship_engine/rates_item_options.rb +26 -0
- data/lib/friendly_shipping/services/ship_engine/rates_options.rb +59 -0
- data/lib/friendly_shipping/services/ship_engine/rates_package_options.rb +18 -0
- data/lib/friendly_shipping/services/ship_engine/serialize_address_residential_indicator.rb +27 -0
- data/lib/friendly_shipping/services/ship_engine/serialize_address_validation_request.rb +31 -0
- data/lib/friendly_shipping/services/ship_engine/serialize_label_shipment.rb +22 -27
- data/lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb +41 -16
- data/lib/friendly_shipping/services/ship_engine/serialize_rates_request.rb +126 -0
- data/lib/friendly_shipping/services/ship_engine.rb +89 -33
- data/lib/friendly_shipping/services/ship_engine_ltl/api_error.rb +12 -0
- data/lib/friendly_shipping/services/ship_engine_ltl/item_options.rb +24 -5
- data/lib/friendly_shipping/services/ship_engine_ltl/package_options.rb +39 -4
- data/lib/friendly_shipping/services/ship_engine_ltl/parse_carrier_response.rb +4 -2
- data/lib/friendly_shipping/services/ship_engine_ltl/parse_quote_response.rb +10 -2
- data/lib/friendly_shipping/services/ship_engine_ltl/quote_options.rb +29 -11
- data/lib/friendly_shipping/services/ship_engine_ltl/serialize_packages.rb +7 -2
- data/lib/friendly_shipping/services/ship_engine_ltl/serialize_quote_request.rb +50 -16
- data/lib/friendly_shipping/services/ship_engine_ltl/serialize_structures.rb +42 -0
- data/lib/friendly_shipping/services/ship_engine_ltl/shipment_options.rb +47 -0
- data/lib/friendly_shipping/services/ship_engine_ltl/structure_options.rb +17 -0
- data/lib/friendly_shipping/services/ship_engine_ltl.rb +47 -39
- data/lib/friendly_shipping/services/tforce_freight/access_token.rb +28 -0
- data/lib/friendly_shipping/services/tforce_freight/api_error.rb +40 -0
- data/lib/friendly_shipping/services/tforce_freight/bol_options.rb +180 -0
- data/lib/friendly_shipping/services/tforce_freight/document_options.rb +100 -0
- data/lib/friendly_shipping/services/tforce_freight/generate_commodity_information.rb +92 -0
- data/lib/friendly_shipping/services/tforce_freight/generate_create_bol_request_hash.rb +153 -0
- data/lib/friendly_shipping/services/tforce_freight/generate_document_options_hash.rb +36 -0
- data/lib/friendly_shipping/services/tforce_freight/generate_handling_units_hash.rb +51 -0
- data/lib/friendly_shipping/services/tforce_freight/generate_location_hash.rb +25 -0
- data/lib/friendly_shipping/services/tforce_freight/generate_pickup_request_hash.rb +111 -0
- data/lib/friendly_shipping/services/tforce_freight/generate_rates_request_hash.rb +63 -0
- data/lib/friendly_shipping/services/tforce_freight/generate_reference_hash.rb +28 -0
- data/lib/friendly_shipping/services/tforce_freight/item_options.rb +93 -0
- data/lib/friendly_shipping/services/tforce_freight/package_options.rb +119 -0
- data/lib/friendly_shipping/services/tforce_freight/parse_create_bol_response.rb +90 -0
- data/lib/friendly_shipping/services/tforce_freight/parse_pickup_response.rb +45 -0
- data/lib/friendly_shipping/services/tforce_freight/parse_rates_response.rb +50 -0
- data/lib/friendly_shipping/services/tforce_freight/parse_shipment_document.rb +29 -0
- data/lib/friendly_shipping/services/tforce_freight/pickup_options.rb +82 -0
- data/lib/friendly_shipping/services/tforce_freight/rates_item_options.rb +10 -0
- data/lib/friendly_shipping/services/tforce_freight/rates_options.rb +159 -0
- data/lib/friendly_shipping/services/tforce_freight/rates_package_options.rb +10 -0
- data/lib/friendly_shipping/services/tforce_freight/shipment_document.rb +38 -0
- data/lib/friendly_shipping/services/tforce_freight/shipment_information.rb +104 -0
- data/lib/friendly_shipping/services/tforce_freight/shipment_options.rb +47 -0
- data/lib/friendly_shipping/services/tforce_freight/shipping_methods.rb +25 -0
- data/lib/friendly_shipping/services/tforce_freight/structure_options.rb +44 -0
- data/lib/friendly_shipping/services/tforce_freight.rb +176 -0
- data/lib/friendly_shipping/services/ups/label_item_options.rb +0 -2
- data/lib/friendly_shipping/services/ups/label_options.rb +14 -5
- data/lib/friendly_shipping/services/ups/label_package_options.rb +1 -3
- data/lib/friendly_shipping/services/ups/parse_address_validation_response.rb +1 -1
- data/lib/friendly_shipping/services/ups/parse_modifier_element.rb +29 -0
- data/lib/friendly_shipping/services/ups/parse_rate_response.rb +11 -3
- 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_time_in_transit_response.rb +1 -1
- 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 +14 -3
- 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 +10 -5
- data/lib/friendly_shipping/services/ups/serialize_shipment_accept_request.rb +1 -1
- data/lib/friendly_shipping/services/ups/serialize_shipment_confirm_request.rb +2 -4
- data/lib/friendly_shipping/services/ups/shipping_methods.rb +1 -1
- data/lib/friendly_shipping/services/ups.rb +2 -24
- data/lib/friendly_shipping/services/ups_freight/api_error.rb +8 -7
- data/lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb +65 -19
- data/lib/friendly_shipping/services/ups_freight/generate_freight_rate_request_hash.rb +2 -23
- data/lib/friendly_shipping/services/ups_freight/generate_freight_ship_request_hash.rb +1 -27
- data/lib/friendly_shipping/services/ups_freight/generate_handling_units_hash.rb +54 -0
- data/lib/friendly_shipping/services/ups_freight/label_options.rb +36 -10
- data/lib/friendly_shipping/services/ups_freight/label_structure_options.rb +13 -0
- data/lib/friendly_shipping/services/ups_freight/parse_freight_label_response.rb +2 -5
- 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 +1 -3
- data/lib/friendly_shipping/services/ups_freight/rates_item_options.rb +18 -9
- data/lib/friendly_shipping/services/ups_freight/rates_options.rb +30 -24
- data/lib/friendly_shipping/services/ups_freight/rates_package_options.rb +79 -10
- data/lib/friendly_shipping/services/ups_freight/rates_structure_options.rb +44 -0
- data/lib/friendly_shipping/services/ups_freight/shipment_information.rb +7 -3
- data/lib/friendly_shipping/services/ups_freight/shipment_options.rb +47 -0
- data/lib/friendly_shipping/services/ups_freight.rb +2 -20
- data/lib/friendly_shipping/services/ups_json/access_token.rb +20 -0
- data/lib/friendly_shipping/services/ups_json/api_error.rb +27 -0
- data/lib/friendly_shipping/services/ups_json/generate_address_classification_payload.rb +29 -0
- data/lib/friendly_shipping/services/ups_json/generate_address_hash.rb +30 -0
- 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 +208 -0
- data/lib/friendly_shipping/services/ups_json/generate_package_hash.rb +76 -0
- data/lib/friendly_shipping/services/ups_json/generate_rates_payload.rb +84 -0
- data/lib/friendly_shipping/services/ups_json/generate_timings_payload.rb +44 -0
- data/lib/friendly_shipping/services/ups_json/label.rb +20 -0
- data/lib/friendly_shipping/services/ups_json/label_billing_options.rb +41 -0
- data/lib/friendly_shipping/services/ups_json/label_item_options.rb +75 -0
- data/lib/friendly_shipping/services/ups_json/label_options.rb +174 -0
- data/lib/friendly_shipping/services/ups_json/label_package_options.rb +49 -0
- data/lib/friendly_shipping/services/ups_json/parse_address_classification_response.rb +31 -0
- 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 +51 -0
- data/lib/friendly_shipping/services/ups_json/parse_labels_response.rb +71 -0
- data/lib/friendly_shipping/services/ups_json/parse_money_hash.rb +128 -0
- data/lib/friendly_shipping/services/ups_json/parse_rate_modifier_hash.rb +28 -0
- data/lib/friendly_shipping/services/ups_json/parse_rates_response.rb +107 -0
- data/lib/friendly_shipping/services/ups_json/parse_timings_response.rb +56 -0
- data/lib/friendly_shipping/services/ups_json/parse_void_response.rb +32 -0
- data/lib/friendly_shipping/services/ups_json/rates_item_options.rb +20 -0
- data/lib/friendly_shipping/services/ups_json/rates_options.rb +111 -0
- data/lib/friendly_shipping/services/ups_json/rates_package_options.rb +17 -0
- data/lib/friendly_shipping/services/ups_json/shipping_methods.rb +111 -0
- data/lib/friendly_shipping/services/ups_json/timings_options.rb +33 -0
- data/lib/friendly_shipping/services/ups_json.rb +216 -0
- data/lib/friendly_shipping/services/usps/choose_package_rate.rb +3 -3
- data/lib/friendly_shipping/services/usps/machinable_package.rb +1 -1
- data/lib/friendly_shipping/services/usps/parse_package_rate.rb +6 -6
- data/lib/friendly_shipping/services/usps/parse_rate_response.rb +0 -4
- data/lib/friendly_shipping/services/usps/parse_time_in_transit_response.rb +6 -9
- data/lib/friendly_shipping/services/usps/parse_xml_response.rb +1 -1
- data/lib/friendly_shipping/services/usps/rate_estimate_options.rb +1 -3
- data/lib/friendly_shipping/services/usps/rate_estimate_package_options.rb +6 -3
- data/lib/friendly_shipping/services/usps/serialize_rate_request.rb +2 -4
- data/lib/friendly_shipping/services/usps/shipping_methods.rb +4 -3
- data/lib/friendly_shipping/services/usps.rb +2 -13
- data/lib/friendly_shipping/services/usps_international/parse_package_rate.rb +3 -3
- data/lib/friendly_shipping/services/usps_international/parse_rate_response.rb +0 -3
- data/lib/friendly_shipping/services/usps_international/rate_estimate_options.rb +1 -3
- 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 +1 -3
- data/lib/friendly_shipping/services/usps_international.rb +2 -6
- data/lib/friendly_shipping/services/usps_ship/access_token.rb +22 -0
- data/lib/friendly_shipping/services/usps_ship/api_error.rb +27 -0
- data/lib/friendly_shipping/services/usps_ship/machinable_package.rb +55 -0
- data/lib/friendly_shipping/services/usps_ship/parse_rate_estimates_response.rb +80 -0
- data/lib/friendly_shipping/services/usps_ship/parse_timings_response.rb +82 -0
- data/lib/friendly_shipping/services/usps_ship/rate_estimate_options.rb +45 -0
- data/lib/friendly_shipping/services/usps_ship/rate_estimate_package_options.rb +122 -0
- data/lib/friendly_shipping/services/usps_ship/serialize_rate_estimates_request.rb +53 -0
- data/lib/friendly_shipping/services/usps_ship/shipping_methods.rb +38 -0
- data/lib/friendly_shipping/services/{ship_engine_ltl/bad_request.rb → usps_ship/timing_options.rb} +2 -2
- data/lib/friendly_shipping/services/usps_ship.rb +185 -0
- data/lib/friendly_shipping/shipment_options.rb +13 -1
- data/lib/friendly_shipping/shipping_method.rb +38 -11
- data/lib/friendly_shipping/structure_options.rb +38 -0
- data/lib/friendly_shipping/timing.rb +42 -7
- data/lib/friendly_shipping/version.rb +1 -1
- data/lib/friendly_shipping.rb +20 -15
- metadata +143 -174
- data/lib/friendly_shipping/services/ship_engine/bad_request.rb +0 -29
- data/lib/friendly_shipping/services/ship_engine/bad_request_handler.rb +0 -33
- data/lib/friendly_shipping/services/ship_engine_ltl/bad_request_handler.rb +0 -33
@@ -1,17 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module FriendlyShipping
|
4
|
+
# Represents a shipping method (UPS Ground, USPS Priority, etc.) that belongs to a {Carrier}.
|
4
5
|
class ShippingMethod
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# @
|
9
|
-
|
10
|
-
|
11
|
-
# @
|
12
|
-
|
13
|
-
|
14
|
-
# @
|
6
|
+
# @return [String] the shipping method's name
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
# @return [String] the shipping method's service code
|
10
|
+
attr_reader :service_code
|
11
|
+
|
12
|
+
# @return [Carrier] this shipping method's carrier
|
13
|
+
attr_reader :carrier
|
14
|
+
|
15
|
+
# @return [Array<String>] countries this shipping method ships from
|
16
|
+
attr_reader :origin_countries
|
17
|
+
|
18
|
+
# @return [Hash] additional carrier-specific data for this shipping method
|
19
|
+
attr_reader :data
|
20
|
+
|
21
|
+
# @param name [String] the shipping method's name
|
22
|
+
# @param service_code [String] the shipping method's service code
|
23
|
+
# @param domestic [Boolean] whether this is a domestic shipping method
|
24
|
+
# @param international [Boolean] whether this is an international shipping method
|
25
|
+
# @param multi_package [Boolean] whether this is a multi-package shipping method
|
26
|
+
# @param carrier [Carrier] this shipping method's carrier
|
27
|
+
# @param origin_countries [Array] countries this shipping method ships from
|
28
|
+
# @param data [Hash] additional carrier-specific data for this shipping method
|
15
29
|
def initialize(
|
16
30
|
name: nil,
|
17
31
|
service_code: nil,
|
@@ -32,20 +46,33 @@ module FriendlyShipping
|
|
32
46
|
@data = data
|
33
47
|
end
|
34
48
|
|
49
|
+
# Returns true if this is a domestic shipping method.
|
50
|
+
# @return [Boolean]
|
35
51
|
def domestic?
|
36
52
|
!!domestic
|
37
53
|
end
|
38
54
|
|
55
|
+
# Returns true if this is an international shipping method.
|
56
|
+
# @return [Boolean]
|
39
57
|
def international?
|
40
58
|
!!international
|
41
59
|
end
|
42
60
|
|
61
|
+
# Returns true if this shipping method supports multiple packages.
|
62
|
+
# @return [Boolean]
|
43
63
|
def multi_package?
|
44
64
|
!!multi_package
|
45
65
|
end
|
46
66
|
|
47
67
|
private
|
48
68
|
|
49
|
-
|
69
|
+
# @return [Boolean]
|
70
|
+
attr_reader :domestic
|
71
|
+
|
72
|
+
# @return [Boolean]
|
73
|
+
attr_reader :international
|
74
|
+
|
75
|
+
# @return [Boolean]
|
76
|
+
attr_reader :multi_package
|
50
77
|
end
|
51
78
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FriendlyShipping
|
4
|
+
# Options for structures (pallets, skids, etc) in a shipment.
|
5
|
+
class StructureOptions
|
6
|
+
# @return [Object] unique identifier for this set of options
|
7
|
+
attr_reader :structure_id
|
8
|
+
|
9
|
+
# @param structure_id [Object] unique identifier for this set of options
|
10
|
+
# @param package_options [Array<PackageOptions>] the options for packages in this structure
|
11
|
+
# @param package_options_class [Class] the class to use for package options when none are provided
|
12
|
+
def initialize(
|
13
|
+
structure_id:,
|
14
|
+
package_options: [],
|
15
|
+
package_options_class: PackageOptions
|
16
|
+
)
|
17
|
+
@structure_id = structure_id
|
18
|
+
@package_options = package_options
|
19
|
+
@package_options_class = package_options_class
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param package [#id] the package for which to get options
|
23
|
+
# @return [PackageOptions]
|
24
|
+
def options_for_package(package)
|
25
|
+
package_options.detect do |package_option|
|
26
|
+
package_option.package_id == package.id
|
27
|
+
end || package_options_class.new(package_id: nil)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# @return [Array<PackageOptions>]
|
33
|
+
attr_reader :package_options
|
34
|
+
|
35
|
+
# @return [Class]
|
36
|
+
attr_reader :package_options_class
|
37
|
+
end
|
38
|
+
end
|
@@ -1,27 +1,62 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module FriendlyShipping
|
4
|
+
# Base class for a transit timing estimate returned by a carrier API.
|
4
5
|
class Timing
|
5
|
-
|
6
|
-
|
7
|
-
:delivery,
|
8
|
-
:guaranteed,
|
9
|
-
:properties
|
6
|
+
# @return [ShippingMethod] this timing's shipping method
|
7
|
+
attr_reader :shipping_method
|
10
8
|
|
9
|
+
# @return [Time] the pickup estimate
|
10
|
+
attr_reader :pickup
|
11
|
+
|
12
|
+
# @return [Time] the delivery estimate
|
13
|
+
attr_reader :delivery
|
14
|
+
|
15
|
+
# @return [Boolean] whether the delivery estimate is guaranteed
|
16
|
+
attr_reader :guaranteed
|
17
|
+
|
18
|
+
# @return [Array] any warnings that were generated
|
19
|
+
attr_reader :warnings
|
20
|
+
|
21
|
+
# @return [Array] any errors that were generated
|
22
|
+
attr_reader :errors
|
23
|
+
|
24
|
+
# @return [Hash] additional data related to the timing (DEPRECATED: use `data` instead)
|
25
|
+
attr_reader :properties
|
26
|
+
|
27
|
+
# @return [Hash] additional data related to the timing
|
28
|
+
attr_reader :data
|
29
|
+
|
30
|
+
# @param shipping_method [ShippingMethod] this timing's shipping method
|
31
|
+
# @param pickup [Time] the pickup estimate
|
32
|
+
# @param delivery [Time] the delivery estimate
|
33
|
+
# @param guaranteed [Boolean] whether the delivery estimate is guaranteed
|
34
|
+
# @param warnings [Array] any warnings that were generated
|
35
|
+
# @param errors [Array] any errors that were generated
|
36
|
+
# @param properties [Hash] additional data related to the timing
|
37
|
+
# @param data [Hash] additional data related to the timing (DEPRECATED: use `data` instead)
|
11
38
|
def initialize(
|
12
39
|
shipping_method:,
|
13
40
|
pickup:,
|
14
41
|
delivery:,
|
15
42
|
guaranteed: false,
|
16
|
-
|
43
|
+
warnings: [],
|
44
|
+
errors: [],
|
45
|
+
properties: {},
|
46
|
+
data: {}
|
17
47
|
)
|
18
48
|
@shipping_method = shipping_method
|
19
49
|
@pickup = pickup
|
20
50
|
@delivery = delivery
|
21
51
|
@guaranteed = guaranteed
|
22
|
-
@
|
52
|
+
@warnings = warnings
|
53
|
+
@errors = errors
|
54
|
+
@data = @properties = properties.presence || data
|
55
|
+
warn "[DEPRECATION] `properties` is deprecated. Please use `data` instead." if properties.present?
|
23
56
|
end
|
24
57
|
|
58
|
+
# Calculates and returns the time between pickup and delivery.
|
59
|
+
# @return [Time]
|
25
60
|
def time_in_transit
|
26
61
|
delivery - pickup
|
27
62
|
end
|
data/lib/friendly_shipping.rb
CHANGED
@@ -2,26 +2,31 @@
|
|
2
2
|
|
3
3
|
require "physical"
|
4
4
|
require "money"
|
5
|
+
require "dry/monads"
|
6
|
+
require "restclient"
|
5
7
|
|
6
8
|
# Explicitly configure the default rounding mode to avoid deprecation warnings
|
7
9
|
Money.rounding_mode = BigDecimal::ROUND_HALF_EVEN
|
8
10
|
|
9
|
-
require "
|
10
|
-
require "friendly_shipping/request"
|
11
|
-
require "friendly_shipping/response"
|
12
|
-
require "friendly_shipping/carrier"
|
13
|
-
require "friendly_shipping/shipping_method"
|
14
|
-
require "friendly_shipping/label"
|
15
|
-
require "friendly_shipping/rate"
|
16
|
-
require "friendly_shipping/api_result"
|
17
|
-
require "friendly_shipping/api_failure"
|
11
|
+
require "zeitwerk"
|
18
12
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
loader = Zeitwerk::Loader.for_gem
|
14
|
+
loader.inflector.inflect(
|
15
|
+
"rl" => "RL",
|
16
|
+
"parse_create_bol_response" => "ParseCreateBOLResponse",
|
17
|
+
"parse_print_bol_response" => "ParsePrintBOLResponse",
|
18
|
+
"serialize_create_bol_request" => "SerializeCreateBOLRequest",
|
19
|
+
"bol_structures_serializer" => "BOLStructuresSerializer",
|
20
|
+
"bol_packages_serializer" => "BOLPackagesSerializer",
|
21
|
+
"bol_options" => "BOLOptions",
|
22
|
+
"ship_engine_ltl" => "ShipEngineLTL",
|
23
|
+
"tforce_freight" => "TForceFreight",
|
24
|
+
"generate_create_bol_request_hash" => "GenerateCreateBOLRequestHash",
|
25
|
+
"parse_xml_response" => "ParseXMLResponse",
|
26
|
+
"usps_ship" => "USPSShip",
|
27
|
+
"shipping_methods" => "SHIPPING_METHODS"
|
28
|
+
)
|
29
|
+
loader.setup
|
25
30
|
|
26
31
|
module FriendlyShipping
|
27
32
|
end
|