Class: UspsApi::InternationalLabelAddress
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::InternationalLabelAddress
- Defined in:
- lib/usps_api/models/international_label_address.rb
Overview
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.
Instance Attribute Summary collapse
-
#city ⇒ String
This is the city name of the address.
-
#city_abbreviation ⇒ String
This is the abbreviation of city name for the address.
-
#country ⇒ String
This is the country name used in an international address.
-
#country_iso_alpha2_code ⇒ String
ISO 3166-1 alpha-2 codes are two-letter country codes defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO), to represent countries, dependent territories, and special areas of geographical interest.
-
#firm ⇒ String
Firm corresponding to the address.
-
#first_name ⇒ String
First Name corresponding to the address.
-
#last_name ⇒ String
Last Name corresponding to the address.
-
#phone ⇒ String
The phone number, including the country extension and area code or the local national format, with no punctuation.
-
#postal_code ⇒ String
This is the Postal Code used for international addresses.
-
#province ⇒ String
This is the province used for international addresses.
-
#province_iso_alpha2_code ⇒ String
The 2 letter abbreviation representing the destination province.
-
#secondary_address ⇒ String
The secondary unit designator, such as apartment(APT) or suite(STE) number, defining the exact location of the address within a building.
-
#street_address ⇒ String
The number of a building along with the name of the road or street on which it is located.
-
#street_address_abbreviation ⇒ String
This is the abbreviation of street address line for the address.
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(street_address:, city:, country:, country_iso_alpha2_code:, street_address_abbreviation: SKIP, secondary_address: SKIP, city_abbreviation: SKIP, postal_code: SKIP, province: SKIP, province_iso_alpha2_code: SKIP, first_name: SKIP, last_name: SKIP, firm: SKIP, phone: SKIP, additional_properties: nil) ⇒ InternationalLabelAddress
constructor
A new instance of InternationalLabelAddress.
-
#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(street_address:, city:, country:, country_iso_alpha2_code:, street_address_abbreviation: SKIP, secondary_address: SKIP, city_abbreviation: SKIP, postal_code: SKIP, province: SKIP, province_iso_alpha2_code: SKIP, first_name: SKIP, last_name: SKIP, firm: SKIP, phone: SKIP, additional_properties: nil) ⇒ InternationalLabelAddress
Returns a new instance of InternationalLabelAddress.
133 134 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 |
# File 'lib/usps_api/models/international_label_address.rb', line 133 def initialize(street_address:, city:, country:, country_iso_alpha2_code:, street_address_abbreviation: SKIP, secondary_address: SKIP, city_abbreviation: SKIP, postal_code: SKIP, province: SKIP, province_iso_alpha2_code: SKIP, first_name: SKIP, last_name: SKIP, firm: SKIP, phone: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @street_address = street_address unless street_address_abbreviation == SKIP @street_address_abbreviation = street_address_abbreviation end @secondary_address = secondary_address unless secondary_address == SKIP @city_abbreviation = city_abbreviation unless city_abbreviation == SKIP @city = city @postal_code = postal_code unless postal_code == SKIP @province = province unless province == SKIP @province_iso_alpha2_code = province_iso_alpha2_code unless province_iso_alpha2_code == SKIP @country = country @country_iso_alpha2_code = country_iso_alpha2_code @first_name = first_name unless first_name == SKIP @last_name = last_name unless last_name == SKIP @firm = firm unless firm == SKIP @phone = phone unless phone == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#city ⇒ String
This is the city name of the address.
36 37 38 |
# File 'lib/usps_api/models/international_label_address.rb', line 36 def city @city end |
#city_abbreviation ⇒ String
This is the abbreviation of city name for the address.
32 33 34 |
# File 'lib/usps_api/models/international_label_address.rb', line 32 def city_abbreviation @city_abbreviation end |
#country ⇒ String
This is the country name used in an international address.
59 60 61 |
# File 'lib/usps_api/models/international_label_address.rb', line 59 def country @country end |
#country_iso_alpha2_code ⇒ String
ISO 3166-1 alpha-2 codes are two-letter country codes defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO), to represent countries, dependent territories, and special areas of geographical interest. They are the most widely used of the country codes published by ISO (the others being alpha-3 and numeric), and are used most prominently for the Internet’s country code top-level domains (with a few exceptions). They are also used as country identifiers extending the postal code when appropriate within the international postal system for paper mail, and have replaced the previous one consisting of one-letter codes. They were first included as part of the ISO 3166 standard in its first edition in 1974.
73 74 75 |
# File 'lib/usps_api/models/international_label_address.rb', line 73 def country_iso_alpha2_code @country_iso_alpha2_code end |
#firm ⇒ String
Firm corresponding to the address.
85 86 87 |
# File 'lib/usps_api/models/international_label_address.rb', line 85 def firm @firm end |
#first_name ⇒ String
First Name corresponding to the address.
77 78 79 |
# File 'lib/usps_api/models/international_label_address.rb', line 77 def first_name @first_name end |
#last_name ⇒ String
Last Name corresponding to the address.
81 82 83 |
# File 'lib/usps_api/models/international_label_address.rb', line 81 def last_name @last_name end |
#phone ⇒ String
The phone number, including the country extension and area code or the local national format, with no punctuation.
90 91 92 |
# File 'lib/usps_api/models/international_label_address.rb', line 90 def phone @phone end |
#postal_code ⇒ String
This is the Postal Code used for international addresses. Note:
-
When shipping to Canada, this field must start with a letter (A-Z)
-
Different shipping destinations may require a postal code for shipping.
For more details, review the [Individual Country Listing](pe.usps.com/text/imm/immctry.htm) for your shipping destination
46 47 48 |
# File 'lib/usps_api/models/international_label_address.rb', line 46 def postal_code @postal_code end |
#province ⇒ String
This is the province used for international addresses.
50 51 52 |
# File 'lib/usps_api/models/international_label_address.rb', line 50 def province @province end |
#province_iso_alpha2_code ⇒ String
The 2 letter abbreviation representing the destination province. Required for select destination countries when ‘prepayDutiesTaxesFees` is `true`.
55 56 57 |
# File 'lib/usps_api/models/international_label_address.rb', line 55 def province_iso_alpha2_code @province_iso_alpha2_code end |
#secondary_address ⇒ String
The secondary unit designator, such as apartment(APT) or suite(STE) number, defining the exact location of the address within a building. For more information please see [Postal Explorer](pe.usps.com/text/pub28/28c2_003.htm).
28 29 30 |
# File 'lib/usps_api/models/international_label_address.rb', line 28 def secondary_address @secondary_address end |
#street_address ⇒ String
The number of a building along with the name of the road or street on which it is located.
17 18 19 |
# File 'lib/usps_api/models/international_label_address.rb', line 17 def street_address @street_address end |
#street_address_abbreviation ⇒ String
This is the abbreviation of street address line for the address.
21 22 23 |
# File 'lib/usps_api/models/international_label_address.rb', line 21 def street_address_abbreviation @street_address_abbreviation end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 208 209 210 |
# File 'lib/usps_api/models/international_label_address.rb', line 163 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. street_address = hash.key?('streetAddress') ? hash['streetAddress'] : nil city = hash.key?('city') ? hash['city'] : nil country = hash.key?('country') ? hash['country'] : nil country_iso_alpha2_code = hash.key?('countryISOAlpha2Code') ? hash['countryISOAlpha2Code'] : nil street_address_abbreviation = hash.key?('streetAddressAbbreviation') ? hash['streetAddressAbbreviation'] : SKIP secondary_address = hash.key?('secondaryAddress') ? hash['secondaryAddress'] : SKIP city_abbreviation = hash.key?('cityAbbreviation') ? hash['cityAbbreviation'] : SKIP postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP province = hash.key?('province') ? hash['province'] : SKIP province_iso_alpha2_code = hash.key?('provinceISOAlpha2Code') ? hash['provinceISOAlpha2Code'] : SKIP first_name = hash.key?('firstName') ? hash['firstName'] : SKIP last_name = hash.key?('lastName') ? hash['lastName'] : SKIP firm = hash.key?('firm') ? hash['firm'] : SKIP phone = hash.key?('phone') ? hash['phone'] : 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. InternationalLabelAddress.new(street_address: street_address, city: city, country: country, country_iso_alpha2_code: country_iso_alpha2_code, street_address_abbreviation: street_address_abbreviation, secondary_address: secondary_address, city_abbreviation: city_abbreviation, postal_code: postal_code, province: province, province_iso_alpha2_code: province_iso_alpha2_code, first_name: first_name, last_name: last_name, firm: firm, phone: phone, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/usps_api/models/international_label_address.rb', line 93 def self.names @_hash = {} if @_hash.nil? @_hash['street_address'] = 'streetAddress' @_hash['street_address_abbreviation'] = 'streetAddressAbbreviation' @_hash['secondary_address'] = 'secondaryAddress' @_hash['city_abbreviation'] = 'cityAbbreviation' @_hash['city'] = 'city' @_hash['postal_code'] = 'postalCode' @_hash['province'] = 'province' @_hash['province_iso_alpha2_code'] = 'provinceISOAlpha2Code' @_hash['country'] = 'country' @_hash['country_iso_alpha2_code'] = 'countryISOAlpha2Code' @_hash['first_name'] = 'firstName' @_hash['last_name'] = 'lastName' @_hash['firm'] = 'firm' @_hash['phone'] = 'phone' @_hash end |
.nullables ⇒ Object
An array for nullable fields
129 130 131 |
# File 'lib/usps_api/models/international_label_address.rb', line 129 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/usps_api/models/international_label_address.rb', line 113 def self.optionals %w[ street_address_abbreviation secondary_address city_abbreviation postal_code province province_iso_alpha2_code first_name last_name firm phone ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/usps_api/models/international_label_address.rb', line 225 def inspect class_name = self.class.name.split('::').last "<#{class_name} street_address: #{@street_address.inspect}, street_address_abbreviation:"\ " #{@street_address_abbreviation.inspect}, secondary_address: #{@secondary_address.inspect},"\ " city_abbreviation: #{@city_abbreviation.inspect}, city: #{@city.inspect}, postal_code:"\ " #{@postal_code.inspect}, province: #{@province.inspect}, province_iso_alpha2_code:"\ " #{@province_iso_alpha2_code.inspect}, country: #{@country.inspect},"\ " country_iso_alpha2_code: #{@country_iso_alpha2_code.inspect}, first_name:"\ " #{@first_name.inspect}, last_name: #{@last_name.inspect}, firm: #{@firm.inspect}, phone:"\ " #{@phone.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/usps_api/models/international_label_address.rb', line 213 def to_s class_name = self.class.name.split('::').last "<#{class_name} street_address: #{@street_address}, street_address_abbreviation:"\ " #{@street_address_abbreviation}, secondary_address: #{@secondary_address},"\ " city_abbreviation: #{@city_abbreviation}, city: #{@city}, postal_code: #{@postal_code},"\ " province: #{@province}, province_iso_alpha2_code: #{@province_iso_alpha2_code}, country:"\ " #{@country}, country_iso_alpha2_code: #{@country_iso_alpha2_code}, first_name:"\ " #{@first_name}, last_name: #{@last_name}, firm: #{@firm}, phone: #{@phone},"\ " additional_properties: #{@additional_properties}>" end |