Class: UspsApi::LabelsPackageOptions2

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

Overview

LabelsPackageOptions2 Model.

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, omas: SKIP, additional_properties: nil) ⇒ LabelsPackageOptions2

Returns a new instance of LabelsPackageOptions2.



63
64
65
66
67
68
69
70
71
72
# File 'lib/usps_api/models/labels_package_options2.rb', line 63

def initialize(package_value: SKIP, non_delivery_option: SKIP, omas: 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
  @omas = omas unless omas == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#non_delivery_optionNonDeliveryOption

Requested action in the case a package is undeliverable:

- `RETURN` for package to be returned to `fromAddress`.
- `REDIRECT` to return package to address specified in the

‘redirectAddress`.

- `ABANDON` to dispose of undeliverable package

Note:

* `REDIRECT` and `ABANDON` will not impact the domestic package

endpoint. Please use ancillary service endorsements instead.

* An address must be provided in `redirectAddress` when a value of

‘REDIRECT` is provided.

Returns:



33
34
35
# File 'lib/usps_api/models/labels_package_options2.rb', line 33

def non_delivery_option
  @non_delivery_option
end

#omasOmas

Fields specific to Official Mail Accounting System (OMAS). Used for Federal Agencies.

Returns:



38
39
40
# File 'lib/usps_api/models/labels_package_options2.rb', line 38

def omas
  @omas
end

#package_valueFloat

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

* Requires extraServiceCode 910, 911, 912, 913, 921, 922, 923, 924, 925,

934, 955, 981 or extraServiceCode 930 with a packageValue greater than 500

* Package value is required when an 'extraServiceCode' value of '930' is

provided.

Returns:

  • (Float)


20
21
22
# File 'lib/usps_api/models/labels_package_options2.rb', line 20

def package_value
  @package_value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/usps_api/models/labels_package_options2.rb', line 75

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
  omas = Omas.from_hash(hash['omas']) if hash['omas']

  # 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.
  LabelsPackageOptions2.new(package_value: package_value,
                            non_delivery_option: non_delivery_option,
                            omas: omas,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
# File 'lib/usps_api/models/labels_package_options2.rb', line 41

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

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/usps_api/models/labels_package_options2.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
# File 'lib/usps_api/models/labels_package_options2.rb', line 50

def self.optionals
  %w[
    package_value
    non_delivery_option
    omas
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



107
108
109
110
111
112
# File 'lib/usps_api/models/labels_package_options2.rb', line 107

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

#to_sObject

Provides a human-readable string representation of the object.



99
100
101
102
103
104
# File 'lib/usps_api/models/labels_package_options2.rb', line 99

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