friendly_shipping 0.3.4 → 0.4.0

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.env.template +1 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +13 -4
  5. data/Gemfile +1 -0
  6. data/README.md +21 -2
  7. data/friendly_shipping.gemspec +1 -1
  8. data/lib/friendly_shipping/api_failure.rb +3 -0
  9. data/lib/friendly_shipping/api_result.rb +3 -0
  10. data/lib/friendly_shipping/carrier.rb +6 -0
  11. data/lib/friendly_shipping/http_client.rb +1 -0
  12. data/lib/friendly_shipping/item_options.rb +11 -0
  13. data/lib/friendly_shipping/label.rb +17 -9
  14. data/lib/friendly_shipping/package_options.rb +28 -0
  15. data/lib/friendly_shipping/rate.rb +9 -8
  16. data/lib/friendly_shipping/request.rb +4 -0
  17. data/lib/friendly_shipping/response.rb +3 -0
  18. data/lib/friendly_shipping/services/ship_engine.rb +10 -11
  19. data/lib/friendly_shipping/services/ship_engine/label_options.rb +34 -0
  20. data/lib/friendly_shipping/services/ship_engine/label_package_options.rb +28 -0
  21. data/lib/friendly_shipping/services/ship_engine/parse_label_response.rb +6 -1
  22. data/lib/friendly_shipping/services/ship_engine/parse_rate_estimate_response.rb +7 -7
  23. data/lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb +25 -0
  24. data/lib/friendly_shipping/services/ship_engine/serialize_label_shipment.rb +15 -14
  25. data/lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb +2 -2
  26. data/lib/friendly_shipping/services/ups.rb +47 -2
  27. data/lib/friendly_shipping/services/ups/label_billing_options.rb +41 -0
  28. data/lib/friendly_shipping/services/ups/label_item_options.rb +74 -0
  29. data/lib/friendly_shipping/services/ups/label_options.rb +165 -0
  30. data/lib/friendly_shipping/services/ups/label_package_options.rb +43 -0
  31. data/lib/friendly_shipping/services/ups/parse_money_element.rb +128 -0
  32. data/lib/friendly_shipping/services/ups/parse_rate_response.rb +8 -7
  33. data/lib/friendly_shipping/services/ups/parse_shipment_accept_response.rb +75 -0
  34. data/lib/friendly_shipping/services/ups/parse_shipment_confirm_response.rb +22 -0
  35. data/lib/friendly_shipping/services/ups/parse_xml_response.rb +2 -1
  36. data/lib/friendly_shipping/services/ups/serialize_address_snippet.rb +11 -6
  37. data/lib/friendly_shipping/services/ups/serialize_package_node.rb +21 -6
  38. data/lib/friendly_shipping/services/ups/serialize_shipment_accept_request.rb +27 -0
  39. data/lib/friendly_shipping/services/ups/serialize_shipment_address_snippet.rb +21 -0
  40. data/lib/friendly_shipping/services/ups/serialize_shipment_confirm_request.rb +282 -0
  41. data/lib/friendly_shipping/services/ups_freight.rb +76 -0
  42. data/lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb +33 -0
  43. data/lib/friendly_shipping/services/ups_freight/generate_freight_rate_request_hash.rb +72 -0
  44. data/lib/friendly_shipping/services/ups_freight/generate_location_hash.rb +39 -0
  45. data/lib/friendly_shipping/services/ups_freight/generate_ups_security_hash.rb +23 -0
  46. data/lib/friendly_shipping/services/ups_freight/parse_freight_rate_response.rb +53 -0
  47. data/lib/friendly_shipping/services/ups_freight/parse_json_response.rb +38 -0
  48. data/lib/friendly_shipping/services/ups_freight/rates_item_options.rb +72 -0
  49. data/lib/friendly_shipping/services/ups_freight/rates_options.rb +54 -0
  50. data/lib/friendly_shipping/services/ups_freight/rates_package_options.rb +38 -0
  51. data/lib/friendly_shipping/services/ups_freight/shipping_methods.rb +25 -0
  52. data/lib/friendly_shipping/services/usps.rb +1 -1
  53. data/lib/friendly_shipping/services/usps/parse_xml_response.rb +1 -1
  54. data/lib/friendly_shipping/services/usps/serialize_rate_request.rb +0 -4
  55. data/lib/friendly_shipping/shipment_options.rb +23 -0
  56. data/lib/friendly_shipping/shipping_method.rb +7 -0
  57. data/lib/friendly_shipping/version.rb +1 -1
  58. metadata +33 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fae2b417bddc3fd2cc6cb4a6c07212e8efb3c65
4
- data.tar.gz: 674d279b79b45e5f72d116a64b83c1215192f805
3
+ metadata.gz: 14d1848557e65a7773aaa0683b4af131c2784181
4
+ data.tar.gz: 1d63935b99e3e09cfec828663ab53956224a67e2
5
5
  SHA512:
6
- metadata.gz: bdf22d97688944e2cd7d0c68ee896e3c41ab15abe27129398cd257dbd89b8dfa601e11f7fb44e5de330d57660580fec577f7ac74acb8f35984c9ce399e4d4fa7
7
- data.tar.gz: 52ce6aedde1900838fda5e9d16feffd5a4c911de78fbed324485f20f2d9c906ecda6f1c6a03037292e1a0a625307fab8b5750fe2b9dea3273a82591f5da6a225
6
+ metadata.gz: 7d894f9c105b238dcbfed6d94246e5206274e29d5fbbec6a82d1cc783a01538c8a0465e321a720ccaeeb9662d2e36d2d6d84b7087b714d44b5249a2f555bfa6e
7
+ data.tar.gz: 9d8b29758884d37bb4fb8eca4aee2f7c58c797115972807fce68d9c9b7cb43608f3cdf4e07ec504ed8f04b8cec377686169c79b611e38bfb99d28964bd096a55
@@ -3,6 +3,7 @@
3
3
  # Only pass along how those passwords/info are reference via ENV VARS
4
4
 
5
5
  SHIPENGINE_API_KEY=Ship Engine API key
6
+ SHIPENGINE_CARRIER_ID=Carrier ID from your ShipEngine account to run test labels with
6
7
 
7
8
  UPS_KEY=UPS API access key
8
9
  UPS_LOGIN=UPS login name
data/.gitignore CHANGED
@@ -17,3 +17,4 @@
17
17
  # Gemfile.lock
18
18
  Gemfile.lock
19
19
  .env
20
+ coverage
@@ -4,22 +4,31 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [0.3.4] - 2017-10-28
7
+ ## [0.4.0] - 2019-11-11
8
+
9
+ ### Added
10
+ - UPS Freight Service (rates estimation only for now)
11
+ - UPS: Label generation
12
+
13
+ ### Changed
14
+
15
+ - All API methods now take a shipment, sometimes a typed Options object, and a `debug` flag.
16
+ - There are option classes for shipments, packages, and items. See the spec for UPS Freight about how they work.
8
17
 
9
18
  ### Changed
10
19
  - Add ConsigneeName to Address validation/classification request
11
20
 
12
- ## [0.3.3] - 2017-10-25
21
+ ## [0.3.3] - 2019-10-25
13
22
 
14
23
  ### Changed
15
24
  - Fix: ShipEngine#labels test mode works again.
16
25
 
17
- ## [0.3.2] - 2017-10-25
26
+ ## [0.3.2] - 2019-10-25
18
27
 
19
28
  ### Changed
20
29
  - Fix: ShipEngine#labels now works as expected.
21
30
 
22
- ## [0.3.1] - 2017-06-20
31
+ ## [0.3.1] - 2019-06-20
23
32
  ### Added
24
33
  - Endpoint for UPS address classification
25
34
 
data/Gemfile CHANGED
@@ -12,5 +12,6 @@ gem 'factory_bot'
12
12
  gem 'pry'
13
13
  gem 'rspec_junit_formatter'
14
14
  gem 'rubocop'
15
+ gem 'simplecov', require: false
15
16
  gem 'vcr'
16
17
  gem 'webmock'
data/README.md CHANGED
@@ -25,6 +25,7 @@ The entry point for using FriendlyShipping are the `service` objects that each r
25
25
  1. `FriendlyShipping::Services::Ups`
26
26
  2. `FriendlyShipping::Services::Usps`
27
27
  3. `FriendlyShipping::Services::ShipEngine`
28
+ 4. `FriendlyShipping::Services::UpsFreight`
28
29
 
29
30
  The services are instantiated with the credentials they need as well as a `test` flag to indicate whether to use their respective `sandbox` environments.
30
31
 
@@ -47,8 +48,8 @@ service = FriendlyShipping::Services::ShipEngine.new(token: ENV['SHIPENGINE_TOKE
47
48
  The following methods are supported:
48
49
 
49
50
  - `#carriers` - List all configured carriers
50
- - `#rate_estimates(physical_shipment, carriers: [friendly_shipping_carrier])` - Get rate estimates for a shipment
51
- - `#labels(physical_shipment, shipping_method:)` - Get labels for a shipments. Currently only supports USPS labels, other services are untested.
51
+ - `#rate_estimates(physical_shipment, options: options)` - Get rate estimates for a shipment
52
+ - `#labels(physical_shipment, options: options)` - Get labels for a shipments. Currently only supports USPS labels, other services are untested.
52
53
  - `#void(physical_label)` - Void a label and get the cost refunded
53
54
 
54
55
  #### UPS (United Parcel Service)
@@ -68,6 +69,7 @@ The following methods are supported:
68
69
 
69
70
  - `#carriers` - List all configured carriers (always returns UPS)
70
71
  - `#rate_estimates(physical_shipment)` - Get rate estimates for a shipment
72
+ - `#labels(physical_shipment, options: options)` - Get labels for a shipment
71
73
  - `#address_classification(physical_location)` - Determine whether an address is commercial or residential.
72
74
  - `#address_validation(physical_location)` - Perform a detailed address validation and determine whether an address is commercial or residential.
73
75
  - `#city_state_lookup(physical_location)` - Lookup City and State for a given ZIP code.
@@ -90,6 +92,23 @@ The following methods are supported:
90
92
  - `#address_validation(physical_location)` - Perform a detailed address validation and determine whether an address is commercial or residential.
91
93
  - `#city_state_lookup(physical_location)` - Lookup City and State for a given ZIP code.
92
94
 
95
+ #### UPS Freight
96
+
97
+ The service class for UPS is `FriendlyShipping::Services::UpsFreight`. It functions quite differently from normal, package-level shipping. Initialize like so:
98
+
99
+ ```rb
100
+ service = FriendlyShipping::Services::UpsFreight.new(
101
+ key: ENV['UPS_API_KEY'],
102
+ login: ENV['UPS_API_LOGIN'],
103
+ password: ENV['UPS_API_PASSWORD'],
104
+ test: true
105
+ )
106
+ ```
107
+
108
+ The following methods are supported:
109
+
110
+ - `#rate_estimates(physical_shipment, options: options)` - Get rate estimates for a shipment
111
+
93
112
  ## Development
94
113
 
95
114
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency "dry-monads", "~> 1.0"
27
27
  spec.add_runtime_dependency "money", ">= 6.0.0"
28
28
  spec.add_runtime_dependency "nokogiri", ">= 1.6"
29
- spec.add_runtime_dependency "physical", "~> 0.4"
29
+ spec.add_runtime_dependency "physical", ">= 0.4.4"
30
30
  spec.add_runtime_dependency "rest-client", "~> 2.0"
31
31
  spec.required_ruby_version = '>= 2.4'
32
32
 
@@ -4,6 +4,9 @@ module FriendlyShipping
4
4
  class ApiFailure
5
5
  attr_reader :failure, :original_request, :original_response
6
6
 
7
+ # @param [Object] failure The API failure
8
+ # @param [FriendlyShipping::Request] original_request The HTTP request (when debugging is enabled)
9
+ # @param [FriendlyShipping::Response] original_response The HTTP response (when debugging is enabled)
7
10
  def initialize(failure, original_request:, original_response:)
8
11
  @failure = failure
9
12
 
@@ -4,6 +4,9 @@ module FriendlyShipping
4
4
  class ApiResult
5
5
  attr_reader :data, :original_request, :original_response
6
6
 
7
+ # @param [Object] data The API result
8
+ # @param [FriendlyShipping::Request] original_request The HTTP request (when debugging is enabled)
9
+ # @param [FriendlyShipping::Response] original_response The HTTP response (when debugging is enabled)
7
10
  def initialize(data, original_request: nil, original_response: nil)
8
11
  @data = data
9
12
 
@@ -4,6 +4,12 @@ module FriendlyShipping
4
4
  class Carrier
5
5
  attr_reader :id, :name, :code, :shipping_methods, :balance, :data
6
6
 
7
+ # @param [Integer] id The carrier's ID
8
+ # @param [String] name The carrier's name
9
+ # @param [String] code The carrier's unique code
10
+ # @param [Array] shipping_methods The shipping methods available on this carrier
11
+ # @param [Float] balance The remaining balance for this carrier
12
+ # @param [Hash] data Additional data related to this carrier
7
13
  def initialize(id: nil, name: nil, code: nil, shipping_methods: [], balance: nil, data: {})
8
14
  @id = id
9
15
  @name = name
@@ -9,6 +9,7 @@ module FriendlyShipping
9
9
 
10
10
  attr_reader :error_handler
11
11
 
12
+ # @param [Proc] error_handler Called to handle an error if one occurs
12
13
  def initialize(error_handler: method(:wrap_in_failure))
13
14
  @error_handler = error_handler
14
15
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FriendlyShipping
4
+ class ItemOptions
5
+ attr_reader :item_id
6
+
7
+ def initialize(item_id:)
8
+ @item_id = item_id
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'friendly_shipping/types'
4
+
3
5
  module FriendlyShipping
4
6
  class Label
5
7
  attr_reader :id,
@@ -9,11 +11,19 @@ module FriendlyShipping
9
11
  :label_href,
10
12
  :data,
11
13
  :label_format,
14
+ :cost,
12
15
  :shipment_cost,
13
- :label_data,
14
- :original_request,
15
- :original_response
16
+ :label_data
16
17
 
18
+ # @param [Integer] id The label's ID
19
+ # @param [Integer] shipment_id The label's shipment ID
20
+ # @param [String] tracking_number The label's tracking number
21
+ # @param [String] service_code The label's service code
22
+ # @param [String] label_href The URL for the label
23
+ # @param [String] label_format The label's format
24
+ # @param [String] label_data The raw label data
25
+ # @param [Float] shipment_cost The cost of the shipment
26
+ # @param [Hash] data Additional data related to the label
17
27
  def initialize(
18
28
  id: nil,
19
29
  shipment_id: nil,
@@ -22,10 +32,9 @@ module FriendlyShipping
22
32
  label_href: nil,
23
33
  label_format: nil,
24
34
  label_data: nil,
35
+ cost: nil,
25
36
  shipment_cost: nil,
26
- data: {},
27
- original_request: nil,
28
- original_response: nil
37
+ data: {}
29
38
  )
30
39
  @id = id
31
40
  @shipment_id = shipment_id
@@ -33,11 +42,10 @@ module FriendlyShipping
33
42
  @service_code = service_code
34
43
  @label_href = label_href
35
44
  @label_format = label_format
36
- @shipment_cost = shipment_cost
45
+ @cost = FriendlyShipping::Types::Money.optional[cost]
46
+ @shipment_cost = FriendlyShipping::Types::Money.optional[shipment_cost]
37
47
  @label_data = label_data
38
48
  @data = data
39
- @original_request = original_request
40
- @original_response = original_response
41
49
  end
42
50
  end
43
51
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FriendlyShipping
4
+ class PackageOptions
5
+ attr_reader :package_id
6
+
7
+ def initialize(
8
+ package_id:,
9
+ item_options: Set.new,
10
+ item_options_class: ItemOptions
11
+ )
12
+ @package_id = package_id
13
+ @item_options = item_options
14
+ @item_options_class = item_options_class
15
+ end
16
+
17
+ def options_for_item(item)
18
+ item_options.detect do |item_option|
19
+ item_option.item_id == item.id
20
+ end || item_options_class.new(item_id: nil)
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :item_options,
26
+ :item_options_class
27
+ end
28
+ end
@@ -9,10 +9,15 @@ module FriendlyShipping
9
9
  :delivery_date,
10
10
  :warnings,
11
11
  :errors,
12
- :data,
13
- :original_request,
14
- :original_response
12
+ :data
15
13
 
14
+ # @param [FriendlyShipping::ShippingMethod] shipping_method The rate's shipping method
15
+ # @param [Hash] amounts The amounts (as Money objects) that make up the rate
16
+ # @param [Integer] remote_service_id The remote service ID for the rate
17
+ # @param [Time] delivery_date The delivery date for the rate
18
+ # @param [Array] warnings Any warnings that were generated
19
+ # @param [Array] errors Any errors that were generated
20
+ # @param [Hash] data Additional data related to the rate
16
21
  def initialize(
17
22
  shipping_method:,
18
23
  amounts:,
@@ -20,9 +25,7 @@ module FriendlyShipping
20
25
  delivery_date: nil,
21
26
  warnings: [],
22
27
  errors: [],
23
- data: {},
24
- original_request: nil,
25
- original_response: nil
28
+ data: {}
26
29
  )
27
30
  @remote_service_id = remote_service_id
28
31
  @shipping_method = shipping_method
@@ -31,8 +34,6 @@ module FriendlyShipping
31
34
  @warnings = warnings
32
35
  @errors = errors
33
36
  @data = data
34
- @original_request = original_request
35
- @original_response = original_response
36
37
  end
37
38
 
38
39
  def total_amount
@@ -4,6 +4,10 @@ module FriendlyShipping
4
4
  class Request
5
5
  attr_reader :url, :body, :headers, :debug
6
6
 
7
+ # @param [String] url The HTTP request URL
8
+ # @param [String] body The HTTP request body
9
+ # @param [Hash] headers The HTTP request headers
10
+ # @param [Boolean] debug Whether to debug the request
7
11
  def initialize(url:, body: nil, headers: {}, debug: false)
8
12
  @url = url
9
13
  @body = body
@@ -4,6 +4,9 @@ module FriendlyShipping
4
4
  class Response
5
5
  attr_reader :status, :body, :headers
6
6
 
7
+ # @param [Integer] status The HTTP response status code
8
+ # @param [String] body The HTTP response body
9
+ # @param [Hash] headers The HTTP response headers
7
10
  def initialize(status:, body:, headers:)
8
11
  @status = status
9
12
  @body = body
@@ -9,6 +9,9 @@ require 'friendly_shipping/services/ship_engine/serialize_rate_estimate_request'
9
9
  require 'friendly_shipping/services/ship_engine/parse_label_response'
10
10
  require 'friendly_shipping/services/ship_engine/parse_void_response'
11
11
  require 'friendly_shipping/services/ship_engine/parse_rate_estimate_response'
12
+ require 'friendly_shipping/services/ship_engine/rate_estimates_options'
13
+ require 'friendly_shipping/services/ship_engine/label_options'
14
+ require 'friendly_shipping/services/ship_engine/label_package_options'
12
15
 
13
16
  module FriendlyShipping
14
17
  module Services
@@ -43,22 +46,20 @@ module FriendlyShipping
43
46
  #
44
47
  # @param [Physical::Shipment] shipment The shipment object we're trying to get results for
45
48
  #
46
- # @options[:carriers] [Physical::Carrier] The carriers we want to get rates from. What counts
47
- # here is the carrier code, so by specifying them upfront you can save a request.
49
+ # @options [FriendlyShipping::Services::ShipEngine::RateEstimatesOptions] The options relevant to estimating rates. See object description.
48
50
  #
49
51
  # @return [Result<ApiResult<Array<FriendlyShipping::Rate>>>] When successfully parsing, an array of rates in a Success Monad.
50
52
  # When the parsing is not successful or ShipEngine can't give us rates, a Failure monad containing something that
51
53
  # can be serialized into an error message using `to_s`.
52
- def rate_estimates(shipment, selected_carriers: nil, debug: false)
53
- selected_carriers ||= carriers.value!.data
54
+ def rate_estimates(shipment, options: FriendlyShipping::Services::ShipEngine::RateEstimatesOptions.new, debug: false)
54
55
  request = FriendlyShipping::Request.new(
55
56
  url: API_BASE + 'rates/estimate',
56
- body: SerializeRateEstimateRequest.call(shipment: shipment, carriers: selected_carriers).to_json,
57
+ body: SerializeRateEstimateRequest.call(shipment: shipment, options: options).to_json,
57
58
  headers: request_headers,
58
59
  debug: debug
59
60
  )
60
61
  client.post(request).bind do |response|
61
- ParseRateEstimateResponse.call(response: response, request: request, carriers: selected_carriers)
62
+ ParseRateEstimateResponse.call(response: response, request: request, options: options)
62
63
  end
63
64
  end
64
65
 
@@ -67,16 +68,14 @@ module FriendlyShipping
67
68
  # @param [Physical::Shipment] shipment The shipment object we're trying to get labels for
68
69
  # Note: Some ShipEngine carriers, notably USPS, only support one package per shipment, and that's
69
70
  # all that the integration supports at this point.
70
- # @param [FriendlyShipping::ShippingMethod] shipping_method The shipping method we want to use.
71
- # Specifically, the "#service_code" will be serialized. If a carrier is set, it's `#id` will
72
- # also be sent to ShipEngine.
71
+ # @param [FriendlyShipping::Services::ShipEngine::LabelOptions] The options relevant to estimating rates. See object description.
73
72
  #
74
73
  # @return [Result<ApiResult<Array<FriendlyShipping::Label>>>] The label returned.
75
74
  #
76
- def labels(shipment, shipping_method:)
75
+ def labels(shipment, options:)
77
76
  request = FriendlyShipping::Request.new(
78
77
  url: API_BASE + API_PATHS[:labels],
79
- body: SerializeLabelShipment.call(shipment: shipment, shipping_method: shipping_method, test: test).to_json,
78
+ body: SerializeLabelShipment.call(shipment: shipment, options: options, test: test).to_json,
80
79
  headers: request_headers
81
80
  )
82
81
  client.post(request).fmap do |response|
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'friendly_shipping/shipment_options'
4
+
5
+ module FriendlyShipping
6
+ module Services
7
+ class ShipEngine
8
+ # Options for generating ShipEngine labels
9
+ #
10
+ # @attribute label_format [Symbol] The format for the label. Possible Values: :png, :zpl and :pdf. Default :pdf
11
+ # @attribute label_download_type [Symbol] Whether to download directly (`:inline`) or
12
+ # obtain a URL to the label (`:url`). Default :url
13
+ # @attribute package_options [Enumberable<LabelPackageOptions>] Package options for the packages in the shipment
14
+ #
15
+ class LabelOptions < FriendlyShipping::ShipmentOptions
16
+ attr_reader :shipping_method,
17
+ :label_format,
18
+ :label_download_type
19
+
20
+ def initialize(
21
+ shipping_method:,
22
+ label_format: :pdf,
23
+ label_download_type: :url,
24
+ **kwargs
25
+ )
26
+ @shipping_method = shipping_method
27
+ @label_format = label_format
28
+ @label_download_type = label_download_type
29
+ super kwargs.merge(package_options_class: LabelPackageOptions)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'friendly_shipping/package_options'
4
+
5
+ module FriendlyShipping
6
+ module Services
7
+ class ShipEngine
8
+ # Options relating to packages in the ShipEngine labels call
9
+ #
10
+ # @attribute :package_code [Symbol] The type of package. Possible types can be gotten
11
+ # via the ShipEngine API: https://www.shipengine.com/docs/reference/list-carrier-packages/
12
+ # If a package type is given, no dimensions will be added to the call (as we can assume the
13
+ # carrier knows the dimensions of their packaging types).
14
+ # @attribute messages [Array<String>] A list of messages to add to the label. No carrier accepts
15
+ # more than three messages, and some have restrictions on how many characters are possible.
16
+ # We're not validating here though.
17
+ class LabelPackageOptions < FriendlyShipping::PackageOptions
18
+ attr_reader :package_code, :messages
19
+
20
+ def initialize(package_code: nil, messages: [], **kwargs)
21
+ @package_code = package_code
22
+ @messages = messages
23
+ super kwargs
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end