Class: UspsApi::LabelsIndiciaRequestDescription

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

Overview

The ‘IndiciaRequestDescription` object defines the physical dimensions, mailing date, processing category, and weight required for processing a First-Class letter, flat, or card.

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(processing_category:, weight:, mailing_date:, length:, height:, thickness:, non_machinable_indicators: SKIP, imi_type: ImiType::IMI_STD, additional_properties: nil) ⇒ LabelsIndiciaRequestDescription

Returns a new instance of LabelsIndiciaRequestDescription.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 105

def initialize(processing_category:, weight:, mailing_date:, length:,
               height:, thickness:, non_machinable_indicators: SKIP,
               imi_type: ImiType::IMI_STD, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @processing_category = processing_category
  @weight = weight
  @mailing_date = mailing_date
  @length = length
  @height = height
  @thickness = thickness
  unless non_machinable_indicators == SKIP
    @non_machinable_indicators =
      non_machinable_indicators
  end
  @imi_type = imi_type unless imi_type == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#heightFloat

The letter/flat/card height in inches. The height is the dimension perpendicular to the length.

Returns:

  • (Float)


60
61
62
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 60

def height
  @height
end

#imi_typeImiType

The type of Intelligent Mail Indicia (IMI) to be generated. The default option is ‘IMI_STD`. The `imiType` can be changed only when `imageInfo.labelType` is set to `IMI_DATA_ONLY`.

Returns:



76
77
78
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 76

def imi_type
  @imi_type
end

#lengthFloat

The letter/flat/card length in inches. For ‘LETTERS` and `CARDS` the length is the dimension parallel to the delivery address as read. For `FLATS` the length is the longest dimension.

Returns:

  • (Float)


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

def length
  @length
end

#mailing_dateObject

Mailing Date Indicia Options

Returns:

  • (Object)


49
50
51
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 49

def mailing_date
  @mailing_date
end

#non_machinable_indicatorsNonMachinableIndicators

Set of boolean indicators used to determine whether a letter qualifies as nonmachinable.



70
71
72
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 70

def non_machinable_indicators
  @non_machinable_indicators
end

#processing_categoryProcessingCategory21

  • LETTERS

    To be eligible for mailing at the price for letters, a piece must be:

    * Rectangular
    * At least 3-1/2 inches high x 5 inches long x 0.007 inch thick.
    * No more than 6-1/8 inches high x 11-1/2 inches long x 1/4 inch
    

thick.

For additional information on letters, please refer to the [Postal

Explorer](pe.usps.com/businessmail101?ViewName=Letters).

  • FLATS The Postal Service uses the word “flats” to refer to large envelopes,

newsletters, and magazines. The words large envelopes and flats are used interchangeably. Whatever you call them, flats must:

* Have one dimension that is greater than 6-1/8 inches high OR 11-½

inches long OR ¼ inch thick.

  * Be no more than 12 inches high x 15 inches long x ¾ inch thick.
For additional information on flats, please refer to the [Postal

Explorer](pe.usps.com/businessmail101?ViewName=Flats).

  • CARDS To be eligible for mailing at the price for postcards, a piece must be:

    * Rectangular
    * At least 3-1/2 inches high x 5 inches long x 0.007 inch thick.
    * No more than 4-1/4 inches high x 6 inches long x 0.016 inch thick.
    

    For additional information on postcards, please refer to the [Postal

Explorer](pe.usps.com/businessmail101?ViewName=Cards).



40
41
42
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 40

def processing_category
  @processing_category
end

#thicknessFloat

The letter/flat/card thickness in inches. The minimum dimension is always the thickness.

Returns:

  • (Float)


65
66
67
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 65

def thickness
  @thickness
end

#weightFloat

The letter/flat/card weight, in ounces. The maximum weight of a letter or card is 3.5 oz and the maximum weight of a flat is 13 oz.

Returns:

  • (Float)


45
46
47
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 45

def weight
  @weight
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 126

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  processing_category =
    hash.key?('processingCategory') ? hash['processingCategory'] : nil
  weight = hash.key?('weight') ? hash['weight'] : nil
  mailing_date = hash.key?('mailingDate') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:LabelsIndiciaRequestDescriptionMailingDate), hash['mailingDate']
  ) : nil
  length = hash.key?('length') ? hash['length'] : nil
  height = hash.key?('height') ? hash['height'] : nil
  thickness = hash.key?('thickness') ? hash['thickness'] : nil
  if hash['nonMachinableIndicators']
    non_machinable_indicators = NonMachinableIndicators.from_hash(hash['nonMachinableIndicators'])
  end
  imi_type = hash['imiType'] ||= ImiType::IMI_STD

  # 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.
  LabelsIndiciaRequestDescription.new(processing_category: processing_category,
                                      weight: weight,
                                      mailing_date: mailing_date,
                                      length: length,
                                      height: height,
                                      thickness: thickness,
                                      non_machinable_indicators: non_machinable_indicators,
                                      imi_type: imi_type,
                                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 79

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['processing_category'] = 'processingCategory'
  @_hash['weight'] = 'weight'
  @_hash['mailing_date'] = 'mailingDate'
  @_hash['length'] = 'length'
  @_hash['height'] = 'height'
  @_hash['thickness'] = 'thickness'
  @_hash['non_machinable_indicators'] = 'nonMachinableIndicators'
  @_hash['imi_type'] = 'imiType'
  @_hash
end

.nullablesObject

An array for nullable fields



101
102
103
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 101

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    non_machinable_indicators
    imi_type
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 171

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.processing_category,
                            ->(val) { ProcessingCategory21.validate(val) }) and
        APIHelper.valid_type?(value.weight,
                              ->(val) { val.instance_of? Float }) and
        UnionTypeLookUp.get(:LabelsIndiciaRequestDescriptionMailingDate)
                       .validate(value.mailing_date) and
        APIHelper.valid_type?(value.length,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.height,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.thickness,
                              ->(val) { val.instance_of? Float })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['processingCategory'],
                          ->(val) { ProcessingCategory21.validate(val) }) and
      APIHelper.valid_type?(value['weight'],
                            ->(val) { val.instance_of? Float }) and
      UnionTypeLookUp.get(:LabelsIndiciaRequestDescriptionMailingDate)
                     .validate(value['mailingDate']) and
      APIHelper.valid_type?(value['length'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['height'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['thickness'],
                            ->(val) { val.instance_of? Float })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



217
218
219
220
221
222
223
224
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 217

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} processing_category: #{@processing_category.inspect}, weight:"\
  " #{@weight.inspect}, mailing_date: #{@mailing_date.inspect}, length: #{@length.inspect},"\
  " height: #{@height.inspect}, thickness: #{@thickness.inspect}, non_machinable_indicators:"\
  " #{@non_machinable_indicators.inspect}, imi_type: #{@imi_type.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



208
209
210
211
212
213
214
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 208

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} processing_category: #{@processing_category}, weight: #{@weight},"\
  " mailing_date: #{@mailing_date}, length: #{@length}, height: #{@height}, thickness:"\
  " #{@thickness}, non_machinable_indicators: #{@non_machinable_indicators}, imi_type:"\
  " #{@imi_type}, additional_properties: #{@additional_properties}>"
end

#to_union_type_mailing_dateObject



163
164
165
166
167
# File 'lib/usps_api/models/labels_indicia_request_description.rb', line 163

def to_union_type_mailing_date
  UnionTypeLookUp.get(:LabelsIndiciaRequestDescriptionMailingDate)
                 .validate(mailing_date)
                 .serialize(mailing_date)
end