Class: UspsApi::PmodImageInfo

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

Overview

Additional details used to determine how to generate the label image.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(image_type: ImageType::PDF, label_type: LabelType1::ENUM_4X6LABEL, imcb_label_type: LabelType::ENUM_6X4LABEL, receipt_option: ReceiptOption1::SAME_PAGE, suppress_postage: true, suppress_mail_date: true, add_zpl_comments: false) ⇒ PmodImageInfo

Returns a new instance of PmodImageInfo.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/usps_api/models/pmod_image_info.rb', line 95

def initialize(image_type: ImageType::PDF,
               label_type: LabelType1::ENUM_4X6LABEL,
               imcb_label_type: LabelType::ENUM_6X4LABEL,
               receipt_option: ReceiptOption1::SAME_PAGE,
               suppress_postage: true, suppress_mail_date: true,
               add_zpl_comments: false)
  @image_type = image_type unless image_type == SKIP
  @label_type = label_type unless label_type == SKIP
  @imcb_label_type = imcb_label_type unless imcb_label_type == SKIP
  @receipt_option = receipt_option unless receipt_option == SKIP
  @suppress_postage = suppress_postage unless suppress_postage == SKIP
  @suppress_mail_date = suppress_mail_date unless suppress_mail_date == SKIP
  @add_zpl_comments = add_zpl_comments unless add_zpl_comments == SKIP
end

Instance Attribute Details

#add_zpl_commentsTrueClass | FalseClass

Applicable only when ‘imageType` is `ZPL203DPI` or `ZPL300DPI`. When `addZPLComments` is `true`, comments will be visible within the ZPL text response to the user to denote different sections of their label. When `addZPLComments` is `false`, no comments will be included in the ZPL text response. This will be ignored for any other `imageType`. Example of a ZPL comment: `^FX Start of label. 123e4567-e89b-12d3-a456-426614174000 ^FS`

Returns:

  • (TrueClass | FalseClass)


62
63
64
# File 'lib/usps_api/models/pmod_image_info.rb', line 62

def add_zpl_comments
  @add_zpl_comments
end

#image_typeImageType

The type of label image requested.

If omitted then the default image type is ‘PDF`.

Returns:



15
16
17
# File 'lib/usps_api/models/pmod_image_info.rb', line 15

def image_type
  @image_type
end

#imcb_label_typeLabelType

Ability to select the 99M image size. If omitted then the default label size is ‘6X4LABEL`. Note:

  • When using ‘ZPL203DPI` or `ZPL300DPI` the image returned will be rotated

90 degrees and be 4x6 inches, instead of 6x4 inches.

Returns:



28
29
30
# File 'lib/usps_api/models/pmod_image_info.rb', line 28

def imcb_label_type
  @imcb_label_type
end

#label_typeLabelType1

Ability to select the label image size. If omitted then the default label size is ‘4X6LABEL`.

Returns:



20
21
22
# File 'lib/usps_api/models/pmod_image_info.rb', line 20

def label_type
  @label_type
end

#receipt_optionReceiptOption1

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:

* 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.

Returns:



42
43
44
# File 'lib/usps_api/models/pmod_image_info.rb', line 42

def receipt_option
  @receipt_option
end

#suppress_mail_dateTrueClass | FalseClass

Indicates if the date is printed on the label. If omitted then the value will default to true.

Returns:

  • (TrueClass | FalseClass)


52
53
54
# File 'lib/usps_api/models/pmod_image_info.rb', line 52

def suppress_mail_date
  @suppress_mail_date
end

#suppress_postageTrueClass | FalseClass

Indicates if postage is printed on the label. If omitted then the request will be defaulted to true.

Returns:

  • (TrueClass | FalseClass)


47
48
49
# File 'lib/usps_api/models/pmod_image_info.rb', line 47

def suppress_postage
  @suppress_postage
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/usps_api/models/pmod_image_info.rb', line 111

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  image_type = hash['imageType'] ||= ImageType::PDF
  label_type = hash['labelType'] ||= LabelType1::ENUM_4X6LABEL
  imcb_label_type = hash['imcbLabelType'] ||= LabelType::ENUM_6X4LABEL
  receipt_option = hash['receiptOption'] ||= ReceiptOption1::SAME_PAGE
  suppress_postage = hash['suppressPostage'] ||= true
  suppress_mail_date = hash['suppressMailDate'] ||= true
  add_zpl_comments = hash['addZPLComments'] ||= false

  # Create object from extracted values.
  PmodImageInfo.new(image_type: image_type,
                    label_type: label_type,
                    imcb_label_type: imcb_label_type,
                    receipt_option: receipt_option,
                    suppress_postage: suppress_postage,
                    suppress_mail_date: suppress_mail_date,
                    add_zpl_comments: add_zpl_comments)
end

.namesObject

A mapping from model property names to API property names.



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/usps_api/models/pmod_image_info.rb', line 65

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['image_type'] = 'imageType'
  @_hash['label_type'] = 'labelType'
  @_hash['imcb_label_type'] = 'imcbLabelType'
  @_hash['receipt_option'] = 'receiptOption'
  @_hash['suppress_postage'] = 'suppressPostage'
  @_hash['suppress_mail_date'] = 'suppressMailDate'
  @_hash['add_zpl_comments'] = 'addZPLComments'
  @_hash
end

.nullablesObject

An array for nullable fields



91
92
93
# File 'lib/usps_api/models/pmod_image_info.rb', line 91

def self.nullables
  []
end

.optionalsObject

An array for optional fields



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/usps_api/models/pmod_image_info.rb', line 78

def self.optionals
  %w[
    image_type
    label_type
    imcb_label_type
    receipt_option
    suppress_postage
    suppress_mail_date
    add_zpl_comments
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (PmodImageInfo | Hash)

    value against the validation is performed.



135
136
137
138
139
140
141
# File 'lib/usps_api/models/pmod_image_info.rb', line 135

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



153
154
155
156
157
158
159
# File 'lib/usps_api/models/pmod_image_info.rb', line 153

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} image_type: #{@image_type.inspect}, label_type: #{@label_type.inspect},"\
  " imcb_label_type: #{@imcb_label_type.inspect}, receipt_option: #{@receipt_option.inspect},"\
  " suppress_postage: #{@suppress_postage.inspect}, suppress_mail_date:"\
  " #{@suppress_mail_date.inspect}, add_zpl_comments: #{@add_zpl_comments.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



144
145
146
147
148
149
150
# File 'lib/usps_api/models/pmod_image_info.rb', line 144

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} image_type: #{@image_type}, label_type: #{@label_type}, imcb_label_type:"\
  " #{@imcb_label_type}, receipt_option: #{@receipt_option}, suppress_postage:"\
  " #{@suppress_postage}, suppress_mail_date: #{@suppress_mail_date}, add_zpl_comments:"\
  " #{@add_zpl_comments}>"
end