Class: UspsApi::InternationalLabelMetadataResponse

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

Overview

Metadata information for an international label including tracking number, pricing details, postage, and extra services.

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, additional_properties: nil) ⇒ InternationalLabelMetadataResponse

Returns a new instance of InternationalLabelMetadataResponse.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/usps_api/models/international_label_metadata_response.rb', line 120

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, 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
  @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_metadata_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_metadata_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_metadata_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_metadata_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_metadata_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_metadata_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_metadata_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_metadata_response.rb', line 75

def label_broker_id
  @label_broker_id
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_metadata_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_metadata_response.rb', line 37

def postage
  @postage
end

#skuString

Pricing SKU

Returns:

  • (String)


32
33
34
# File 'lib/usps_api/models/international_label_metadata_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_metadata_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_metadata_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.



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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
# File 'lib/usps_api/models/international_label_metadata_response.rb', line 152

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

  # 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.
  InternationalLabelMetadataResponse.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,
                                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/usps_api/models/international_label_metadata_response.rb', line 78

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
end

.nullablesObject

An array for nullable fields



116
117
118
# File 'lib/usps_api/models/international_label_metadata_response.rb', line 116

def self.nullables
  []
end

.optionalsObject

An array for optional fields



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/usps_api/models/international_label_metadata_response.rb', line 97

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
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



230
231
232
233
234
235
236
237
238
239
240
# File 'lib/usps_api/models/international_label_metadata_response.rb', line 230

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}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



218
219
220
221
222
223
224
225
226
227
# File 'lib/usps_api/models/international_label_metadata_response.rb', line 218

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}, additional_properties:"\
  " #{@additional_properties}>"
end