Class: UspsApi::PriceType

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

Overview

The type of price applied. * Valid Options for Domestic Prices include: ‘RETAIL’,‘COMMERCIAL’, ‘CONTRACT’ & ‘NSA’ (deprecated) * Valid Options for International Prices include: ‘RETAIL’, ‘COMMERCIAL’, ‘COMMERCIAL_BASE’, ‘COMMERCIAL_PLUS’, ‘CONTRACT’ & ‘NSA’ (deprecated)

Constant Summary collapse

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

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

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = RETAIL) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/usps_api/models/price_type.rb', line 38

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 'commercial_base' then COMMERCIAL_BASE
  when 'commercial_plus' then COMMERCIAL_PLUS
  when 'contract' then CONTRACT
  when 'nsa' then NSA
  else
    default_value
  end
end

.validate(value) ⇒ Object



32
33
34
35
36
# File 'lib/usps_api/models/price_type.rb', line 32

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

  PRICE_TYPE.include?(value)
end