Class: FriendlyShipping::Services::Ups::LabelOptions

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

Constant Summary collapse

SHIPMENT_DELIVERY_CONFIRMATION_CODES =
{
  delivery_confirmation_signature_required: 1,
  delivery_confirmation_adult_signature_required: 2
}.freeze
TERMS_OF_SHIPMENT_CODES =
{
  cost_and_freight: 'CFR',
  cost_insurance_and_freight: 'CIF',
  carriage_and_insurance_paid: 'CIP',
  carriage_paid_to: 'CPT',
  delivered_at_frontier: 'DAF',
  delivery_duty_paid: 'DDP',
  delivery_duty_unpaid: 'DDU',
  delivered_ex_quay: 'DEQ',
  delivered_ex_ship: 'DES',
  ex_works: 'EXW',
  free_alongside_ship: 'FAS',
  free_carrier: 'FCA',
  free_on_board: 'FOB'
}.freeze
RETURN_SERVICE_CODES =
{
  ups_print_and_mail: 2, # UPS Print and Mail (PNM)
  ups_return_1_attempt: 3, # UPS Return Service 1-Attempt
  ups_return_3_attempt: 5, # UPS Return Service 3-Attempt (RS3)
  ups_electronic_return_label: 8, # UPS Electronic Return Label (ERL)
  ups_print_return_label: 9, # UPS Print Return Label (PRL)
  ups_exchange_print_return: 10, # UPS Exchange Print Return Label
  ups_pack_collect_1_attemt_box_1: 11, # UPS Pack & Collect Service 1-Attempt Box 1
  ups_pack_collect_1_attemt_box_2: 12, # UPS Pack & Collect Service 1-Attempt Box 2
  ups_pack_collect_1_attemt_box_3: 13, # UPS Pack & Collect Service 1-Attempt Box 3
  ups_pack_collect_1_attemt_box_4: 14, # UPS Pack & Collect Service 1-Attempt Box 4
  ups_pack_collect_1_attemt_box_5: 15, # UPS Pack & Collect Service 1-Attempt Box 5
  ups_pack_collect_3_attemt_box_1: 16, # UPS Pack & Collect Service 1-Attempt Box 1
  ups_pack_collect_3_attemt_box_2: 17, # UPS Pack & Collect Service 1-Attempt Box 2
  ups_pack_collect_3_attemt_box_3: 18, # UPS Pack & Collect Service 1-Attempt Box 3
  ups_pack_collect_3_attemt_box_4: 19, # UPS Pack & Collect Service 1-Attempt Box 4
  ups_pack_collect_3_attemt_box_5: 20 # UPS Pack & Collect Service 1-Attempt Box 5
}.freeze
SUB_VERSIONS =
%w[1601 1607 1701 1707 1801 1807 2108 2205].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(shipping_method:, shipper_number:, shipper: nil, sub_version: '1707', customer_context: nil, validate_address: true, negotiated_rates: false, billing_options: LabelBillingOptions.new, sold_to: nil, saturday_delivery: false, label_format: 'GIF', label_size: [4, 6], delivery_confirmation: nil, carbon_neutral: true, return_service: nil, paperless_invoice: false, terms_of_shipment: nil, reason_for_export: 'SALE', invoice_date: nil, package_options_class: LabelPackageOptions, declaration_statement: nil, **kwargs) ⇒ LabelOptions

Returns a new instance of LabelOptions.

Raises:

  • (ArgumentError)


105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 105

def initialize(
  shipping_method:,
  shipper_number:,
  shipper: nil,
  sub_version: '1707',
  customer_context: nil,
  validate_address: true,
  negotiated_rates: false,
  billing_options: LabelBillingOptions.new,
  sold_to: nil,
  saturday_delivery: false,
  label_format: 'GIF',
  label_size: [4, 6],
  delivery_confirmation: nil,
  carbon_neutral: true,
  return_service: nil,
  paperless_invoice: false,
  terms_of_shipment: nil,
  reason_for_export: 'SALE',
  invoice_date: nil,
  package_options_class: LabelPackageOptions,
  declaration_statement: nil,
  **kwargs
)
  raise ArgumentError, "Invalid sub-version: #{sub_version}" unless sub_version.in?(SUB_VERSIONS)

  @shipping_method = shipping_method
  @shipper_number = shipper_number
  @shipper = shipper
  @sub_version = sub_version
  @customer_context = customer_context
  @validate_address = validate_address
  @negotiated_rates = negotiated_rates
  @billing_options = billing_options
  @sold_to = sold_to
  @saturday_delivery = saturday_delivery
  @label_format = label_format
  @label_size = label_size
  @delivery_confirmation = delivery_confirmation
  @carbon_neutral = carbon_neutral
  @return_service = return_service
  @paperless_invoice = paperless_invoice
  @terms_of_shipment = terms_of_shipment
  @reason_for_export = reason_for_export
  @invoice_date = invoice_date
  @declaration_statement = declaration_statement
  super(**kwargs.reverse_merge(package_options_class: package_options_class))
end

Instance Attribute Details

#billing_optionsObject (readonly)

Returns the value of attribute billing_options.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def billing_options
  @billing_options
end

#carbon_neutralObject (readonly)

Returns the value of attribute carbon_neutral.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def carbon_neutral
  @carbon_neutral
end

#customer_contextObject (readonly)

Returns the value of attribute customer_context.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def customer_context
  @customer_context
end

#declaration_statementObject (readonly)

Returns the value of attribute declaration_statement.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def declaration_statement
  @declaration_statement
end

#invoice_dateObject (readonly)

Returns the value of attribute invoice_date.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def invoice_date
  @invoice_date
end

#label_formatObject (readonly)

Returns the value of attribute label_format.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def label_format
  @label_format
end

#label_sizeObject (readonly)

Returns the value of attribute label_size.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def label_size
  @label_size
end

#negotiated_ratesObject (readonly)

Returns the value of attribute negotiated_rates.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def negotiated_rates
  @negotiated_rates
end

#paperless_invoiceObject (readonly)

Returns the value of attribute paperless_invoice.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def paperless_invoice
  @paperless_invoice
end

#reason_for_exportObject (readonly)

Returns the value of attribute reason_for_export.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def reason_for_export
  @reason_for_export
end

#saturday_deliveryObject (readonly)

Returns the value of attribute saturday_delivery.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def saturday_delivery
  @saturday_delivery
end

#shipperObject (readonly)

Returns the value of attribute shipper.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def shipper
  @shipper
end

#shipper_numberObject (readonly)

Returns the value of attribute shipper_number.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def shipper_number
  @shipper_number
end

#shipping_methodObject (readonly)

Returns the value of attribute shipping_method.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def shipping_method
  @shipping_method
end

#sold_toObject (readonly)

Returns the value of attribute sold_to.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def sold_to
  @sold_to
end

#sub_versionObject (readonly)

Returns the value of attribute sub_version.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def sub_version
  @sub_version
end

#validate_addressObject (readonly)

Returns the value of attribute validate_address.



87
88
89
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 87

def validate_address
  @validate_address
end

Instance Method Details

#delivery_confirmation_codeObject



154
155
156
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 154

def delivery_confirmation_code
  SHIPMENT_DELIVERY_CONFIRMATION_CODES[delivery_confirmation]
end

#return_service_codeObject



162
163
164
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 162

def return_service_code
  RETURN_SERVICE_CODES[return_service]
end

#terms_of_shipment_codeObject



158
159
160
# File 'lib/friendly_shipping/services/ups/label_options.rb', line 158

def terms_of_shipment_code
  TERMS_OF_SHIPMENT_CODES[terms_of_shipment]
end