Class: UspsApi::ReceiptOption1

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

Overview

Label & Receipt print out options: Enter ‘SAME_PAGE` to print the Label and the Receipt on a single page. Enter `SEPARATE_PAGE` to print the Label and the Receipt on separate pages. Enter `NONE` to print the Label only and no Receipt. Note: * The `labelType` of `4X4LABEL` or `6X4LABEL` with the image `imageType` of `ZPL203DPI` or `ZPL300DPI` does not support a `receiptOption` of `SEPARATE_PAGE`. * When `imageType` is `ZPL203DPI` or `ZPL300DPI`, a `receiptOption` of `SAME_PAGE` is not supported. * When `imageType` is `ZPL203DPI` or `ZPL300DPI` and `receiptOption` is `SEPARATE_PAGE`, the receipt will be returned as an additional label segment within the single ZPL payload in `labelImage`. In this case, `receiptImage` will not be populated.

Constant Summary collapse

RECEIPT_OPTION1 =
[
  # TODO: Write general description for SAME_PAGE
  SAME_PAGE = 'SAME_PAGE'.freeze,

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = SAME_PAGE) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/usps_api/models/receipt_option1.rb', line 36

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

  str = value.to_s.strip

  case str.downcase
  when 'same_page' then SAME_PAGE
  when 'separate_page' then SEPARATE_PAGE
  when 'none' then NONE
  else
    default_value
  end
end

.validate(value) ⇒ Object



30
31
32
33
34
# File 'lib/usps_api/models/receipt_option1.rb', line 30

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

  RECEIPT_OPTION1.include?(value)
end