Class: UspsApi::ImiType

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

Overview

The type of Intelligent Mail Indicia (IMI) to be generated. The default option is ‘IMI_STD`. The `imiType` can be changed only when `imageInfo.labelType` is set to `IMI_DATA_ONLY`.

Constant Summary collapse

IMI_TYPE =
[
  # TODO: Write general description for IMI_MIN
  IMI_MIN = 'IMI_MIN'.freeze,

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = IMI_MIN) ⇒ Object



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

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

  str = value.to_s.strip

  case str.downcase
  when 'imi_min' then IMI_MIN
  when 'imi_std' then IMI_STD
  when 'imi_max' then IMI_MAX
  else
    default_value
  end
end

.validate(value) ⇒ Object



22
23
24
25
26
# File 'lib/usps_api/models/imi_type.rb', line 22

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

  IMI_TYPE.include?(value)
end