Class: FriendlyShipping::Services::ShipEngine::LabelPackageOptions

Inherits:
PackageOptions
  • Object
show all
Defined in:
lib/friendly_shipping/services/ship_engine/label_package_options.rb

Overview

Package options for generating shipping labels.

Instance Attribute Summary collapse

Attributes inherited from PackageOptions

#package_id

Instance Method Summary collapse

Methods inherited from PackageOptions

#options_for_item

Constructor Details

#initialize(package_code: nil, messages: [], **kwargs) ⇒ LabelPackageOptions

Returns a new instance of LabelPackageOptions.

Parameters:

  • package_code (Symbol) (defaults to: nil)

    The type of package. Possible types can be gotten via the ShipEngine API: https://www.shipengine.com/docs/reference/list-carrier-packages/ If a package type is given, no dimensions will be added to the call (as we can assume the carrier knows the dimensions of their packaging types).

  • messages (Array<String>) (defaults to: [])

    A list of messages to add to the label. No carrier accepts more than three messages, and some have restrictions on how many characters are possible. We're not validating here though.

  • kwargs (Hash)

Options Hash (**kwargs):

  • :package_id (String)

    the ID for the package that belongs to these options

  • :item_options (Array<ItemOptions>)

    the options for items in this package

  • :item_options_class (Class)

    the class to use for item options when none are provided



25
26
27
28
29
# File 'lib/friendly_shipping/services/ship_engine/label_package_options.rb', line 25

def initialize(package_code: nil, messages: [], **kwargs)
  @package_code = package_code
  @messages = messages
  super(**kwargs.reverse_merge(item_options_class: LabelItemOptions))
end

Instance Attribute Details

#messagesArray<String> (readonly)

Returns a list of messages to add to the label.

Returns:

  • (Array<String>)

    a list of messages to add to the label



12
13
14
# File 'lib/friendly_shipping/services/ship_engine/label_package_options.rb', line 12

def messages
  @messages
end

#package_codeSymbol (readonly)

Returns the type of package.

Returns:

  • (Symbol)

    the type of package



9
10
11
# File 'lib/friendly_shipping/services/ship_engine/label_package_options.rb', line 9

def package_code
  @package_code
end