Class: UspsApi::ReturnsPackageRequest
- Defined in:
- lib/usps_api/models/returns_package_request.rb
Overview
Domestic Package Request
Instance Attribute Summary collapse
-
#customs_form ⇒ LabelsCustomsForm1
Domestic Returns Custom Form.
-
#from_address ⇒ InternationalLabelsDomesticLabelAddress
The address where the return package is being shipped from.
-
#image_info ⇒ ImageInfo11
Image information.
-
#package_description ⇒ Object
package description.
-
#return_address ⇒ InternationalLabelsDomesticLabelAddress
The address where the package should be returned to if it is deemed undeliverable or returned to sender.
-
#sender_address ⇒ InternationalLabelsDomesticLabelSenderAddress
The address of the business involved (typically the sender of the original package).
-
#to_address ⇒ InternationalLabelsDomesticLabelAddress
The address where the return package is being shipped to.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(to_address:, from_address:, package_description:, image_info: SKIP, sender_address: SKIP, return_address: SKIP, customs_form: SKIP) ⇒ ReturnsPackageRequest
constructor
A new instance of ReturnsPackageRequest.
-
#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(to_address:, from_address:, package_description:, image_info: SKIP, sender_address: SKIP, return_address: SKIP, customs_form: SKIP) ⇒ ReturnsPackageRequest
Returns a new instance of ReturnsPackageRequest.
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/usps_api/models/returns_package_request.rb', line 91 def initialize(to_address:, from_address:, package_description:, image_info: SKIP, sender_address: SKIP, return_address: SKIP, customs_form: SKIP) @image_info = image_info unless image_info == SKIP @to_address = to_address @from_address = from_address @sender_address = sender_address unless sender_address == SKIP @return_address = return_address unless return_address == SKIP @package_description = package_description @customs_form = customs_form unless customs_form == SKIP end |
Instance Attribute Details
#customs_form ⇒ LabelsCustomsForm1
Domestic Returns Custom Form
61 62 63 |
# File 'lib/usps_api/models/returns_package_request.rb', line 61 def customs_form @customs_form end |
#from_address ⇒ InternationalLabelsDomesticLabelAddress
The address where the return package is being shipped from. The ZIP Code™in the ‘fromAddress` object is used to calculate pricing. Notes:
-
The First and Last Name or Firm Name are always required.
-
If the ‘returnAddress` is not provided, the `fromAddress` will be used
as the ‘returnAddress`.
33 34 35 |
# File 'lib/usps_api/models/returns_package_request.rb', line 33 def from_address @from_address end |
#image_info ⇒ ImageInfo11
Image information
14 15 16 |
# File 'lib/usps_api/models/returns_package_request.rb', line 14 def image_info @image_info end |
#package_description ⇒ Object
package description
57 58 59 |
# File 'lib/usps_api/models/returns_package_request.rb', line 57 def package_description @package_description end |
#return_address ⇒ InternationalLabelsDomesticLabelAddress
The address where the package should be returned to if it is deemed undeliverable or returned to sender. This address will be printed in the return address block of the label. This could be a secondary return address in case the toAddress is deemed undeliverable or returned to sender. Note:
-
The First and Last Name or Firm Name are always required.
53 54 55 |
# File 'lib/usps_api/models/returns_package_request.rb', line 53 def return_address @return_address end |
#sender_address ⇒ InternationalLabelsDomesticLabelSenderAddress
The address of the business involved (typically the sender of the original package). The ‘senderAddress` can be different from the `toAddress` when the business address is not where the package is being shipped to. Notes:
-
The First and Last Name or Firm Name are always required.
-
‘senderAddress` is required when the `shipperVisibilityMethod` field is
set to ‘SENDER_INFORMATION`.
43 44 45 |
# File 'lib/usps_api/models/returns_package_request.rb', line 43 def sender_address @sender_address end |
#to_address ⇒ InternationalLabelsDomesticLabelAddress
The address where the return package is being shipped to. The ZIP Code™ in the ‘toAddress` object is used to calculate pricing. Notes:
-
The First and Last Name or Firm Name are always required.
-
For return labels, the ‘toAddress` ZIP Plus 4 is looked up by the API,
unless the ‘ignoreBadAddress` field is set to true or the address cannot be found. If `ignoreBadAddress` field is true then ZIP Plus 4 is required.
24 25 26 |
# File 'lib/usps_api/models/returns_package_request.rb', line 24 def to_address @to_address end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/usps_api/models/returns_package_request.rb', line 104 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. to_address = InternationalLabelsDomesticLabelAddress.from_hash(hash['toAddress']) if hash['toAddress'] from_address = InternationalLabelsDomesticLabelAddress.from_hash(hash['fromAddress']) if hash['fromAddress'] package_description = hash.key?('packageDescription') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:ReturnsPackageRequestPackageDescription), hash['packageDescription'] ) : nil image_info = ImageInfo11.from_hash(hash['imageInfo']) if hash['imageInfo'] if hash['senderAddress'] sender_address = InternationalLabelsDomesticLabelSenderAddress.from_hash(hash['senderAddress']) end return_address = InternationalLabelsDomesticLabelAddress.from_hash(hash['returnAddress']) if hash['returnAddress'] customs_form = LabelsCustomsForm1.from_hash(hash['customsForm']) if hash['customsForm'] # Create object from extracted values. ReturnsPackageRequest.new(to_address: to_address, from_address: from_address, package_description: package_description, image_info: image_info, sender_address: sender_address, return_address: return_address, customs_form: customs_form) end |
.names ⇒ Object
A mapping from model property names to API property names.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/usps_api/models/returns_package_request.rb', line 64 def self.names @_hash = {} if @_hash.nil? @_hash['image_info'] = 'imageInfo' @_hash['to_address'] = 'toAddress' @_hash['from_address'] = 'fromAddress' @_hash['sender_address'] = 'senderAddress' @_hash['return_address'] = 'returnAddress' @_hash['package_description'] = 'packageDescription' @_hash['customs_form'] = 'customsForm' @_hash end |
.nullables ⇒ Object
An array for nullable fields
87 88 89 |
# File 'lib/usps_api/models/returns_package_request.rb', line 87 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
77 78 79 80 81 82 83 84 |
# File 'lib/usps_api/models/returns_package_request.rb', line 77 def self.optionals %w[ image_info sender_address return_address customs_form ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/usps_api/models/returns_package_request.rb', line 135 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.to_address, ->(val) { InternationalLabelsDomesticLabelAddress.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.from_address, ->(val) { InternationalLabelsDomesticLabelAddress.validate(val) }, is_model_hash: true) and UnionTypeLookUp.get(:ReturnsPackageRequestPackageDescription) .validate(value.package_description) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['toAddress'], ->(val) { InternationalLabelsDomesticLabelAddress.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['fromAddress'], ->(val) { InternationalLabelsDomesticLabelAddress.validate(val) }, is_model_hash: true) and UnionTypeLookUp.get(:ReturnsPackageRequestPackageDescription) .validate(value['packageDescription']) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
172 173 174 175 176 177 178 |
# File 'lib/usps_api/models/returns_package_request.rb', line 172 def inspect class_name = self.class.name.split('::').last "<#{class_name} image_info: #{@image_info.inspect}, to_address: #{@to_address.inspect},"\ " from_address: #{@from_address.inspect}, sender_address: #{@sender_address.inspect},"\ " return_address: #{@return_address.inspect}, package_description:"\ " #{@package_description.inspect}, customs_form: #{@customs_form.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
164 165 166 167 168 169 |
# File 'lib/usps_api/models/returns_package_request.rb', line 164 def to_s class_name = self.class.name.split('::').last "<#{class_name} image_info: #{@image_info}, to_address: #{@to_address}, from_address:"\ " #{@from_address}, sender_address: #{@sender_address}, return_address: #{@return_address},"\ " package_description: #{@package_description}, customs_form: #{@customs_form}>" end |