Class: FriendlyShipping::Services::ShipEngine::LabelOptions

Inherits:
FriendlyShipping::ShipmentOptions show all
Defined in:
lib/friendly_shipping/services/ship_engine/label_options.rb

Overview

Options for generating shipping labels.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(shipping_method:, label_download_type: :url, label_format: :pdf, label_image_id: nil, customs_options: LabelCustomsOptions.new, customs_items_serializer: CustomsItemsSerializer, **kwargs) ⇒ LabelOptions

Returns a new instance of LabelOptions.

Parameters:

  • shipping_method (ShippingMethod)

    the label's shipping method

  • label_download_type (Symbol) (defaults to: :url)

    whether to download directly (:inline) or obtain a URL to the label (:url). Default :url

  • label_format (Symbol) (defaults to: :pdf)

    the format for the label. Possible Values: :png, :zpl and :pdf. Default :pdf

  • label_image_id (String) (defaults to: nil)

    identifier for image uploaded to ShipEngine. Default: nil

  • customs_options (LabelCustomsOptions) (defaults to: LabelCustomsOptions.new)

    customs options for obtaining international shipment labels

  • customs_items_serializer (Proc, #call) (defaults to: CustomsItemsSerializer)

    a callable that takes packages and an options object to create the customs items array for the shipment

  • kwargs (Hash)

Options Hash (**kwargs):

  • :package_options (Array<LabelPackageOptions>)

    package options for the packages in the shipment

  • :package_options_class (Class)

    the class to use for package options when none are provided



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/friendly_shipping/services/ship_engine/label_options.rb', line 35

def initialize(
  shipping_method:,
  label_download_type: :url,
  label_format: :pdf,
  label_image_id: nil,
  customs_options: LabelCustomsOptions.new,
  customs_items_serializer: CustomsItemsSerializer,
  **kwargs
)
  @shipping_method = shipping_method
  @label_download_type = label_download_type
  @label_format = label_format
  @label_image_id = label_image_id
  @customs_options = customs_options
  @customs_items_serializer = customs_items_serializer
  super(**kwargs.reverse_merge(package_options_class: LabelPackageOptions))
end

Instance Attribute Details

#customs_items_serializerProc, #call (readonly)

Returns a callable that takes packages and an options object to create the customs items array for the shipment.

Returns:

  • (Proc, #call)

    a callable that takes packages and an options object to create the customs items array for the shipment



24
25
26
# File 'lib/friendly_shipping/services/ship_engine/label_options.rb', line 24

def customs_items_serializer
  @customs_items_serializer
end

#customs_optionsLabelCustomsOptions (readonly)

Returns customs options for international shipment labels.

Returns:



21
22
23
# File 'lib/friendly_shipping/services/ship_engine/label_options.rb', line 21

def customs_options
  @customs_options
end

#label_download_typeSymbol (readonly)

Returns whether to download directly or obtain a URL to the label.

Returns:

  • (Symbol)

    whether to download directly or obtain a URL to the label



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

def label_download_type
  @label_download_type
end

#label_formatSymbol (readonly)

Returns the format for the label.

Returns:

  • (Symbol)

    the format for the label



15
16
17
# File 'lib/friendly_shipping/services/ship_engine/label_options.rb', line 15

def label_format
  @label_format
end

#label_image_idString (readonly)

Returns identifier for image uploaded to ShipEngine.

Returns:

  • (String)

    identifier for image uploaded to ShipEngine



18
19
20
# File 'lib/friendly_shipping/services/ship_engine/label_options.rb', line 18

def label_image_id
  @label_image_id
end

#shipping_methodShippingMethod (readonly)

Returns the label's shipping method.

Returns:



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

def shipping_method
  @shipping_method
end