Class: UspsApi::ScanFormsImageInfo

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

Overview

Characteristics of the type of SCAN Form being requested.

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: LabelType4::ENUM_85X11LABEL, additional_properties: nil) ⇒ ScanFormsImageInfo

Returns a new instance of ScanFormsImageInfo.



52
53
54
55
56
57
58
59
60
61
# File 'lib/usps_api/models/scan_forms_image_info.rb', line 52

def initialize(image_type: ImageType::PDF,
               label_type: LabelType4::ENUM_85X11LABEL,
               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
  @additional_properties = additional_properties
end

Instance Attribute Details

#image_typeImageType

The type of SCAN Form image being requested. If omitted then the default image type is ‘PDF`. Note:

  • The ‘labelType` of `8.5X11LABEL` is not supported with the `imageType`

of ‘ZPL203DPI` or `ZPL300DPI`.

  • ‘ZPL203DPI` and `ZPL300DPI` are only supported via

‘imageInfo.imageType`. The deprecated `imageType` field does not support these values.

Returns:



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

def image_type
  @image_type
end

#label_typeLabelType4

Ability to select the SCAN Form image size. If omitted then the default SCAN form size is ‘8.5X11LABEL`. Note:

  • The ‘8.5X11LABEL` format will generate SCAN Form type 5630, the

‘4X6LABEL` format will generate SCAN Form type 5630-S.

Returns:



29
30
31
# File 'lib/usps_api/models/scan_forms_image_info.rb', line 29

def label_type
  @label_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/usps_api/models/scan_forms_image_info.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  image_type = hash['imageType'] ||= ImageType::PDF
  label_type = hash['labelType'] ||= LabelType4::ENUM_85X11LABEL

  # 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.
  ScanFormsImageInfo.new(image_type: image_type,
                         label_type: label_type,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
# File 'lib/usps_api/models/scan_forms_image_info.rb', line 32

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

.nullablesObject

An array for nullable fields



48
49
50
# File 'lib/usps_api/models/scan_forms_image_info.rb', line 48

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    image_type
    label_type
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



86
87
88
89
90
91
92
# File 'lib/usps_api/models/scan_forms_image_info.rb', line 86

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.



102
103
104
105
106
# File 'lib/usps_api/models/scan_forms_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},"\
  " 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/scan_forms_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},"\
  " additional_properties: #{@additional_properties}>"
end