Class: UspsApi::PricesTotalRatesQuery
- Defined in:
- lib/usps_api/models/prices_total_rates_query.rb
Overview
Search parameters for base rate and extra service rate.
Instance Attribute Summary collapse
-
#account_number ⇒ String
The Enterprise Payment Account, Permit number or PC Postage meter number associated with a contract.
-
#account_type ⇒ AccountType1
The type of payment account linked to a contract rate.
-
#destination_zip_code ⇒ String
The destination ZIP code for the package.
-
#extra_services ⇒ Array[ExtraService1]
Extra Service Codes requested.
-
#has_nonstandard_characteristics ⇒ TrueClass | FalseClass
Package is nonstandard.
-
#height ⇒ Float
This is the package height in inches.
-
#item_value ⇒ Float
The value of the item.
-
#length ⇒ Float
This is the package length in inches.
-
#mail_class ⇒ MailClassOutboundOnly
The mail service requested.
-
#mail_classes ⇒ Array[MailClassOutboundOnly]
A list of mail classes.
-
#mailing_date ⇒ Date
The date the package or letter/flat/card will be mailed.
-
#origin_zip_code ⇒ String
The originating ZIP code for the package.
-
#price_type ⇒ PricesPriceType
Price type can be * ‘RETAIL’ * ‘COMMERCIAL’ * ‘CONTRACT’ * ‘NSA’ (deprecated).
-
#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: SKIP, mail_classes: SKIP, price_type: SKIP, mailing_date: SKIP, account_type: SKIP, account_number: SKIP, has_nonstandard_characteristics: false, item_value: SKIP, extra_services: SKIP) ⇒ PricesTotalRatesQuery
constructor
A new instance of PricesTotalRatesQuery.
-
#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: SKIP, mail_classes: SKIP, price_type: SKIP, mailing_date: SKIP, account_type: SKIP, account_number: SKIP, has_nonstandard_characteristics: false, item_value: SKIP, extra_services: SKIP) ⇒ PricesTotalRatesQuery
Returns a new instance of PricesTotalRatesQuery.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 220 def initialize(origin_zip_code:, destination_zip_code:, weight:, length:, width:, height:, mail_class: SKIP, mail_classes: SKIP, price_type: SKIP, mailing_date: SKIP, account_type: SKIP, account_number: SKIP, has_nonstandard_characteristics: false, item_value: SKIP, extra_services: SKIP) @origin_zip_code = origin_zip_code @destination_zip_code = destination_zip_code @weight = weight @length = length @width = width @height = height @mail_class = mail_class unless mail_class == SKIP @mail_classes = mail_classes unless mail_classes == SKIP @price_type = price_type unless price_type == SKIP @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 @item_value = item_value unless item_value == SKIP @extra_services = extra_services unless extra_services == SKIP end |
Instance Attribute Details
#account_number ⇒ String
The Enterprise Payment Account, Permit number or PC Postage meter number associated with a contract.
89 90 91 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 89 def account_number @account_number end |
#account_type ⇒ AccountType1
The type of payment account linked to a contract rate.
84 85 86 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 84 def account_type @account_type end |
#destination_zip_code ⇒ String
The destination ZIP code for the package.
18 19 20 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 18 def destination_zip_code @destination_zip_code end |
#extra_services ⇒ Array[ExtraService1]
Extra Service Codes requested. If omitted, all available extra services will be returned. To narrow the results, provide a specific set of extra service codes. For convenience, use ‘986` for `PRIORITY_MAIL_EXPRESS` or `920` for all other `mailClasses`.
-
415 - USPS Label Delivery
-
480 - Tracking Plus 6 Months
-
481 - Tracking Plus 1 Year
-
482 - Tracking Plus 3 Years
-
483 - Tracking Plus 5 Years
-
484 - Tracking Plus 7 Years
-
485 - Tracking Plus 10 Years
-
486 - Tracking Plus Signature 3 Years
-
487 - Tracking Plus Signature 5 Years
-
488 - Tracking Plus Signature 7 Years
-
489 - Tracking Plus Signature 10 Years
-
498 - PO Box Locker – Stocking Fee (NSA Only)
-
500 - PO Box Locker – Self-Service Pickup Fee (NSA Only)
-
501 - PO Box Locker – Clerk-Assisted Pickup Fee (NSA Only)
-
502 - PO Box Locker – Local Delivery Fee (NSA Only)
-
810 - HAZMAT Air Eligible Ethanol Package
-
811 - HAZMAT Class 1 - Toy Propellant/Safety Fuse Package
-
812 - HAZMAT Class 3 – Flammable Liquid Package
-
813 - HAZMAT Class 7 - Radioactive Materials Package
-
814 - HAZMAT Class 8 - Corrosive Materials Package
-
815 - HAZMAT Class 8 - Nonspillable Wet Battery Package
-
816 - HAZMAT Class 9 - Lithium Battery Marked - Ground Only Package
-
817 - HAZMAT Class 9 - Lithium Battery - Returns Package
-
818 - HAZMAT Class 9 - Lithium batteries, marked package
-
819 - HAZMAT Class 9 - Dry Ice Package
-
820 - HAZMAT Class 9 - Lithium batteries, unmarked package
-
821 - HAZMAT Class 9 - Magnetized Materials Package
-
822 - HAZMAT Division 4.1 – Flammable Solids or Safety Matches Package
-
823 - HAZMAT Division 5.1 - Oxidizers Package
-
824 - HAZMAT Division 5.2 - Organic Peroxides Package
-
825 - HAZMAT Division 6.1 – Toxic Materials Package
-
826 - HAZMAT Division 6.2 – Infectious Substances Package
-
827 - HAZMAT Excepted Quantity Provision Package
-
828 - HAZMAT Ground Only
-
829 - HAZMAT ID8000 Consumer Commodity Package
-
830 - HAZMAT Lighters Package
-
831 - HAZMAT LTD QTY Ground Package
-
832 - HAZMAT Small Quantity Provision Package
-
853 - Perishable Material
-
856 - Live Animals Transportation Fee
-
857 - Hazardous Material
-
858 - Cremated Remains
-
910 - Certified Mail
-
911 - Certified Mail Restricted Delivery
-
912 - Certified Mail Adult Signature Required
-
913 - Certified Mail Adult Signature Restricted Delivery
-
915 - Collect on Delivery (COD)
-
917 - COD Restricted Delivery
-
920 - USPS Tracking
-
921 - Signature Confirmation
-
922 - Adult Signature Required 21 or Over
-
923 - Adult Signature Restricted Delivery 21 or Over
-
924 - Signature Confirmation Restricted Delivery
-
925 - Priority Mail Express Merchandise Insurance
-
930 - Insurance <= $500
-
931 - Insurance > $500
-
934 - Insurance Restricted Delivery
-
940 - Registered Mail
-
941 - Registered Mail Restricted Delivery
-
955 - Return Receipt
-
957 - Return Receipt Electronic
-
972 - Live Animal and Perishable Handling Fee
-
981 - Signature Requested (PRIORITY_MAIL_EXPRESS only)
-
984 - Parcel Locker Delivery
-
986 - PO to Addressee (PRIORITY_MAIL_EXPRESS only)
-
991 - Sunday Delivery
176 177 178 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 176 def extra_services @extra_services 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).
97 98 99 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 97 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/prices_total_rates_query.rb', line 38 def height @height end |
#item_value ⇒ Float
The value of the item. Required for Insurance and Collect On Delivery. The price for Insurance, Registered Mail, and Collect On Delivery extra services will vary based on this value.
103 104 105 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 103 def item_value @item_value end |
#length ⇒ Float
This is the package length in inches. The maximum dimension is always length.
29 30 31 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 29 def length @length end |
#mail_class ⇒ MailClassOutboundOnly
The mail service requested.
Note:
- A single mail class option is deprecated and will be removed in the
next major revision. This attribute will be replaced with the list of mail classes.
- `PARCEL_SELECT_LIGHTWEIGHT` is deprecated and will convert to
‘PARCEL_SELECT`
- `FIRST-CLASS_PACKAGE_SERVICE` is deprecated and will convert to
‘USPS_GROUND_ADVANTAGE`
- `USPS_RETAIL_GROUND` is no longer supported and will return a 400 if
used
52 53 54 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 52 def mail_class @mail_class end |
#mail_classes ⇒ Array[MailClassOutboundOnly]
A list of mail classes. 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`.
-
‘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).
68 69 70 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 68 def mail_classes @mail_classes 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).
80 81 82 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 80 def mailing_date @mailing_date end |
#origin_zip_code ⇒ String
The originating ZIP code for the package.
14 15 16 |
# File 'lib/usps_api/models/prices_total_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)
73 74 75 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 73 def price_type @price_type 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/prices_total_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/prices_total_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.
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 246 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'] : SKIP mail_classes = hash.key?('mailClasses') ? hash['mailClasses'] : SKIP price_type = hash.key?('priceType') ? hash['priceType'] : SKIP 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 item_value = hash.key?('itemValue') ? hash['itemValue'] : SKIP extra_services = hash.key?('extraServices') ? hash['extraServices'] : SKIP # Create object from extracted values. PricesTotalRatesQuery.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, mail_classes: mail_classes, price_type: price_type, mailing_date: mailing_date, account_type: account_type, account_number: account_number, has_nonstandard_characteristics: has_nonstandard_characteristics, item_value: item_value, extra_services: extra_services) end |
.names ⇒ Object
A mapping from model property names to API property names.
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 179 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['mail_classes'] = 'mailClasses' @_hash['price_type'] = 'priceType' @_hash['mailing_date'] = 'mailingDate' @_hash['account_type'] = 'accountType' @_hash['account_number'] = 'accountNumber' @_hash['has_nonstandard_characteristics'] = 'hasNonstandardCharacteristics' @_hash['item_value'] = 'itemValue' @_hash['extra_services'] = 'extraServices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
216 217 218 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 216 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 201 def self.optionals %w[ mail_class mail_classes price_type mailing_date account_type account_number has_nonstandard_characteristics item_value extra_services ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 299 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},"\ " mail_classes: #{@mail_classes.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}, item_value: #{@item_value.inspect},"\ " extra_services: #{@extra_services.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
287 288 289 290 291 292 293 294 295 296 |
# File 'lib/usps_api/models/prices_total_rates_query.rb', line 287 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}, mail_classes: #{@mail_classes},"\ " price_type: #{@price_type}, mailing_date: #{@mailing_date}, account_type:"\ " #{@account_type}, account_number: #{@account_number}, has_nonstandard_characteristics:"\ " #{@has_nonstandard_characteristics}, item_value: #{@item_value}, extra_services:"\ " #{@extra_services}>" end |