Class: UspsApi::Rate
- Defined in:
- lib/usps_api/models/rate.rb
Overview
Rate Model.
Instance Attribute Summary collapse
-
#description ⇒ String
The description of the price.
-
#destination_entry_facility_type ⇒ DestinationEntryFacilityType5
Destination Entry Facility type for the provided rate, this value can be used in the labels API to ensure the provided rate is applied.
-
#dim_weight ⇒ Float
The dimensional weight of the package, if greater than specified in weight, in ounces.
-
#dimensional_weight ⇒ Float
The dimensional weight of package, if greater than specified in weight, in ounces.
-
#end_date ⇒ String
Effective end date of the rate.
-
#fees ⇒ Array[Fee2]
Fees associated to the package.
-
#mail_class ⇒ Object
List or enumeration of the domestic or international mail classes available.
-
#price ⇒ Float
Amount of Postage Required, does not include insurance or other extra service fees.
-
#price_type ⇒ InternationalPriceType
The type of price applied.
-
#processing_category ⇒ ProcessingCategory11
Processing category for the provided rate, this value can be used in the labels API to ensure the provided rate is applied.
-
#product_definition ⇒ String
A business friendly description associated to the product that can be displayed to a customer on a shipping portal.
-
#product_name ⇒ String
A business friendly name associated to the product that can be displayed to a customer on a shipping portal.
-
#rate_indicator ⇒ String
Two-digit rate indicator code for the provided rate, this value can be used in the labels API to ensure the provided rate is applied.
-
#sku ⇒ String
Pricing SKU.
-
#start_date ⇒ Date
Effective start date of the rate.
-
#weight ⇒ Float
The package weight, in weightUOM.
-
#zone ⇒ String
For domestic requests: indicates the calculated zone between the provided ‘originZIPCode` and `destinationZIPCode` for a given `mailClass`, `mailingDate`, and `weight`.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(description: SKIP, start_date: SKIP, end_date: SKIP, sku: SKIP, price: SKIP, zone: SKIP, weight: SKIP, dim_weight: SKIP, dimensional_weight: SKIP, price_type: SKIP, fees: SKIP, product_name: SKIP, product_definition: SKIP, processing_category: SKIP, rate_indicator: SKIP, destination_entry_facility_type: SKIP, mail_class: SKIP) ⇒ Rate
constructor
A new instance of Rate.
-
#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(description: SKIP, start_date: SKIP, end_date: SKIP, sku: SKIP, price: SKIP, zone: SKIP, weight: SKIP, dim_weight: SKIP, dimensional_weight: SKIP, price_type: SKIP, fees: SKIP, product_name: SKIP, product_definition: SKIP, processing_category: SKIP, rate_indicator: SKIP, destination_entry_facility_type: SKIP, mail_class: SKIP) ⇒ Rate
Returns a new instance of Rate.
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 218 |
# File 'lib/usps_api/models/rate.rb', line 192 def initialize(description: SKIP, start_date: SKIP, end_date: SKIP, sku: SKIP, price: SKIP, zone: SKIP, weight: SKIP, dim_weight: SKIP, dimensional_weight: SKIP, price_type: SKIP, fees: SKIP, product_name: SKIP, product_definition: SKIP, processing_category: SKIP, rate_indicator: SKIP, destination_entry_facility_type: SKIP, mail_class: SKIP) @description = description unless description == SKIP @start_date = start_date unless start_date == SKIP @end_date = end_date unless end_date == SKIP @sku = sku unless sku == SKIP @price = price unless price == SKIP @zone = zone unless zone == SKIP @weight = weight unless weight == SKIP @dim_weight = dim_weight unless dim_weight == SKIP @dimensional_weight = dimensional_weight unless dimensional_weight == SKIP @price_type = price_type unless price_type == SKIP @fees = fees unless fees == SKIP @product_name = product_name unless product_name == SKIP @product_definition = product_definition unless product_definition == SKIP @processing_category = processing_category unless processing_category == SKIP @rate_indicator = rate_indicator unless rate_indicator == SKIP unless destination_entry_facility_type == SKIP @destination_entry_facility_type = destination_entry_facility_type end @mail_class = mail_class unless mail_class == SKIP end |
Instance Attribute Details
#description ⇒ String
The description of the price.
14 15 16 |
# File 'lib/usps_api/models/rate.rb', line 14 def description @description end |
#destination_entry_facility_type ⇒ DestinationEntryFacilityType5
Destination Entry Facility type for the provided rate, this value can be used in the labels API to ensure the provided rate is applied.
-
‘NONE` - None, translates to PTR code `N`
-
‘AREA_DISTRIBUTION_CENTER` - Area Distribution Center, translates to PTR
code ‘A`
-
‘AUXILIARY_SERVICE_FACILITY` - Auxiliary Service Facility, translates to
PTR code ‘F`
-
‘DESTINATION_DELIVERY_UNIT` - Destination Delivery Unit, translates to
PTR code ‘D`
-
‘DESTINATION_NETWORK_DISTRIBUTION_CENTER` - Destination Network
Distribution Center, translates to PTR code ‘B`
-
‘DESTINATION_SECTIONAL_CENTER_FACILITY` - Destination Sectional Center
Facility, translates to PTR code ‘S`
-
‘DESTINATION_SERVICE_HUB` - Destination Service Hub, translates to PTR
code ‘H`
-
‘INTERNATIONAL_SERVICE_CENTER` - International Service Center,
translates to PTR code ‘I`
-
‘DESTINATION_REGIONAL_PROCESSING_DISTRIBUTION_CENTER` - Destination
Regional Processing Distribution Center, translates to PTR code ‘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.
133 134 135 |
# File 'lib/usps_api/models/rate.rb', line 133 def destination_entry_facility_type @destination_entry_facility_type end |
#dim_weight ⇒ Float
The dimensional weight of the package, if greater than specified in weight, in ounces.
50 51 52 |
# File 'lib/usps_api/models/rate.rb', line 50 def dim_weight @dim_weight end |
#dimensional_weight ⇒ Float
The dimensional weight of package, if greater than specified in weight, in ounces. This will be removed in July 2025.
55 56 57 |
# File 'lib/usps_api/models/rate.rb', line 55 def dimensional_weight @dimensional_weight end |
#end_date ⇒ String
Effective end date of the rate. If blank, the rate does not have an end date as of yet.
23 24 25 |
# File 'lib/usps_api/models/rate.rb', line 23 def end_date @end_date end |
#fees ⇒ Array[Fee2]
Fees associated to the package.
67 68 69 |
# File 'lib/usps_api/models/rate.rb', line 67 def fees @fees end |
#mail_class ⇒ Object
List or enumeration of the domestic or international mail classes available
138 139 140 |
# File 'lib/usps_api/models/rate.rb', line 138 def mail_class @mail_class end |
#price ⇒ Float
Amount of Postage Required, does not include insurance or other extra service fees.
32 33 34 |
# File 'lib/usps_api/models/rate.rb', line 32 def price @price end |
#price_type ⇒ InternationalPriceType
The type of price applied.
* Valid Options for Domestic Prices include: 'RETAIL', 'COMMERCIAL', &
‘CONTRACT’
* Valid Options for International Prices include: 'RETAIL', 'COMMERCIAL',
‘COMMERCIAL_BASE’, ‘COMMERCIAL_PLUS’, & ‘CONTRACT’
63 64 65 |
# File 'lib/usps_api/models/rate.rb', line 63 def price_type @price_type end |
#processing_category ⇒ ProcessingCategory11
Processing category for the provided rate, this value can be used in the labels API to ensure the provided rate is applied.
-
‘CARDS` - Cards, translates to PTR code `0`
-
‘LETTERS` - Letters, translates to PTR code `1`
-
‘FLATS` - Flats, translates to PTR code `2`
-
‘MACHINABLE` - Machinable Parcel, translates to PTR code `3`
-
‘IRREGULAR` - Irregular Parcel, translates to PTR code `4` - This option
is deprecated in favor of ‘NONSTANDARD` and will no longer be returned as of 01/19/2025.
-
‘NON_MACHINABLE` - Non-machinable parcel, translates to PTR code `5` -
This option is deprecated in favor of ‘NONSTANDARD` and will no longer be returned as of 01/19/2025.
-
‘NONSTANDARD` - Nonstandard parcel, translates to PTR code `5`
-
‘CATALOGS` - Catalogs, translates to PTR code `C`
-
‘OPEN_AND_DISTRIBUTE` - Open and Distribute, translates to PTR code `O`
-
‘RETURNS` - Returns, translates to PTR code `R`
-
‘SOFT_PACK_MACHINABLE` - Soft Pack Machinable, translates to PTR code
‘S`
-
‘SOFT_PACK_NON_MACHINABLE` - Soft Package Non-machinable, translates to
PTR code ‘T`
100 101 102 |
# File 'lib/usps_api/models/rate.rb', line 100 def processing_category @processing_category end |
#product_definition ⇒ String
A business friendly description associated to the product that can be displayed to a customer on a shipping portal.
77 78 79 |
# File 'lib/usps_api/models/rate.rb', line 77 def product_definition @product_definition end |
#product_name ⇒ String
A business friendly name associated to the product that can be displayed to a customer on a shipping portal.
72 73 74 |
# File 'lib/usps_api/models/rate.rb', line 72 def product_name @product_name end |
#rate_indicator ⇒ String
Two-digit rate indicator code for the provided rate, this value can be used in the labels API to ensure the provided rate is applied.
105 106 107 |
# File 'lib/usps_api/models/rate.rb', line 105 def rate_indicator @rate_indicator end |
#sku ⇒ String
Pricing SKU.
27 28 29 |
# File 'lib/usps_api/models/rate.rb', line 27 def sku @sku end |
#start_date ⇒ Date
Effective start date of the rate.
18 19 20 |
# File 'lib/usps_api/models/rate.rb', line 18 def start_date @start_date end |
#weight ⇒ Float
The package weight, in weightUOM. Items must weigh 70 pounds (1120 ounces) or less.
45 46 47 |
# File 'lib/usps_api/models/rate.rb', line 45 def weight @weight end |
#zone ⇒ String
For domestic requests: indicates the calculated zone between the provided ‘originZIPCode` and `destinationZIPCode` for a given `mailClass`, `mailingDate`, and `weight`. For international requests: indicates the price group for a given `destinationCountryCode`, `mailClass`, `mailingDate`, and `rateIndicator`.
40 41 42 |
# File 'lib/usps_api/models/rate.rb', line 40 def zone @zone end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 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 |
# File 'lib/usps_api/models/rate.rb', line 221 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. description = hash.key?('description') ? hash['description'] : SKIP start_date = hash.key?('startDate') ? hash['startDate'] : SKIP end_date = hash.key?('endDate') ? hash['endDate'] : SKIP sku = hash.key?('SKU') ? hash['SKU'] : SKIP price = hash.key?('price') ? hash['price'] : SKIP zone = hash.key?('zone') ? hash['zone'] : SKIP weight = hash.key?('weight') ? hash['weight'] : SKIP dim_weight = hash.key?('dimWeight') ? hash['dimWeight'] : SKIP dimensional_weight = hash.key?('dimensionalWeight') ? hash['dimensionalWeight'] : SKIP price_type = hash.key?('priceType') ? hash['priceType'] : SKIP # Parameter is an array, so we need to iterate through it fees = nil unless hash['fees'].nil? fees = [] hash['fees'].each do |structure| fees << (Fee2.from_hash(structure) if structure) end end fees = SKIP unless hash.key?('fees') product_name = hash.key?('productName') ? hash['productName'] : SKIP product_definition = hash.key?('productDefinition') ? hash['productDefinition'] : SKIP processing_category = hash.key?('processingCategory') ? hash['processingCategory'] : SKIP rate_indicator = hash.key?('rateIndicator') ? hash['rateIndicator'] : SKIP destination_entry_facility_type = hash.key?('destinationEntryFacilityType') ? hash['destinationEntryFacilityType'] : SKIP mail_class = hash.key?('mailClass') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:RateMailClass), hash['mailClass'] ) : SKIP # Create object from extracted values. Rate.new(description: description, start_date: start_date, end_date: end_date, sku: sku, price: price, zone: zone, weight: weight, dim_weight: dim_weight, dimensional_weight: dimensional_weight, price_type: price_type, fees: fees, product_name: product_name, product_definition: product_definition, processing_category: processing_category, rate_indicator: rate_indicator, destination_entry_facility_type: destination_entry_facility_type, mail_class: mail_class) end |
.names ⇒ Object
A mapping from model property names to API property names.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/usps_api/models/rate.rb', line 141 def self.names @_hash = {} if @_hash.nil? @_hash['description'] = 'description' @_hash['start_date'] = 'startDate' @_hash['end_date'] = 'endDate' @_hash['sku'] = 'SKU' @_hash['price'] = 'price' @_hash['zone'] = 'zone' @_hash['weight'] = 'weight' @_hash['dim_weight'] = 'dimWeight' @_hash['dimensional_weight'] = 'dimensionalWeight' @_hash['price_type'] = 'priceType' @_hash['fees'] = 'fees' @_hash['product_name'] = 'productName' @_hash['product_definition'] = 'productDefinition' @_hash['processing_category'] = 'processingCategory' @_hash['rate_indicator'] = 'rateIndicator' @_hash['destination_entry_facility_type'] = 'destinationEntryFacilityType' @_hash['mail_class'] = 'mailClass' @_hash end |
.nullables ⇒ Object
An array for nullable fields
188 189 190 |
# File 'lib/usps_api/models/rate.rb', line 188 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/usps_api/models/rate.rb', line 165 def self.optionals %w[ description start_date end_date sku price zone weight dim_weight dimensional_weight price_type fees product_name product_definition processing_category rate_indicator destination_entry_facility_type mail_class ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
280 281 282 283 284 285 286 |
# File 'lib/usps_api/models/rate.rb', line 280 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/usps_api/models/rate.rb', line 301 def inspect class_name = self.class.name.split('::').last "<#{class_name} description: #{@description.inspect}, start_date: #{@start_date.inspect},"\ " end_date: #{@end_date.inspect}, sku: #{@sku.inspect}, price: #{@price.inspect}, zone:"\ " #{@zone.inspect}, weight: #{@weight.inspect}, dim_weight: #{@dim_weight.inspect},"\ " dimensional_weight: #{@dimensional_weight.inspect}, price_type: #{@price_type.inspect},"\ " fees: #{@fees.inspect}, product_name: #{@product_name.inspect}, product_definition:"\ " #{@product_definition.inspect}, processing_category: #{@processing_category.inspect},"\ " rate_indicator: #{@rate_indicator.inspect}, destination_entry_facility_type:"\ " #{@destination_entry_facility_type.inspect}, mail_class: #{@mail_class.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
289 290 291 292 293 294 295 296 297 298 |
# File 'lib/usps_api/models/rate.rb', line 289 def to_s class_name = self.class.name.split('::').last "<#{class_name} description: #{@description}, start_date: #{@start_date}, end_date:"\ " #{@end_date}, sku: #{@sku}, price: #{@price}, zone: #{@zone}, weight: #{@weight},"\ " dim_weight: #{@dim_weight}, dimensional_weight: #{@dimensional_weight}, price_type:"\ " #{@price_type}, fees: #{@fees}, product_name: #{@product_name}, product_definition:"\ " #{@product_definition}, processing_category: #{@processing_category}, rate_indicator:"\ " #{@rate_indicator}, destination_entry_facility_type: #{@destination_entry_facility_type},"\ " mail_class: #{@mail_class}>" end |