Sha256: be3a203ce7ec11198385c8bef3e97c0a38048aa715b69eb8a04448908fa072af

Contents?: true

Size: 1.69 KB

Versions: 21

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require 'friendly_shipping/services/ups/label_item_options'

module FriendlyShipping
  module Services
    class Ups
      # Package properties relevant for generating a UPS shipping label
      #
      # @option reference_numbers [Hash] a Hash where keys are _reference number codes_ and
      #   values are _reference number values_. Example: `{ reference_numbers: { xn: 'my_reference_1 }`
      # @option delivery_confirmation [Symbol] Can be set to any key from PACKAGE_DELIVERY_CONFIRMATION_CODES.
      #   Only possible for domestic shipments or shipments between the US and Puerto Rico.
      # @option shipper_release [Boolean] Indicates that the package may be released by driver without a signature from the
      #   consignee. Default: false
      class LabelPackageOptions < FriendlyShipping::PackageOptions
        PACKAGE_DELIVERY_CONFIRMATION_CODES = {
          delivery_confirmation: 1,
          delivery_confirmation_signature_required: 2,
          delivery_confirmation_adult_signature_required: 3
        }.freeze

        attr_reader :reference_numbers, :shipper_release

        def initialize(
          reference_numbers: {},
          delivery_confirmation: nil,
          shipper_release: false,
          **kwargs
        )
          @reference_numbers = reference_numbers
          @delivery_confirmation = delivery_confirmation
          @shipper_release = shipper_release
          super(**kwargs.merge(item_options_class: LabelItemOptions))
        end

        def delivery_confirmation_code
          PACKAGE_DELIVERY_CONFIRMATION_CODES[delivery_confirmation]
        end

        private

        attr_reader :delivery_confirmation
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
friendly_shipping-0.8.0 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.7.3 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.7.2 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.7.1 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.7.0 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.6.5 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.6.4 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.6.3 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.6.2 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.6.1 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.6.0 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.5.3 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.5.2 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.5.1 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.5 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.4.14 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.4.13 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.4.12 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.4.11 lib/friendly_shipping/services/ups/label_package_options.rb
friendly_shipping-0.4.10 lib/friendly_shipping/services/ups/label_package_options.rb