Class: UspsApi::IndiciaImbImageInfo

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

Overview

Additional details used to determine how to generate the indicia 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: ImageType2::PDF, label_type: LabelType11::ENUM_6X4LABEL, receipt_option: ReceiptOption::NONE, additional_properties: nil) ⇒ IndiciaImbImageInfo

Returns a new instance of IndiciaImbImageInfo.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/usps_api/models/indicia_imb_image_info.rb', line 58

def initialize(image_type: ImageType2::PDF,
               label_type: LabelType11::ENUM_6X4LABEL,
               receipt_option: ReceiptOption::NONE,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @image_type = image_type unless image_type == SKIP
  @label_type = label_type unless label_type == SKIP
  @receipt_option = receipt_option unless receipt_option == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#image_typeImageType2

The image type to be created. If omitted then the default image type is PDF.

Returns:



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

def image_type
  @image_type
end

#label_typeLabelType11

The requested image size.

  • Using ‘6X4LABEL` will return the image in the `indiciaImage` response

field.

  • Using ‘IMI_DATA_ONLY` will return the IMI data in the `indiciaIMI`

response field and not populate the ‘indiciaImage` or `receiptImage` field.

Returns:



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

def label_type
  @label_type
end

#receipt_optionReceiptOption

Indicia & Receipt print out options: Enter ‘SEPARATE_PAGE` to print the Indicia and the Receipt on separate pages. Enter `NONE` to print the Indicia only and no Receipt. Note:

  • ‘NONE` is the only option supported when `labelType` is set to

‘IMI_DATA_ONLY`.

Returns:



33
34
35
# File 'lib/usps_api/models/indicia_imb_image_info.rb', line 33

def receipt_option
  @receipt_option
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/usps_api/models/indicia_imb_image_info.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  image_type = hash['imageType'] ||= ImageType2::PDF
  label_type = hash['labelType'] ||= LabelType11::ENUM_6X4LABEL
  receipt_option = hash['receiptOption'] ||= ReceiptOption::NONE

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  IndiciaImbImageInfo.new(image_type: image_type,
                          label_type: label_type,
                          receipt_option: receipt_option,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/usps_api/models/indicia_imb_image_info.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



102
103
104
105
106
107
# File 'lib/usps_api/models/indicia_imb_image_info.rb', line 102

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

#to_sObject

Provides a human-readable string representation of the object.



95
96
97
98
99
# File 'lib/usps_api/models/indicia_imb_image_info.rb', line 95

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