Class: UspsApi::LabelsPackageOptions1

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

Overview

Options added to packages that are less frequently used

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, immediate_manifest: false, redirect_address: SKIP, content_type: SKIP, generate_gx_event: true, containers: SKIP, ancillary_service_endorsements: SKIP, additional_properties: nil) ⇒ LabelsPackageOptions1

Returns a new instance of LabelsPackageOptions1.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/usps_api/models/labels_package_options1.rb', line 138

def initialize(package_value: SKIP, non_delivery_option: SKIP, omas: SKIP,
               immediate_manifest: false, redirect_address: SKIP,
               content_type: SKIP, generate_gx_event: true,
               containers: SKIP, ancillary_service_endorsements: 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
  @immediate_manifest = immediate_manifest unless immediate_manifest == SKIP
  @redirect_address = redirect_address unless redirect_address == SKIP
  @content_type = content_type unless content_type == SKIP
  @generate_gx_event = generate_gx_event unless generate_gx_event == SKIP
  @containers = containers unless containers == SKIP
  unless ancillary_service_endorsements == SKIP
    @ancillary_service_endorsements =
      ancillary_service_endorsements
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#ancillary_service_endorsementsAncillaryServiceEndorsements1

Endorsements allow the sender to obtain the addressee’s new (forwarding) address (provided the appropriate endorsement is used and if the addressee filed a Change-of-Address Order with the Postal Service) or the reason for non-delivery. For more information see [PostalPro](postalpro.usps.com/address-quality/ancillary-service-e ndorsements)



100
101
102
# File 'lib/usps_api/models/labels_package_options1.rb', line 100

def ancillary_service_endorsements
  @ancillary_service_endorsements
end

#containersArray[LabelsContainer]

containers

Returns:



90
91
92
# File 'lib/usps_api/models/labels_package_options1.rb', line 90

def containers
  @containers
end

#content_typeContentType1

The type of contents in the package.

  • HAZMAT

  • CREMATED_REMAINS

  • BEES

  • DAY_OLD_POULTRY

  • ADULT_BIRDS

  • OTHER_LIVES

  • PERISHABLE

  • PHARMACEUTICALS

  • MEDICAL_SUPPLIES

  • FRUITS

  • VEGETABLES

  • LIVE_PLANTS

Note:

  • ‘CREMATED_REMAINS` is currently only eligible for the

‘PRIORITY_MAIL_EXPRESS_RETURN_SERVICE` mail class. Please refer to [Publication 139](about.usps.com/publications/pub139/welcome.htm) for guidelines on how to package and ship `CREMATED_REMAINS`.

  • ‘HAZMAT` domestic labels with destination addresses to APO/FPO/DPO and

PTFAS (except Puerto Rico) will not contain any Hazmat markings/indicators, including service type codes in the IMpb. When users indicate a shipment contains hazmat materials in the API request (via content type and/or extra services), that information will still be captured and sent in the shipping services file. For more information, please review the [USPS APIs release notes](postalpro.usps.gov/usps-apis-releases)

  • For guidelines on shipping Hazardous Material, please refer to

[Publication 52](pe.usps.com/text/pub52/welcome.htm).

Returns:



81
82
83
# File 'lib/usps_api/models/labels_package_options1.rb', line 81

def content_type
  @content_type
end

#generate_gx_eventTrueClass | FalseClass

Provides the option for a user to not create a “GX” event for the package. By default, a GX event will be created.

Returns:

  • (TrueClass | FalseClass)


86
87
88
# File 'lib/usps_api/models/labels_package_options1.rb', line 86

def generate_gx_event
  @generate_gx_event
end

#immediate_manifestTrueClass | FalseClass

Setting this field to ‘true` will send electronic data to Postal systems within 15 minutes of label creation.

Returns:

  • (TrueClass | FalseClass)


43
44
45
# File 'lib/usps_api/models/labels_package_options1.rb', line 43

def immediate_manifest
  @immediate_manifest
end

#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_options1.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_options1.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_options1.rb', line 20

def package_value
  @package_value
end

#redirect_addressInternationalLabelsDomesticLabelAddress

Deprecated: Use the ‘ancillaryServiceEndorsements` field instead. Address to send the package to if it is not deliverable. Note:

- Required when `nonDeliveryOption` is a value of `REDIRECT`.


50
51
52
# File 'lib/usps_api/models/labels_package_options1.rb', line 50

def redirect_address
  @redirect_address
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/usps_api/models/labels_package_options1.rb', line 162

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']
  immediate_manifest = hash['immediateManifest'] ||= false
  if hash['redirectAddress']
    redirect_address = InternationalLabelsDomesticLabelAddress.from_hash(hash['redirectAddress'])
  end
  content_type = hash.key?('contentType') ? hash['contentType'] : SKIP
  generate_gx_event = hash['generateGXEvent'] ||= true
  # Parameter is an array, so we need to iterate through it
  containers = nil
  unless hash['containers'].nil?
    containers = []
    hash['containers'].each do |structure|
      containers << (LabelsContainer.from_hash(structure) if structure)
    end
  end

  containers = SKIP unless hash.key?('containers')
  ancillary_service_endorsements =
    hash.key?('ancillaryServiceEndorsements') ? hash['ancillaryServiceEndorsements'] : 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.
  LabelsPackageOptions1.new(package_value: package_value,
                            non_delivery_option: non_delivery_option,
                            omas: omas,
                            immediate_manifest: immediate_manifest,
                            redirect_address: redirect_address,
                            content_type: content_type,
                            generate_gx_event: generate_gx_event,
                            containers: containers,
                            ancillary_service_endorsements: ancillary_service_endorsements,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/usps_api/models/labels_package_options1.rb', line 103

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['package_value'] = 'packageValue'
  @_hash['non_delivery_option'] = 'nonDeliveryOption'
  @_hash['omas'] = 'omas'
  @_hash['immediate_manifest'] = 'immediateManifest'
  @_hash['redirect_address'] = 'redirectAddress'
  @_hash['content_type'] = 'contentType'
  @_hash['generate_gx_event'] = 'generateGXEvent'
  @_hash['containers'] = 'containers'
  @_hash['ancillary_service_endorsements'] =
    'ancillaryServiceEndorsements'
  @_hash
end

.nullablesObject

An array for nullable fields



134
135
136
# File 'lib/usps_api/models/labels_package_options1.rb', line 134

def self.nullables
  []
end

.optionalsObject

An array for optional fields



119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/usps_api/models/labels_package_options1.rb', line 119

def self.optionals
  %w[
    package_value
    non_delivery_option
    omas
    immediate_manifest
    redirect_address
    content_type
    generate_gx_event
    containers
    ancillary_service_endorsements
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



211
212
213
214
215
216
217
# File 'lib/usps_api/models/labels_package_options1.rb', line 211

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



230
231
232
233
234
235
236
237
238
239
# File 'lib/usps_api/models/labels_package_options1.rb', line 230

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}, immediate_manifest:"\
  " #{@immediate_manifest.inspect}, redirect_address: #{@redirect_address.inspect},"\
  " content_type: #{@content_type.inspect}, generate_gx_event: #{@generate_gx_event.inspect},"\
  " containers: #{@containers.inspect}, ancillary_service_endorsements:"\
  " #{@ancillary_service_endorsements.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



220
221
222
223
224
225
226
227
# File 'lib/usps_api/models/labels_package_options1.rb', line 220

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