Class: UspsApi::InternationalPackageOptions
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::InternationalPackageOptions
- Defined in:
- lib/usps_api/models/international_package_options.rb
Overview
Additional options for international package shipments including redirect addresses, over-labeling information, and manifest preferences.
Instance Attribute Summary collapse
-
#generate_gx_event ⇒ TrueClass | FalseClass
Provides the option for a user to not create a “GX” event for the package.
-
#immediate_manifest ⇒ TrueClass | FalseClass
Setting this field to ‘true` will send electronic data to Postal systems within 15 minutes of label creation.
-
#non_delivery_option ⇒ NonDeliveryOption
Requested action in the case a package is undeliverable: * RETURN for the package to be returned to ‘fromAddress`.
-
#original_package ⇒ OriginalPackage
Information about the original package when an over labeled package is being created.
-
#package_value ⇒ Float
The merchandise value of the package, in US dollars.
-
#redirect_address ⇒ RedirectAddress
Address where the package will be redirected to if undeliverable and a ‘nonDeliveryOption` of REDIRECT is provided.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(package_value: SKIP, non_delivery_option: SKIP, redirect_address: SKIP, original_package: SKIP, generate_gx_event: true, immediate_manifest: false) ⇒ InternationalPackageOptions
constructor
A new instance of InternationalPackageOptions.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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, redirect_address: SKIP, original_package: SKIP, generate_gx_event: true, immediate_manifest: false) ⇒ InternationalPackageOptions
Returns a new instance of InternationalPackageOptions.
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/usps_api/models/international_package_options.rb', line 83 def initialize(package_value: SKIP, non_delivery_option: SKIP, redirect_address: SKIP, original_package: SKIP, generate_gx_event: true, immediate_manifest: false) @package_value = package_value unless package_value == SKIP @non_delivery_option = non_delivery_option unless non_delivery_option == SKIP @redirect_address = redirect_address unless redirect_address == SKIP @original_package = original_package unless original_package == SKIP @generate_gx_event = generate_gx_event unless generate_gx_event == SKIP @immediate_manifest = immediate_manifest unless immediate_manifest == SKIP end |
Instance Attribute Details
#generate_gx_event ⇒ TrueClass | FalseClass
Provides the option for a user to not create a “GX” event for the package. By default, a GX event will be created.
42 43 44 |
# File 'lib/usps_api/models/international_package_options.rb', line 42 def generate_gx_event @generate_gx_event end |
#immediate_manifest ⇒ TrueClass | FalseClass
Setting this field to ‘true` will send electronic data to Postal systems within 15 minutes of label creation. If invoked, this label <u><strong>cannot</strong></u> be cancelled. Instead, one must request an unused label refund – which may be subject to an admin fee. Depending on time of label creation, your packages could be charged same day instead of next day.
52 53 54 |
# File 'lib/usps_api/models/international_package_options.rb', line 52 def immediate_manifest @immediate_manifest end |
#non_delivery_option ⇒ NonDeliveryOption
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
23 24 25 |
# File 'lib/usps_api/models/international_package_options.rb', line 23 def non_delivery_option @non_delivery_option end |
#original_package ⇒ OriginalPackage
Information about the original package when an over labeled package is being created.
37 38 39 |
# File 'lib/usps_api/models/international_package_options.rb', line 37 def original_package @original_package end |
#package_value ⇒ Float
The merchandise value of the package, in US dollars. Used to calculate Insurance Fees if requested.
16 17 18 |
# File 'lib/usps_api/models/international_package_options.rb', line 16 def package_value @package_value end |
#redirect_address ⇒ RedirectAddress
Address where the package will be redirected to if undeliverable and a ‘nonDeliveryOption` of REDIRECT is provided. This field is required if REDIRECT `nonDeliveryOption` is provided. Note:
-
The First and Last Name or Firm Name are required when ‘redirectAddress`
is populated.
32 33 34 |
# File 'lib/usps_api/models/international_package_options.rb', line 32 def redirect_address @redirect_address end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/usps_api/models/international_package_options.rb', line 95 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 redirect_address = RedirectAddress.from_hash(hash['redirectAddress']) if hash['redirectAddress'] original_package = OriginalPackage.from_hash(hash['originalPackage']) if hash['originalPackage'] generate_gx_event = hash['generateGXEvent'] ||= true immediate_manifest = hash['immediateManifest'] ||= false # Create object from extracted values. InternationalPackageOptions.new(package_value: package_value, non_delivery_option: non_delivery_option, redirect_address: redirect_address, original_package: original_package, generate_gx_event: generate_gx_event, immediate_manifest: immediate_manifest) end |
.names ⇒ Object
A mapping from model property names to API property names.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/usps_api/models/international_package_options.rb', line 55 def self.names @_hash = {} if @_hash.nil? @_hash['package_value'] = 'packageValue' @_hash['non_delivery_option'] = 'nonDeliveryOption' @_hash['redirect_address'] = 'redirectAddress' @_hash['original_package'] = 'originalPackage' @_hash['generate_gx_event'] = 'generateGXEvent' @_hash['immediate_manifest'] = 'immediateManifest' @_hash end |
.nullables ⇒ Object
An array for nullable fields
79 80 81 |
# File 'lib/usps_api/models/international_package_options.rb', line 79 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/usps_api/models/international_package_options.rb', line 67 def self.optionals %w[ package_value non_delivery_option redirect_address original_package generate_gx_event immediate_manifest ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
128 129 130 131 132 133 134 |
# File 'lib/usps_api/models/international_package_options.rb', line 128 def inspect class_name = self.class.name.split('::').last "<#{class_name} package_value: #{@package_value.inspect}, non_delivery_option:"\ " #{@non_delivery_option.inspect}, redirect_address: #{@redirect_address.inspect},"\ " original_package: #{@original_package.inspect}, generate_gx_event:"\ " #{@generate_gx_event.inspect}, immediate_manifest: #{@immediate_manifest.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
119 120 121 122 123 124 125 |
# File 'lib/usps_api/models/international_package_options.rb', line 119 def to_s class_name = self.class.name.split('::').last "<#{class_name} package_value: #{@package_value}, non_delivery_option:"\ " #{@non_delivery_option}, redirect_address: #{@redirect_address}, original_package:"\ " #{@original_package}, generate_gx_event: #{@generate_gx_event}, immediate_manifest:"\ " #{@immediate_manifest}>" end |