Class: UspsApi::ShipmentsPriceType1

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

Overview

Price type of the Shipping Request. Note: - If ‘priceType` is `CONTRACT`, `paymentAccount` is required.

Constant Summary collapse

SHIPMENTS_PRICE_TYPE1 =
[
  # TODO: Write general description for RETAIL
  RETAIL = 'RETAIL'.freeze,

  # TODO: Write general description for COMMERCIAL
  COMMERCIAL = 'COMMERCIAL'.freeze,

  # TODO: Write general description for CONTRACT
  CONTRACT = 'CONTRACT'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = RETAIL) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/usps_api/models/shipments_price_type1.rb', line 27

def self.from_value(value, default_value = RETAIL)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'retail' then RETAIL
  when 'commercial' then COMMERCIAL
  when 'contract' then CONTRACT
  else
    default_value
  end
end

.validate(value) ⇒ Object



21
22
23
24
25
# File 'lib/usps_api/models/shipments_price_type1.rb', line 21

def self.validate(value)
  return false if value.nil?

  SHIPMENTS_PRICE_TYPE1.include?(value)
end