Class: UspsApi::ImageInfo

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

Returns a new instance of ImageInfo.



51
52
53
54
55
56
57
# File 'lib/usps_api/models/image_info.rb', line 51

def initialize(receipt_option: ReceiptOption::NONE,
               image_type: ImageType2::PDF,
               label_type: LabelType2::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.

Returns:



21
22
23
# File 'lib/usps_api/models/image_info.rb', line 21

def image_type
  @image_type
end

#label_typeLabelType2

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

Returns:



26
27
28
# File 'lib/usps_api/models/image_info.rb', line 26

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



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/usps_api/models/image_info.rb', line 60

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'] ||= LabelType2::ENUM_2X15LABEL

  # Create object from extracted values.
  ImageInfo.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.



29
30
31
32
33
34
35
# File 'lib/usps_api/models/image_info.rb', line 29

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



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



82
83
84
85
86
# File 'lib/usps_api/models/image_info.rb', line 82

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.



75
76
77
78
79
# File 'lib/usps_api/models/image_info.rb', line 75

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