Class: UspsApi::ImageType3

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

Overview

The type of label image requested. If omitted then the default image type is PDF. * ‘PDF’ * ‘TIFF’ * ‘JPG’ * ‘PNG’ * ‘GIF’ * ‘SVG’ * ‘ZPL203DPI’ * ‘ZPL300DPI’ * ‘LABEL_BROKER’ - Request a USPS QR code to allow your customers with no access to a printer to print at participating Post Office Locations. All USPS API users and third-party integrators utilizing QR codes are subject to the [Label Broker terms and conditions](www.usps.com/terms-conditions/label-broker.htm). For more information please see the Label Broker guide available on [GitHub](github.com/USPS/api-examples/blob/main/USPS%20APIs%20Domest ic%20Labels%20API%20Documentation_2023_0901%20Published.pdf) (Note: Only supports labelType of ‘4X6LABEL’ or ‘6X4LABEL’ and receiptOption of ‘NONE’).

A USPS Label Broker QR code image will be returned in the API response

instead of a label image. * ‘NONE’ Note: - Labels with customs forms only support formats of ‘PDF`, `TIFF`, `ZPL203DPI`, `ZPL300DPI`, `LABEL_BROKER`, and `NONE`. - Including Extra Service Code `415 - USPS Label Delivery` returns no images and is equivalent to requesting `NONE`.

Constant Summary collapse

IMAGE_TYPE3 =
[
  # 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 LABEL_BROKER
  LABEL_BROKER = 'LABEL_BROKER'.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



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/usps_api/models/image_type3.rb', line 62

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 'label_broker' then LABEL_BROKER
  when 'none' then NONE
  else
    default_value
  end
end

.validate(value) ⇒ Object



56
57
58
59
60
# File 'lib/usps_api/models/image_type3.rb', line 56

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

  IMAGE_TYPE3.include?(value)
end