Class: UspsApi::InternationalLabelsPackageOptions

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/international_labels_package_options.rb

Overview

Additional options for package shipments including package value and non-delivery preferences.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(package_value: SKIP, non_delivery_option: SKIP, additional_properties: nil) ⇒ InternationalLabelsPackageOptions

Returns a new instance of InternationalLabelsPackageOptions.



46
47
48
49
50
51
52
53
54
# File 'lib/usps_api/models/international_labels_package_options.rb', line 46

def initialize(package_value: SKIP, non_delivery_option: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @package_value = package_value unless package_value == SKIP
  @non_delivery_option = non_delivery_option unless non_delivery_option == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#non_delivery_optionNonDeliveryOption

Requested action in the case a package is undeliverable: * RETURN for the package to be returned to ‘fromAddress`. * REDIRECT to return the package to address specified in the `redirectAddress`. * ABANDON to dispose of the undeliverable package

Returns:



23
24
25
# File 'lib/usps_api/models/international_labels_package_options.rb', line 23

def non_delivery_option
  @non_delivery_option
end

#package_valueFloat

The merchandise value of the package, in US dollars. Used to calculate Insurance Fees if requested.

Returns:

  • (Float)


16
17
18
# File 'lib/usps_api/models/international_labels_package_options.rb', line 16

def package_value
  @package_value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/usps_api/models/international_labels_package_options.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  package_value = hash.key?('packageValue') ? hash['packageValue'] : SKIP
  non_delivery_option =
    hash.key?('nonDeliveryOption') ? hash['nonDeliveryOption'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  InternationalLabelsPackageOptions.new(package_value: package_value,
                                        non_delivery_option: non_delivery_option,
                                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
# File 'lib/usps_api/models/international_labels_package_options.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['package_value'] = 'packageValue'
  @_hash['non_delivery_option'] = 'nonDeliveryOption'
  @_hash
end

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/usps_api/models/international_labels_package_options.rb', line 42

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
# File 'lib/usps_api/models/international_labels_package_options.rb', line 34

def self.optionals
  %w[
    package_value
    non_delivery_option
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



86
87
88
89
90
# File 'lib/usps_api/models/international_labels_package_options.rb', line 86

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} package_value: #{@package_value.inspect}, non_delivery_option:"\
  " #{@non_delivery_option.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



79
80
81
82
83
# File 'lib/usps_api/models/international_labels_package_options.rb', line 79

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} package_value: #{@package_value}, non_delivery_option:"\
  " #{@non_delivery_option}, additional_properties: #{@additional_properties}>"
end