Class: UspsApi::BaseRatesQuery
- Defined in:
- lib/usps_api/models/base_rates_query.rb
Overview
Package rate ingredients used to calculate base prices.
Instance Attribute Summary collapse
-
#account_number ⇒ String
The Enterprise Payment Account, Permit number, PC Postage meter number, or Mailer ID associated with a contract.
-
#account_type ⇒ AccountType
The type of payment account linked to a contract rate.
-
#destination_entry_facility_type ⇒ DestinationEntryFacilityType1
Types of Facilities: * ‘NONE` - Translate to Destination Rate Indicator N * `DESTINATION_NETWORK_DISTRIBUTION_CENTER` - Translate to Destination Rate Indicator B * `DESTINATION_SECTIONAL_CENTER_FACILITY` - Translate to Destination Rate Indicator S * `DESTINATION_DELIVERY_UNIT` - Translate to Destination Rate Indicator D * `DESTINATION_SERVICE_HUB` - Translate to Destination Rate Indicator H * `DESTINATION_REGIONAL_PROCESSING_DISTRIBUTION_CENTER` - Translate to Destination Rate Indicator B Note: * Effective 01/18/2026: `DESTINATION_NETWORK_DISTRIBUTION_CENTER` with `PARCEL_SELECT` is no longer eligible.
-
#destination_zip_code ⇒ String
This is destination ZIP Code™ for the package.
-
#has_nonstandard_characteristics ⇒ TrueClass | FalseClass
Package is nonstandard.
-
#height ⇒ Float
This is the package height in inches.
-
#length ⇒ Float
This is the package length in inches.
-
#mail_class ⇒ PricesMailClass
The mail service requested.
-
#mailing_date ⇒ Date
The date the package or letter/flat/card will be mailed.
-
#origin_zip_code ⇒ String
This is the originating ZIP Code™ for the package.
-
#price_type ⇒ PricesPriceType
Price type can be * ‘RETAIL’ * ‘COMMERCIAL’ * ‘CONTRACT’ * ‘NSA’ (deprecated).
-
#processing_category ⇒ ProcessingCategory3
USPS categorizes parcels into one of two mail processing categories: MACHINABLE or NONSTANDARD.
-
#rate_indicator ⇒ RateIndicator
Rate ingredient to determine pricing categorization for calculating the price * 3D - 3-Digit * 3N - 3-Digit Dimensional Rectangular * 3R - 3-Digit Dimensional Nonrectangular * 5D - 5-Digit * BA - Basic * BB - Mixed NDC * BM - NDC * C1 - Cubic Pricing Tier 1 * C2 - Cubic Pricing Tier 2 * C3 - Cubic Pricing Tier 3 * C4 - Cubic Pricing Tier 4 * C5 - Cubic Pricing Tier 5 * CP - Cubic Parcel * CM - USPS Connect Local® Mail * DC - NDC * DE - SCF * DF - 5-Digit * DN - Dimensional Nonrectangular * DR - Dimensional Rectangular * E4 - Priority Mail Express Flat Rate Envelope - Post Office To Addressee * E6 - Priority Mail Express Legal Flat Rate Envelope * E7 - Priority Mail Express Legal Flat Rate Envelope Sunday / Holiday * 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 * LC - USPS Connect® Local Single Piece * LF - USPS Connect® Local Flat Rate Box * LL - USPS Connect® Local Large Flat Rate Bag * LO - USPS Connect® Local Oversized * LS - USPS Connect® Local Small Flat Rate Bag * NP - Non-Presorted * O1 - Full Tray Box * O2 - Half Tray Box * O3 - EMM Tray Box * O4 - Flat Tub Tray Box * O5 - Surface Transported Pallet * O6 - Full Pallet Box * O7 - Half Pallet Box * OS - Oversized * P5 - Cubic Soft Pack Tier 1 * P6 - Cubic Soft Pack Tier 2 * P7 - Cubic Soft Pack Tier 3 * P8 - Cubic Soft Pack Tier 4 * P9 - Cubic Soft Pack Tier 5 * Q6 - Cubic Soft Pack Tier 6 * Q7 - Cubic Soft Pack Tier 7 * Q8 - Cubic Soft Pack Tier 8 * Q9 - Cubic Soft Pack Tier 9 * Q0 - Cubic Soft Pack Tier 10 * PA - Priority Mail Express Single Piece * PL - Large Flat Rate Box * PM - Large Flat Rate Box APO/FPO/DPO * PR - Presorted * SB - Small Flat Rate Bag * SN - SCF Dimensional Nonrectangular * SP - Single Piece * SR - SCF Dimensional Rectangular.
-
#weight ⇒ Float
This is the calculated weight for the package based on user input.
-
#width ⇒ Float
This is the package width in inches.
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(origin_zip_code:, destination_zip_code:, weight:, length:, width:, height:, mail_class:, processing_category:, rate_indicator:, destination_entry_facility_type:, price_type:, mailing_date: SKIP, account_type: SKIP, account_number: SKIP, has_nonstandard_characteristics: false) ⇒ BaseRatesQuery
constructor
A new instance of BaseRatesQuery.
-
#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(origin_zip_code:, destination_zip_code:, weight:, length:, width:, height:, mail_class:, processing_category:, rate_indicator:, destination_entry_facility_type:, price_type:, mailing_date: SKIP, account_type: SKIP, account_number: SKIP, has_nonstandard_characteristics: false) ⇒ BaseRatesQuery
Returns a new instance of BaseRatesQuery.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/usps_api/models/base_rates_query.rb', line 271 def initialize(origin_zip_code:, destination_zip_code:, weight:, length:, width:, height:, mail_class:, processing_category:, rate_indicator:, destination_entry_facility_type:, price_type:, mailing_date: SKIP, account_type: SKIP, account_number: SKIP, has_nonstandard_characteristics: false) @origin_zip_code = origin_zip_code @destination_zip_code = destination_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 @account_type = account_type unless account_type == SKIP @account_number = account_number unless account_number == SKIP unless has_nonstandard_characteristics == SKIP @has_nonstandard_characteristics = has_nonstandard_characteristics end end |
Instance Attribute Details
#account_number ⇒ String
The Enterprise Payment Account, Permit number, PC Postage meter number, or Mailer ID associated with a contract.
223 224 225 |
# File 'lib/usps_api/models/base_rates_query.rb', line 223 def account_number @account_number end |
#account_type ⇒ AccountType
The type of payment account linked to a contract rate. Note:
-
‘METER` pricing is only available to PC Postage providers.
-
‘MID` pricing is only available for return mail classes.
218 219 220 |
# File 'lib/usps_api/models/base_rates_query.rb', line 218 def account_type @account_type end |
#destination_entry_facility_type ⇒ DestinationEntryFacilityType1
Types of Facilities:
-
‘NONE` - Translate to Destination Rate Indicator N
-
‘DESTINATION_NETWORK_DISTRIBUTION_CENTER` - Translate to Destination
Rate Indicator B
-
‘DESTINATION_SECTIONAL_CENTER_FACILITY` - Translate to Destination Rate
Indicator S
-
‘DESTINATION_DELIVERY_UNIT` - Translate to Destination Rate Indicator D
-
‘DESTINATION_SERVICE_HUB` - Translate to Destination Rate Indicator H
-
‘DESTINATION_REGIONAL_PROCESSING_DISTRIBUTION_CENTER` - Translate to
Destination Rate Indicator B Note:
-
Effective 01/18/2026: ‘DESTINATION_NETWORK_DISTRIBUTION_CENTER` with
‘PARCEL_SELECT` is no longer eligible.
-
Effective 01/18/2026: (NSA Only)
‘DESTINATION_REGIONAL_PROCESSING_DISTRIBUTION_CENTER` with `PARCEL_SELECT` is available as an option.
199 200 201 |
# File 'lib/usps_api/models/base_rates_query.rb', line 199 def destination_entry_facility_type @destination_entry_facility_type end |
#destination_zip_code ⇒ String
This is destination ZIP Code™ for the package.
18 19 20 |
# File 'lib/usps_api/models/base_rates_query.rb', line 18 def destination_zip_code @destination_zip_code end |
#has_nonstandard_characteristics ⇒ TrueClass | FalseClass
Package is nonstandard. Nonstandard packages include cylindrical tubes and rolls, certain high-density items, cartons containing more than 24 ounces of liquids in one or more glass containers, cartons containing 1 gallon or more of liquid in metal or plastic containers, and items in [201.7.6.2](pe.usps.com/text/dmm300/201.htm#7.6.2).
231 232 233 |
# File 'lib/usps_api/models/base_rates_query.rb', line 231 def has_nonstandard_characteristics @has_nonstandard_characteristics end |
#height ⇒ Float
This is the package height in inches.
38 39 40 |
# File 'lib/usps_api/models/base_rates_query.rb', line 38 def height @height end |
#length ⇒ Float
This is the package length in inches. The maximum dimension is always length.
29 30 31 |
# File 'lib/usps_api/models/base_rates_query.rb', line 29 def length @length end |
#mail_class ⇒ PricesMailClass
The mail service requested. Note:
-
‘PARCEL_SELECT_LIGHTWEIGHT` is deprecated and will convert to
‘PARCEL_SELECT`.
-
‘FIRST-CLASS_PACKAGE_SERVICE` is deprecated and will convert to
‘USPS_GROUND_ADVANTAGE`.
-
‘FIRST-CLASS_PACKAGE_RETURN_SERVICE` is deprecated and will convert to
‘USPS_GROUND_ADVANTAGE_RETURN_SERVICE`.
-
‘GROUND_RETURN_SERVICE` is deprecated and will convert to
‘USPS_GROUND_ADVANTAGE_RETURN_SERVICE`.
-
‘USPS_RETAIL_GROUND` is no longer supported and will return a 400 if
used.
-
Certain mail classes, such as ‘MEDIA_MAIL`, `BOUND_PRINTED_MATTER`, and
‘LIBRARY_MAIL`, have eligibility rules on what can be mailed using that service. For more details on these mail classes, please visit [What are Package Services?](faq.usps.com/s/article/What-are-Package-Services).
58 59 60 |
# File 'lib/usps_api/models/base_rates_query.rb', line 58 def mail_class @mail_class end |
#mailing_date ⇒ Date
The date the package or letter/flat/card will be mailed. The mailing date may be today plus 0 to 7 days in advance. Enter the date in the full-date notation as defined by [RFC 3339, section 5.6](datatracker.ietf.org/doc/html/rfc3339#section-5.6).
211 212 213 |
# File 'lib/usps_api/models/base_rates_query.rb', line 211 def mailing_date @mailing_date end |
#origin_zip_code ⇒ String
This is the originating ZIP Code™ for the package.
14 15 16 |
# File 'lib/usps_api/models/base_rates_query.rb', line 14 def origin_zip_code @origin_zip_code end |
#price_type ⇒ PricesPriceType
Price type can be * ‘RETAIL’ * ‘COMMERCIAL’ * ‘CONTRACT’ * ‘NSA’ (deprecated)
204 205 206 |
# File 'lib/usps_api/models/base_rates_query.rb', line 204 def price_type @price_type end |
#processing_category ⇒ ProcessingCategory3
USPS categorizes parcels into one of two mail processing categories: MACHINABLE or NONSTANDARD. These categories are based on the physical dimensions of the piece, regardless of the placement (orientation) of the delivery address on the piece. For more information see [Domestic Mail Manual (DMM)](pe.usps.com/DMM300/201.htm). Machinable letter-size mail is:
-
Not less than 5 inches long, 3-1/2 inches high, and 0.007-inch thick.
For pieces more than 4-1/4 inches high or 6 inches long, or both, the minimum thickness is 0.009.(Pieces not meeting the 0.009 thickness are non-machinable letters under 2.1.)
-
Not more than 11-1/2 inches long, or more than 6-1/8 inches high, or
greater than 1/4-inch thick.
-
Rectangular, with four square corners and parallel opposite sides.
Letter-size, card-type mailpieces made of cardstock may have finished corners that do not exceed a radius of 0.125 inch (1/8 inch) unless prepared as Customized Market Mail under 243.9.0. See Exhibit 1.1.1.
-
Within an aspect ratio (length divided by height) of 1.3 to 2.5,
inclusive.
-
Subject to additional dimensional restrictions in 3.0, depending on
mailpiece design. Flat-size mail must have the following characteristics:
-
Be more than 11-1/2 inches long, or more than 6-1/8 inches high, or more
than 1/4 inch thick, other than automation flats under 6.0 or as allowed for USPS® Marketing Mail pieces with simplified addresses under 5.2.2. Mailpieces other than automation flats or USPS® Marketing Mail pieces with simplified addresses that are 1/4 inch thick or less must be at least 3-1/2 inches high and at least 5 inches long and be at least 0.007 inch thick.
-
Be not more than 15 inches long or more than 12 inches high or more than
3/4 inch thick, except for:
-
Periodicals non-machinable flat-size pieces mailed as specified in
207.26.0. They must not be more than 1–1/4 inches thick.
-
Polywrapped flats, with selvage that extends beyond the contents, up to
a maximum length of 15-3/4 inches or a maximum height of 12-1/2 inches. The enclosed contents must not be longer than 15 inches or higher than 12 inches.
-
Co-mailed polywrapped flats mailed as specified in Customer Support
Ruling PS-346, with selvage that extends beyond the contents, up to a maximum height of 12-7/8 inches. The enclosed contents must not be higher than 12 inches.
-
Be rectangular with four square corners or with finished corners that do
not exceed a radius of 0.125 inch (1/8 inch) unless prepared as Customized Market Mail under 9.0.
-
Be categorized as a catalog.
-
Other size or weight standards may apply to mail addressed to certain
APOs and FPOs, and mail sent by the Department of State to U.S. government personnel abroad. Note:
-
‘IRREGULAR` is deprecated and will convert to `NONSTANDARD` as of
01/19/2025.
-
‘NON_MACHINABLE` is deprecated and will convert to `NONSTANDARD` as of
01/19/2025.
115 116 117 |
# File 'lib/usps_api/models/base_rates_query.rb', line 115 def processing_category @processing_category end |
#rate_indicator ⇒ RateIndicator
Rate ingredient to determine pricing categorization for calculating the price
* 3D - 3-Digit
* 3N - 3-Digit Dimensional Rectangular
* 3R - 3-Digit Dimensional Nonrectangular
* 5D - 5-Digit
* BA - Basic
* BB - Mixed NDC
* BM - NDC
* C1 - Cubic Pricing Tier 1
* C2 - Cubic Pricing Tier 2
* C3 - Cubic Pricing Tier 3
* C4 - Cubic Pricing Tier 4
* C5 - Cubic Pricing Tier 5
* CP - Cubic Parcel
* CM - USPS Connect Local® Mail
* DC - NDC
* DE - SCF
* DF - 5-Digit
* DN - Dimensional Nonrectangular
* DR - Dimensional Rectangular
* E4 - Priority Mail Express Flat Rate Envelope - Post Office To
Addressee
* E6 - Priority Mail Express Legal Flat Rate Envelope
* E7 - Priority Mail Express Legal Flat Rate Envelope Sunday / Holiday
* 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
* LC - USPS Connect® Local Single Piece
* LF - USPS Connect® Local Flat Rate Box
* LL - USPS Connect® Local Large Flat Rate Bag
* LO - USPS Connect® Local Oversized
* LS - USPS Connect® Local Small Flat Rate Bag
* NP - Non-Presorted
* O1 - Full Tray Box
* O2 - Half Tray Box
* O3 - EMM Tray Box
* O4 - Flat Tub Tray Box
* O5 - Surface Transported Pallet
* O6 - Full Pallet Box
* O7 - Half Pallet Box
* OS - Oversized
* P5 - Cubic Soft Pack Tier 1
* P6 - Cubic Soft Pack Tier 2
* P7 - Cubic Soft Pack Tier 3
* P8 - Cubic Soft Pack Tier 4
* P9 - Cubic Soft Pack Tier 5
* Q6 - Cubic Soft Pack Tier 6
* Q7 - Cubic Soft Pack Tier 7
* Q8 - Cubic Soft Pack Tier 8
* Q9 - Cubic Soft Pack Tier 9
* Q0 - Cubic Soft Pack Tier 10
* PA - Priority Mail Express Single Piece
* PL - Large Flat Rate Box
* PM - Large Flat Rate Box APO/FPO/DPO
* PR - Presorted
* SB - Small Flat Rate Bag
* SN - SCF Dimensional Nonrectangular
* SP - Single Piece
* SR - SCF Dimensional Rectangular
180 181 182 |
# File 'lib/usps_api/models/base_rates_query.rb', line 180 def rate_indicator @rate_indicator end |
#weight ⇒ Float
This is 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.
24 25 26 |
# File 'lib/usps_api/models/base_rates_query.rb', line 24 def weight @weight end |
#width ⇒ Float
This is the package width in inches. The second longest dimension is always width.
34 35 36 |
# File 'lib/usps_api/models/base_rates_query.rb', line 34 def width @width end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/usps_api/models/base_rates_query.rb', line 297 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. origin_zip_code = hash.key?('originZIPCode') ? hash['originZIPCode'] : nil destination_zip_code = hash.key?('destinationZIPCode') ? hash['destinationZIPCode'] : 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 mailing_date = hash.key?('mailingDate') ? hash['mailingDate'] : SKIP account_type = hash.key?('accountType') ? hash['accountType'] : SKIP account_number = hash.key?('accountNumber') ? hash['accountNumber'] : SKIP has_nonstandard_characteristics = hash['hasNonstandardCharacteristics'] ||= false # Create object from extracted values. BaseRatesQuery.new(origin_zip_code: origin_zip_code, destination_zip_code: destination_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, account_type: account_type, account_number: account_number, has_nonstandard_characteristics: has_nonstandard_characteristics) end |
.names ⇒ Object
A mapping from model property names to API property names.
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/usps_api/models/base_rates_query.rb', line 234 def self.names @_hash = {} if @_hash.nil? @_hash['origin_zip_code'] = 'originZIPCode' @_hash['destination_zip_code'] = 'destinationZIPCode' @_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['account_type'] = 'accountType' @_hash['account_number'] = 'accountNumber' @_hash['has_nonstandard_characteristics'] = 'hasNonstandardCharacteristics' @_hash end |
.nullables ⇒ Object
An array for nullable fields
267 268 269 |
# File 'lib/usps_api/models/base_rates_query.rb', line 267 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
257 258 259 260 261 262 263 264 |
# File 'lib/usps_api/models/base_rates_query.rb', line 257 def self.optionals %w[ mailing_date account_type account_number has_nonstandard_characteristics ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/usps_api/models/base_rates_query.rb', line 353 def inspect class_name = self.class.name.split('::').last "<#{class_name} origin_zip_code: #{@origin_zip_code.inspect}, destination_zip_code:"\ " #{@destination_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}, account_type: #{@account_type.inspect},"\ " account_number: #{@account_number.inspect}, has_nonstandard_characteristics:"\ " #{@has_nonstandard_characteristics.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/usps_api/models/base_rates_query.rb', line 340 def to_s class_name = self.class.name.split('::').last "<#{class_name} origin_zip_code: #{@origin_zip_code}, destination_zip_code:"\ " #{@destination_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}, account_type: #{@account_type},"\ " account_number: #{@account_number}, has_nonstandard_characteristics:"\ " #{@has_nonstandard_characteristics}>" end |