Class: UspsApi::ContainersImageInfo

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/containers_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: LabelType::ENUM_6X4LABEL, add_zpl_comments: false) ⇒ ContainersImageInfo

Returns a new instance of ContainersImageInfo.



59
60
61
62
63
64
65
# File 'lib/usps_api/models/containers_image_info.rb', line 59

def initialize(image_type: ImageType::PDF,
               label_type: LabelType::ENUM_6X4LABEL,
               add_zpl_comments: false)
  @image_type = image_type unless image_type == SKIP
  @label_type = label_type unless label_type == 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)


34
35
36
# File 'lib/usps_api/models/containers_image_info.rb', line 34

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. Note:

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

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

Returns:



18
19
20
# File 'lib/usps_api/models/containers_image_info.rb', line 18

def image_type
  @image_type
end

#label_typeLabelType

Ability to select the label image size. If omitted then the default label size is 6X4LABEL.

* '6X4LABEL'

Returns:



24
25
26
# File 'lib/usps_api/models/containers_image_info.rb', line 24

def label_type
  @label_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/usps_api/models/containers_image_info.rb', line 68

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  image_type = hash['imageType'] ||= ImageType::PDF
  label_type = hash['labelType'] ||= LabelType::ENUM_6X4LABEL
  add_zpl_comments = hash['addZPLComments'] ||= false

  # Create object from extracted values.
  ContainersImageInfo.new(image_type: image_type,
                          label_type: label_type,
                          add_zpl_comments: add_zpl_comments)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
# File 'lib/usps_api/models/containers_image_info.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['image_type'] = 'imageType'
  @_hash['label_type'] = 'labelType'
  @_hash['add_zpl_comments'] = 'addZPLComments'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/usps_api/models/containers_image_info.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
52
# File 'lib/usps_api/models/containers_image_info.rb', line 46

def self.optionals
  %w[
    image_type
    label_type
    add_zpl_comments
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



84
85
86
87
88
89
90
# File 'lib/usps_api/models/containers_image_info.rb', line 84

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.



100
101
102
103
104
# File 'lib/usps_api/models/containers_image_info.rb', line 100

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

#to_sObject

Provides a human-readable string representation of the object.



93
94
95
96
97
# File 'lib/usps_api/models/containers_image_info.rb', line 93

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