Class: UspsApi::ImageType

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

Overview

The type of label image requested. If omitted then the default image type is PDF. Note: - When using ‘ZPL203DPI` or `ZPL300DPI` the image returned will be rotated 90 degrees and be 4x6 inches, instead of 6x4 inches.

Constant Summary collapse

IMAGE_TYPE =
[
  # TODO: Write general description for PDF
  PDF = 'PDF'.freeze,

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

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

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

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

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = PDF) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/usps_api/models/image_type.rb', line 46

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

  str = value.to_s.strip

  case str.downcase
  when 'pdf' then PDF
  when 'tiff' then TIFF
  when 'jpg' then JPG
  when 'png' then PNG
  when 'gif' then GIF
  when 'svg' then SVG
  when 'zpl203dpi' then ZPL203DPI
  when 'zpl300dpi' then ZPL300DPI
  when 'none' then NONE
  else
    default_value
  end
end

.validate(value) ⇒ Object



40
41
42
43
44
# File 'lib/usps_api/models/image_type.rb', line 40

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

  IMAGE_TYPE.include?(value)
end