Class: UspsApi::InternationalLabelVendorResponse

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

Overview

Response containing the international label metadata and Base64-encoded label image for vendor-specific media types.

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(label_address: SKIP, international_tracking_number: SKIP, construct_code: SKIP, sku: SKIP, postage: SKIP, extra_services: SKIP, international_price_group: SKIP, weight_uom: WeightUom1::LB, weight: SKIP, dimensional_weight: SKIP, mailing_date: SKIP, fees: SKIP, label_broker_id: SKIP, label_image: SKIP, label_broker_qr: SKIP, additional_properties: nil) ⇒ InternationalLabelVendorResponse

Returns a new instance of InternationalLabelVendorResponse.



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
162
163
164
165
166
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 134

def initialize(label_address: SKIP, international_tracking_number: SKIP,
               construct_code: SKIP, sku: SKIP, postage: SKIP,
               extra_services: SKIP, international_price_group: SKIP,
               weight_uom: WeightUom1::LB, weight: SKIP,
               dimensional_weight: SKIP, mailing_date: SKIP, fees: SKIP,
               label_broker_id: SKIP, label_image: SKIP,
               label_broker_qr: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @label_address = label_address unless label_address == SKIP
  unless international_tracking_number == SKIP
    @international_tracking_number =
      international_tracking_number
  end
  @construct_code = construct_code unless construct_code == SKIP
  @sku = sku unless sku == SKIP
  @postage = postage unless postage == SKIP
  @extra_services = extra_services unless extra_services == SKIP
  unless international_price_group == SKIP
    @international_price_group =
      international_price_group
  end
  @weight_uom = weight_uom unless weight_uom == SKIP
  @weight = weight unless weight == SKIP
  @dimensional_weight = dimensional_weight unless dimensional_weight == SKIP
  @mailing_date = mailing_date unless mailing_date == SKIP
  @fees = fees unless fees == SKIP
  @label_broker_id = label_broker_id unless label_broker_id == SKIP
  @label_image = label_image unless label_image == SKIP
  @label_broker_qr = label_broker_qr unless label_broker_qr == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#construct_codeString

The barcode construct code associated with the international tracking number

Returns:

  • (String)


28
29
30
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 28

def construct_code
  @construct_code
end

#dimensional_weightString

The dimensional weight of the package in pounds, if greater than the value specified in ‘weight`.

Returns:

  • (String)


61
62
63
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 61

def dimensional_weight
  @dimensional_weight
end

#extra_servicesArray[InternationalLabelsExtraServiceResponse]

Extra services requested on the mailpiece.



41
42
43
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 41

def extra_services
  @extra_services
end

#feesArray[Fee2]

Fees associated to the package.

Returns:



69
70
71
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 69

def fees
  @fees
end

#international_price_groupString

Indicates the price group for a given ‘countryISOAlpha2Code`, `mailClass`, `mailingDate`, and `rateIndicator`.

Returns:

  • (String)


46
47
48
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 46

def international_price_group
  @international_price_group
end

#international_tracking_numberString

International Package Tracking number

Returns:

  • (String)


23
24
25
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 23

def international_tracking_number
  @international_tracking_number
end

#label_addressInternationalLabelAddress

Uses for: The international address where the package is being mailed to. The destination Country Code is used for calculating pricing. Note:

  • The First and Last Name or Firm Name are always required.



19
20
21
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 19

def label_address
  @label_address
end

#label_broker_idString

Unique Label Broker ID that can be used as an alternative to the Label Broker QR Code to retrieve the label at a Post Office. Will only be provided when an imageType of LABEL_BROKER is requested.

Returns:

  • (String)


75
76
77
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 75

def label_broker_id
  @label_broker_id
end

#label_broker_qrString

The Label Broker QR Code image, Base64 encoded file contents. Only provided if ‘imageType` in the `imageInfo` is set to `LABEL_BROKER`.

Returns:

  • (String)


85
86
87
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 85

def label_broker_qr
  @label_broker_qr
end

#label_imageString

Contains the Base64-encoded file contents of the label image. Provided only when ‘imageInfo.imageType` is not `NONE`.

Returns:

  • (String)


80
81
82
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 80

def label_image
  @label_image
end

#mailing_dateDate

The date on which the package will be mailed as provided in the request.

Returns:

  • (Date)


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

def mailing_date
  @mailing_date
end

#postageFloat

Amount of Postage Required, does not include insurance or other extra service fees.

Returns:

  • (Float)


37
38
39
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 37

def postage
  @postage
end

#skuString

Pricing SKU

Returns:

  • (String)


32
33
34
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 32

def sku
  @sku
end

#weightFloat

The calculated weight for the package based on user input. The greater of ‘dimensionalWeight` and `weight` will be used to calculate the rate.

Returns:

  • (Float)


56
57
58
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 56

def weight
  @weight
end

#weight_uomWeightUom1

Weight Unit of Measurement.

* lb - Pounds

Returns:



51
52
53
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 51

def weight_uom
  @weight_uom
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



169
170
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 169

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  label_address = InternationalLabelAddress.from_hash(hash['labelAddress']) if
    hash['labelAddress']
  international_tracking_number =
    hash.key?('internationalTrackingNumber') ? hash['internationalTrackingNumber'] : SKIP
  construct_code = hash.key?('constructCode') ? hash['constructCode'] : SKIP
  sku = hash.key?('SKU') ? hash['SKU'] : SKIP
  postage = hash.key?('postage') ? hash['postage'] : SKIP
  # Parameter is an array, so we need to iterate through it
  extra_services = nil
  unless hash['extraServices'].nil?
    extra_services = []
    hash['extraServices'].each do |structure|
      extra_services << (InternationalLabelsExtraServiceResponse.from_hash(structure) if structure)
    end
  end

  extra_services = SKIP unless hash.key?('extraServices')
  international_price_group =
    hash.key?('internationalPriceGroup') ? hash['internationalPriceGroup'] : SKIP
  weight_uom = hash['weightUOM'] ||= WeightUom1::LB
  weight = hash.key?('weight') ? hash['weight'] : SKIP
  dimensional_weight =
    hash.key?('dimensionalWeight') ? hash['dimensionalWeight'] : SKIP
  mailing_date = hash.key?('mailingDate') ? hash['mailingDate'] : SKIP
  # Parameter is an array, so we need to iterate through it
  fees = nil
  unless hash['fees'].nil?
    fees = []
    hash['fees'].each do |structure|
      fees << (Fee2.from_hash(structure) if structure)
    end
  end

  fees = SKIP unless hash.key?('fees')
  label_broker_id =
    hash.key?('labelBrokerID') ? hash['labelBrokerID'] : SKIP
  label_image = hash.key?('labelImage') ? hash['labelImage'] : SKIP
  label_broker_qr =
    hash.key?('labelBrokerQR') ? hash['labelBrokerQR'] : SKIP

  # 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.
  InternationalLabelVendorResponse.new(label_address: label_address,
                                       international_tracking_number: international_tracking_number,
                                       construct_code: construct_code,
                                       sku: sku,
                                       postage: postage,
                                       extra_services: extra_services,
                                       international_price_group: international_price_group,
                                       weight_uom: weight_uom,
                                       weight: weight,
                                       dimensional_weight: dimensional_weight,
                                       mailing_date: mailing_date,
                                       fees: fees,
                                       label_broker_id: label_broker_id,
                                       label_image: label_image,
                                       label_broker_qr: label_broker_qr,
                                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 88

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['label_address'] = 'labelAddress'
  @_hash['international_tracking_number'] = 'internationalTrackingNumber'
  @_hash['construct_code'] = 'constructCode'
  @_hash['sku'] = 'SKU'
  @_hash['postage'] = 'postage'
  @_hash['extra_services'] = 'extraServices'
  @_hash['international_price_group'] = 'internationalPriceGroup'
  @_hash['weight_uom'] = 'weightUOM'
  @_hash['weight'] = 'weight'
  @_hash['dimensional_weight'] = 'dimensionalWeight'
  @_hash['mailing_date'] = 'mailingDate'
  @_hash['fees'] = 'fees'
  @_hash['label_broker_id'] = 'labelBrokerID'
  @_hash['label_image'] = 'labelImage'
  @_hash['label_broker_qr'] = 'labelBrokerQR'
  @_hash
end

.nullablesObject

An array for nullable fields



130
131
132
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 130

def self.nullables
  []
end

.optionalsObject

An array for optional fields



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 109

def self.optionals
  %w[
    label_address
    international_tracking_number
    construct_code
    sku
    postage
    extra_services
    international_price_group
    weight_uom
    weight
    dimensional_weight
    mailing_date
    fees
    label_broker_id
    label_image
    label_broker_qr
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 252

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} label_address: #{@label_address.inspect}, international_tracking_number:"\
  " #{@international_tracking_number.inspect}, construct_code: #{@construct_code.inspect},"\
  " sku: #{@sku.inspect}, postage: #{@postage.inspect}, extra_services:"\
  " #{@extra_services.inspect}, international_price_group:"\
  " #{@international_price_group.inspect}, weight_uom: #{@weight_uom.inspect}, weight:"\
  " #{@weight.inspect}, dimensional_weight: #{@dimensional_weight.inspect}, mailing_date:"\
  " #{@mailing_date.inspect}, fees: #{@fees.inspect}, label_broker_id:"\
  " #{@label_broker_id.inspect}, label_image: #{@label_image.inspect}, label_broker_qr:"\
  " #{@label_broker_qr.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



240
241
242
243
244
245
246
247
248
249
# File 'lib/usps_api/models/international_label_vendor_response.rb', line 240

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} label_address: #{@label_address}, international_tracking_number:"\
  " #{@international_tracking_number}, construct_code: #{@construct_code}, sku: #{@sku},"\
  " postage: #{@postage}, extra_services: #{@extra_services}, international_price_group:"\
  " #{@international_price_group}, weight_uom: #{@weight_uom}, weight: #{@weight},"\
  " dimensional_weight: #{@dimensional_weight}, mailing_date: #{@mailing_date}, fees:"\
  " #{@fees}, label_broker_id: #{@label_broker_id}, label_image: #{@label_image},"\
  " label_broker_qr: #{@label_broker_qr}, additional_properties: #{@additional_properties}>"
end