Class: UspsApi::ImageInfo2

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/image_info2.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(receipt_option: ReceiptOption::NONE, image_type: ImageType2::PDF, label_type: LabelType21::ENUM_2X15LABEL) ⇒ ImageInfo2

Returns a new instance of ImageInfo2.



61
62
63
64
65
66
67
# File 'lib/usps_api/models/image_info2.rb', line 61

def initialize(receipt_option: ReceiptOption::NONE,
               image_type: ImageType2::PDF,
               label_type: LabelType21::ENUM_2X15LABEL)
  @receipt_option = receipt_option unless receipt_option == SKIP
  @image_type = image_type unless image_type == SKIP
  @label_type = label_type unless label_type == SKIP
end

Instance Attribute Details

#image_typeImageType2

The type of indicia image requested. If omitted then the default image type is PDF.

* 'PDF'
* 'TIFF'
* 'JPG'
* 'PNG'
* 'GIF'
* 'SVG'

Returns:



27
28
29
# File 'lib/usps_api/models/image_info2.rb', line 27

def image_type
  @image_type
end

#label_typeLabelType21

Ability to select the indicia image size. If omitted then the default indicia size is 2X1.5LABEL.

  • Using ‘2X1.5LABEL` 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` field.

Returns:



36
37
38
# File 'lib/usps_api/models/image_info2.rb', line 36

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.

Returns:



16
17
18
# File 'lib/usps_api/models/image_info2.rb', line 16

def receipt_option
  @receipt_option
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/usps_api/models/image_info2.rb', line 70

def self.from_hash(hash)
  return nil unless hash

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

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

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/usps_api/models/image_info2.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



48
49
50
51
52
53
54
# File 'lib/usps_api/models/image_info2.rb', line 48

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



92
93
94
95
96
# File 'lib/usps_api/models/image_info2.rb', line 92

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

#to_sObject

Provides a human-readable string representation of the object.



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

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