Class: UspsApi::InternationalBaseRatesQuery

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

Overview

Search parameters for base rates.

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(origin_zip_code:, weight:, length:, width:, height:, mail_class:, processing_category:, rate_indicator:, destination_entry_facility_type:, price_type:, destination_country_code:, mailing_date: SKIP, foreign_postal_code: SKIP, account_type: SKIP, account_number: SKIP) ⇒ InternationalBaseRatesQuery

Returns a new instance of InternationalBaseRatesQuery.



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/usps_api/models/international_base_rates_query.rb', line 153

def initialize(origin_zip_code:, weight:, length:, width:, height:,
               mail_class:, processing_category:, rate_indicator:,
               destination_entry_facility_type:, price_type:,
               destination_country_code:, mailing_date: SKIP,
               foreign_postal_code: SKIP, account_type: SKIP,
               account_number: SKIP)
  @origin_zip_code = origin_zip_code
  @weight = weight
  @length = length
  @width = width
  @height = height
  @mail_class = mail_class
  @processing_category = processing_category
  @rate_indicator = rate_indicator
  @destination_entry_facility_type = destination_entry_facility_type
  @price_type = price_type
  @mailing_date = mailing_date unless mailing_date == SKIP
  @foreign_postal_code = foreign_postal_code unless foreign_postal_code == SKIP
  @destination_country_code = destination_country_code
  @account_type =  unless  == SKIP
  @account_number =  unless  == SKIP
end

Instance Attribute Details

#account_numberString

The Enterprise Payment Account, Permit number or PC Postage meter number associated with a contract.

Returns:

  • (String)


114
115
116
# File 'lib/usps_api/models/international_base_rates_query.rb', line 114

def 
  @account_number
end

#account_typeAccountType1

The type of payment account linked to a contract rate. Note:

  • ‘METER` pricing is only available to PC Postage providers.

Returns:



109
110
111
# File 'lib/usps_api/models/international_base_rates_query.rb', line 109

def 
  @account_type
end

#destination_country_codeString

The ISO 3166-1 alpha-2 code representing the shipping destination.

Returns:

  • (String)


103
104
105
# File 'lib/usps_api/models/international_base_rates_query.rb', line 103

def destination_country_code
  @destination_country_code
end

#destination_entry_facility_typeDestinationEntryFacilityType2

Types of Facilities

* NONE - Translate to Destination Rate Indicator N
* INTERNATIONAL_SERVICE_CENTER - Translate to Destination Rate Indicator

I



80
81
82
# File 'lib/usps_api/models/international_base_rates_query.rb', line 80

def destination_entry_facility_type
  @destination_entry_facility_type
end

#foreign_postal_codeString

The foreign postal code for the package. Note:

  • 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

Returns:

  • (String)


99
100
101
# File 'lib/usps_api/models/international_base_rates_query.rb', line 99

def foreign_postal_code
  @foreign_postal_code
end

#heightFloat

The package height in inches.

Returns:

  • (Float)


33
34
35
# File 'lib/usps_api/models/international_base_rates_query.rb', line 33

def height
  @height
end

#lengthFloat

The package length in inches. The maximum dimension is always length.

Returns:

  • (Float)


24
25
26
# File 'lib/usps_api/models/international_base_rates_query.rb', line 24

def length
  @length
end

#mail_classMailClass4

The mail service requested.

* 'FIRST-CLASS_PACKAGE_INTERNATIONAL_SERVICE'
* 'PRIORITY_MAIL_INTERNATIONAL'
* 'PRIORITY_MAIL_EXPRESS_INTERNATIONAL'
* 'GLOBAL_EXPRESS_GUARANTEED' - Global Express Guaranteed Service is

suspended as of September 29, 2024.

Returns:



42
43
44
# File 'lib/usps_api/models/international_base_rates_query.rb', line 42

def mail_class
  @mail_class
end

#mailing_dateDate

The date the package or letter/flat will be mailed. The mailing date may be today plus 0 to 7 days in advance.

Returns:

  • (Date)


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

def mailing_date
  @mailing_date
end

#origin_zip_codeString

The originating ZIP Code for the package.

Returns:

  • (String)


14
15
16
# File 'lib/usps_api/models/international_base_rates_query.rb', line 14

def origin_zip_code
  @origin_zip_code
end

#price_typeInternationalPriceType

Price type can be * ‘RETAIL’ * ‘COMMERCIAL’ * ‘COMMERCIAL_BASE’ * ‘COMMERCIAL_PLUS’ * ‘CONTRACT’



85
86
87
# File 'lib/usps_api/models/international_base_rates_query.rb', line 85

def price_type
  @price_type
end

#processing_categoryProcessingCategory5

Value designates if shipment is ‘MACHINABLE`, `NONSTANDARD, or `FLATS`. Note:

  • ‘NON_MACHINABLE` is deprecated and will convert to `NONSTANDARD` as of

01/19/2025.

Returns:



49
50
51
# File 'lib/usps_api/models/international_base_rates_query.rb', line 49

def processing_category
  @processing_category
end

#rate_indicatorRateIndicator2

Use to specify USPS® containers/packaging or container attributes that may affect postage.

* E4 - Priority Mail Express Flat Rate Envelope - Post Office To

Addressee

* E6 - Priority Mail Express Legal Flat Rate Envelope
* FA - Legal Flat Rate Envelope
* FB - Medium Flat Rate Box/Large Flat Rate Bag
* FE - Flat Rate Envelope
* FP - Padded Flat Rate Envelope
* FS - Small Flat Rate Box
* PA - Priority Mail Express International Single Piece
* PL - Large Flat Rate Box
* SP - Single Piece
* EP - ECOMPRO Single Piece
* HA - ECOMPRO Legal Flat Rate Envelope
* HB - ECOMPRO Medium Flat Rate Box
* HE - ECOMPRO Flat Rate Envelope
* HL - ECOMPRO Large Flat Rate Box
* HP - ECOMPRO Padded Flat Rate Envelope
* HS - ECOMPRO Small Flat Rate Box
* LE - Single-piece parcel

Returns:



73
74
75
# File 'lib/usps_api/models/international_base_rates_query.rb', line 73

def rate_indicator
  @rate_indicator
end

#weightFloat

The calculated weight for the package based on user input. The greater of dimWeight and weight will be used to calculated the rate. Weight unit of measurement is in pounds.

Returns:

  • (Float)


20
21
22
# File 'lib/usps_api/models/international_base_rates_query.rb', line 20

def weight
  @weight
end

#widthFloat

The package width in inches. The second longest dimension is always width.

Returns:

  • (Float)


29
30
31
# File 'lib/usps_api/models/international_base_rates_query.rb', line 29

def width
  @width
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
211
212
213
214
215
216
217
# File 'lib/usps_api/models/international_base_rates_query.rb', line 177

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  origin_zip_code = hash.key?('originZIPCode') ? hash['originZIPCode'] : nil
  weight = hash.key?('weight') ? hash['weight'] : nil
  length = hash.key?('length') ? hash['length'] : nil
  width = hash.key?('width') ? hash['width'] : nil
  height = hash.key?('height') ? hash['height'] : nil
  mail_class = hash.key?('mailClass') ? hash['mailClass'] : nil
  processing_category =
    hash.key?('processingCategory') ? hash['processingCategory'] : nil
  rate_indicator = hash.key?('rateIndicator') ? hash['rateIndicator'] : nil
  destination_entry_facility_type =
    hash.key?('destinationEntryFacilityType') ? hash['destinationEntryFacilityType'] : nil
  price_type = hash.key?('priceType') ? hash['priceType'] : nil
  destination_country_code =
    hash.key?('destinationCountryCode') ? hash['destinationCountryCode'] : nil
  mailing_date = hash.key?('mailingDate') ? hash['mailingDate'] : SKIP
  foreign_postal_code =
    hash.key?('foreignPostalCode') ? hash['foreignPostalCode'] : SKIP
   = hash.key?('accountType') ? hash['accountType'] : SKIP
   = hash.key?('accountNumber') ? hash['accountNumber'] : SKIP

  # Create object from extracted values.
  InternationalBaseRatesQuery.new(origin_zip_code: origin_zip_code,
                                  weight: weight,
                                  length: length,
                                  width: width,
                                  height: height,
                                  mail_class: mail_class,
                                  processing_category: processing_category,
                                  rate_indicator: rate_indicator,
                                  destination_entry_facility_type: destination_entry_facility_type,
                                  price_type: price_type,
                                  destination_country_code: destination_country_code,
                                  mailing_date: mailing_date,
                                  foreign_postal_code: foreign_postal_code,
                                  account_type: ,
                                  account_number: )
end

.namesObject

A mapping from model property names to API property names.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/usps_api/models/international_base_rates_query.rb', line 117

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['origin_zip_code'] = 'originZIPCode'
  @_hash['weight'] = 'weight'
  @_hash['length'] = 'length'
  @_hash['width'] = 'width'
  @_hash['height'] = 'height'
  @_hash['mail_class'] = 'mailClass'
  @_hash['processing_category'] = 'processingCategory'
  @_hash['rate_indicator'] = 'rateIndicator'
  @_hash['destination_entry_facility_type'] =
    'destinationEntryFacilityType'
  @_hash['price_type'] = 'priceType'
  @_hash['mailing_date'] = 'mailingDate'
  @_hash['foreign_postal_code'] = 'foreignPostalCode'
  @_hash['destination_country_code'] = 'destinationCountryCode'
  @_hash['account_type'] = 'accountType'
  @_hash['account_number'] = 'accountNumber'
  @_hash
end

.nullablesObject

An array for nullable fields



149
150
151
# File 'lib/usps_api/models/international_base_rates_query.rb', line 149

def self.nullables
  []
end

.optionalsObject

An array for optional fields



139
140
141
142
143
144
145
146
# File 'lib/usps_api/models/international_base_rates_query.rb', line 139

def self.optionals
  %w[
    mailing_date
    foreign_postal_code
    account_type
    account_number
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/usps_api/models/international_base_rates_query.rb', line 232

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} origin_zip_code: #{@origin_zip_code.inspect}, weight: #{@weight.inspect},"\
  " length: #{@length.inspect}, width: #{@width.inspect}, height: #{@height.inspect},"\
  " mail_class: #{@mail_class.inspect}, processing_category: #{@processing_category.inspect},"\
  " rate_indicator: #{@rate_indicator.inspect}, destination_entry_facility_type:"\
  " #{@destination_entry_facility_type.inspect}, price_type: #{@price_type.inspect},"\
  " mailing_date: #{@mailing_date.inspect}, foreign_postal_code:"\
  " #{@foreign_postal_code.inspect}, destination_country_code:"\
  " #{@destination_country_code.inspect}, account_type: #{@account_type.inspect},"\
  " account_number: #{@account_number.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} origin_zip_code: #{@origin_zip_code}, weight: #{@weight}, length:"\
  " #{@length}, width: #{@width}, height: #{@height}, mail_class: #{@mail_class},"\
  " processing_category: #{@processing_category}, rate_indicator: #{@rate_indicator},"\
  " destination_entry_facility_type: #{@destination_entry_facility_type}, price_type:"\
  " #{@price_type}, mailing_date: #{@mailing_date}, foreign_postal_code:"\
  " #{@foreign_postal_code}, destination_country_code: #{@destination_country_code},"\
  " account_type: #{@account_type}, account_number: #{@account_number}>"
end