Class: UspsApi::InternationalPackageRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::InternationalPackageRequest
- Defined in:
- lib/usps_api/models/international_package_request.rb
Overview
International Shipment Request
Instance Attribute Summary collapse
-
#customs_form ⇒ InternationalCustomsForm
Customs form information required for international shipments including content type, item details, and references.
-
#from_address ⇒ InternationalLabelsDomesticLabelAddress
Uses for: The address of the business where the package is being mailed from.
-
#image_info ⇒ InternationalImageInfo
The Image Object defines label characteristics.
-
#package_description ⇒ InternationalLabelsInternationalPackageDescription
Physical and service characteristics of an international package including dimensions, weight, mail class, and processing requirements.
-
#sender_address ⇒ InternationalLabelsDomesticLabelSenderAddress
Uses for: The address of the business sending the package.
-
#to_address ⇒ InternationalLabelAddress
Uses for: The international address where the package is being mailed 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.
Instance Method Summary collapse
-
#initialize(to_address:, from_address:, package_description:, customs_form:, image_info: SKIP, sender_address: SKIP) ⇒ InternationalPackageRequest
constructor
A new instance of InternationalPackageRequest.
-
#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:, customs_form:, image_info: SKIP, sender_address: SKIP) ⇒ InternationalPackageRequest
Returns a new instance of InternationalPackageRequest.
75 76 77 78 79 80 81 82 83 |
# File 'lib/usps_api/models/international_package_request.rb', line 75 def initialize(to_address:, from_address:, package_description:, customs_form:, image_info: SKIP, sender_address: 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 @package_description = package_description @customs_form = customs_form end |
Instance Attribute Details
#customs_form ⇒ InternationalCustomsForm
Customs form information required for international shipments including content type, item details, and references.
48 49 50 |
# File 'lib/usps_api/models/international_package_request.rb', line 48 def customs_form @customs_form end |
#from_address ⇒ InternationalLabelsDomesticLabelAddress
Uses for: The address of the business where the package is being mailed from. Note:
-
The First and Last Name or Firm Name are always required.
29 30 31 |
# File 'lib/usps_api/models/international_package_request.rb', line 29 def from_address @from_address end |
#image_info ⇒ InternationalImageInfo
The Image Object defines label characteristics
14 15 16 |
# File 'lib/usps_api/models/international_package_request.rb', line 14 def image_info @image_info end |
#package_description ⇒ InternationalLabelsInternationalPackageDescription
Physical and service characteristics of an international package including dimensions, weight, mail class, and processing requirements.
43 44 45 |
# File 'lib/usps_api/models/international_package_request.rb', line 43 def package_description @package_description end |
#sender_address ⇒ InternationalLabelsDomesticLabelSenderAddress
Uses for:
The address of the business sending the package. Can differ from the
‘fromAddress` in the case the business is using a third-party logistics provider or mailing from off-site locations.
Note:
- The First and Last Name or Firm Name are always required.
38 39 40 |
# File 'lib/usps_api/models/international_package_request.rb', line 38 def sender_address @sender_address end |
#to_address ⇒ InternationalLabelAddress
Uses for: The international address where the package is being mailed to. The destination Country Code is used for calculating pricing. Note:
-
The First and Last Name or Firm Name are always required.
22 23 24 |
# File 'lib/usps_api/models/international_package_request.rb', line 22 def to_address @to_address end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/usps_api/models/international_package_request.rb', line 86 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. to_address = InternationalLabelAddress.from_hash(hash['toAddress']) if hash['toAddress'] from_address = InternationalLabelsDomesticLabelAddress.from_hash(hash['fromAddress']) if hash['fromAddress'] if hash['packageDescription'] package_description = InternationalLabelsInternationalPackageDescription.from_hash(hash['packageDescription']) end customs_form = InternationalCustomsForm.from_hash(hash['customsForm']) if hash['customsForm'] image_info = InternationalImageInfo.from_hash(hash['imageInfo']) if hash['imageInfo'] if hash['senderAddress'] sender_address = InternationalLabelsDomesticLabelSenderAddress.from_hash(hash['senderAddress']) end # Create object from extracted values. InternationalPackageRequest.new(to_address: to_address, from_address: from_address, package_description: package_description, customs_form: customs_form, image_info: image_info, sender_address: sender_address) end |
.names ⇒ Object
A mapping from model property names to API property names.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/usps_api/models/international_package_request.rb', line 51 def self.names @_hash = {} if @_hash.nil? @_hash['image_info'] = 'imageInfo' @_hash['to_address'] = 'toAddress' @_hash['from_address'] = 'fromAddress' @_hash['sender_address'] = 'senderAddress' @_hash['package_description'] = 'packageDescription' @_hash['customs_form'] = 'customsForm' @_hash end |
.nullables ⇒ Object
An array for nullable fields
71 72 73 |
# File 'lib/usps_api/models/international_package_request.rb', line 71 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
63 64 65 66 67 68 |
# File 'lib/usps_api/models/international_package_request.rb', line 63 def self.optionals %w[ image_info sender_address ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
121 122 123 124 125 126 127 |
# File 'lib/usps_api/models/international_package_request.rb', line 121 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},"\ " package_description: #{@package_description.inspect}, customs_form:"\ " #{@customs_form.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
113 114 115 116 117 118 |
# File 'lib/usps_api/models/international_package_request.rb', line 113 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}, package_description:"\ " #{@package_description}, customs_form: #{@customs_form}>" end |