Class: OpenapiClient::Rate

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_client/models/rate.rb

Overview

A rate

Direct Known Subclasses

GetRateByIdResponseBody

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Rate

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/openapi_client/models/rate.rb', line 162

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Rate` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Rate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'rate_id')
    self.rate_id = attributes[:'rate_id']
  end

  if attributes.key?(:'rate_type')
    self.rate_type = attributes[:'rate_type']
  end

  if attributes.key?(:'carrier_id')
    self.carrier_id = attributes[:'carrier_id']
  end

  if attributes.key?(:'shipping_amount')
    self.shipping_amount = attributes[:'shipping_amount']
  end

  if attributes.key?(:'insurance_amount')
    self.insurance_amount = attributes[:'insurance_amount']
  end

  if attributes.key?(:'confirmation_amount')
    self.confirmation_amount = attributes[:'confirmation_amount']
  end

  if attributes.key?(:'other_amount')
    self.other_amount = attributes[:'other_amount']
  end

  if attributes.key?(:'tax_amount')
    self.tax_amount = attributes[:'tax_amount']
  end

  if attributes.key?(:'zone')
    self.zone = attributes[:'zone']
  end

  if attributes.key?(:'package_type')
    self.package_type = attributes[:'package_type']
  end

  if attributes.key?(:'delivery_days')
    self.delivery_days = attributes[:'delivery_days']
  end

  if attributes.key?(:'guaranteed_service')
    self.guaranteed_service = attributes[:'guaranteed_service']
  end

  if attributes.key?(:'estimated_delivery_date')
    self.estimated_delivery_date = attributes[:'estimated_delivery_date']
  end

  if attributes.key?(:'carrier_delivery_days')
    self.carrier_delivery_days = attributes[:'carrier_delivery_days']
  end

  if attributes.key?(:'ship_date')
    self.ship_date = attributes[:'ship_date']
  end

  if attributes.key?(:'negotiated_rate')
    self.negotiated_rate = attributes[:'negotiated_rate']
  end

  if attributes.key?(:'service_type')
    self.service_type = attributes[:'service_type']
  end

  if attributes.key?(:'service_code')
    self.service_code = attributes[:'service_code']
  end

  if attributes.key?(:'trackable')
    self.trackable = attributes[:'trackable']
  end

  if attributes.key?(:'carrier_code')
    self.carrier_code = attributes[:'carrier_code']
  end

  if attributes.key?(:'carrier_nickname')
    self.carrier_nickname = attributes[:'carrier_nickname']
  end

  if attributes.key?(:'carrier_friendly_name')
    self.carrier_friendly_name = attributes[:'carrier_friendly_name']
  end

  if attributes.key?(:'validation_status')
    self.validation_status = attributes[:'validation_status']
  end

  if attributes.key?(:'warning_messages')
    if (value = attributes[:'warning_messages']).is_a?(Array)
      self.warning_messages = value
    end
  end

  if attributes.key?(:'error_messages')
    if (value = attributes[:'error_messages']).is_a?(Array)
      self.error_messages = value
    end
  end
end

Instance Attribute Details

#carrier_codeObject

carrier code



74
75
76
# File 'lib/openapi_client/models/rate.rb', line 74

def carrier_code
  @carrier_code
end

#carrier_delivery_daysObject

The carrier delivery days



56
57
58
# File 'lib/openapi_client/models/rate.rb', line 56

def carrier_delivery_days
  @carrier_delivery_days
end

#carrier_friendly_nameObject

carrier friendly name



80
81
82
# File 'lib/openapi_client/models/rate.rb', line 80

def carrier_friendly_name
  @carrier_friendly_name
end

#carrier_idObject

A string that uniquely identifies the carrier



24
25
26
# File 'lib/openapi_client/models/rate.rb', line 24

def carrier_id
  @carrier_id
end

#carrier_nicknameObject

carrier nickname



77
78
79
# File 'lib/openapi_client/models/rate.rb', line 77

def carrier_nickname
  @carrier_nickname
end

#confirmation_amountObject

The confirmation amount



33
34
35
# File 'lib/openapi_client/models/rate.rb', line 33

def confirmation_amount
  @confirmation_amount
end

#delivery_daysObject

The number of days estimated for delivery, this will show the actual deliverty time if for example, the package gets shipped on a Friday



48
49
50
# File 'lib/openapi_client/models/rate.rb', line 48

def delivery_days
  @delivery_days
end

#error_messagesObject

The error messages



88
89
90
# File 'lib/openapi_client/models/rate.rb', line 88

def error_messages
  @error_messages
end

#estimated_delivery_dateObject

Returns the value of attribute estimated_delivery_date.



53
54
55
# File 'lib/openapi_client/models/rate.rb', line 53

def estimated_delivery_date
  @estimated_delivery_date
end

#guaranteed_serviceObject

Indicates if the rate is guaranteed.



51
52
53
# File 'lib/openapi_client/models/rate.rb', line 51

def guaranteed_service
  @guaranteed_service
end

#insurance_amountObject

The insurance amount



30
31
32
# File 'lib/openapi_client/models/rate.rb', line 30

def insurance_amount
  @insurance_amount
end

#negotiated_rateObject

Indicates if the rates been negotiated



62
63
64
# File 'lib/openapi_client/models/rate.rb', line 62

def negotiated_rate
  @negotiated_rate
end

#other_amountObject

Any other charges associated with this rate



36
37
38
# File 'lib/openapi_client/models/rate.rb', line 36

def other_amount
  @other_amount
end

#package_typeObject

package type that this rate was estimated for



45
46
47
# File 'lib/openapi_client/models/rate.rb', line 45

def package_type
  @package_type
end

#rate_idObject

A string that uniquely identifies the rate



19
20
21
# File 'lib/openapi_client/models/rate.rb', line 19

def rate_id
  @rate_id
end

#rate_typeObject

Returns the value of attribute rate_type.



21
22
23
# File 'lib/openapi_client/models/rate.rb', line 21

def rate_type
  @rate_type
end

#service_codeObject

service code for the rate



68
69
70
# File 'lib/openapi_client/models/rate.rb', line 68

def service_code
  @service_code
end

#service_typeObject

service type



65
66
67
# File 'lib/openapi_client/models/rate.rb', line 65

def service_type
  @service_type
end

#ship_dateObject

ship date



59
60
61
# File 'lib/openapi_client/models/rate.rb', line 59

def ship_date
  @ship_date
end

#shipping_amountObject

The shipping amount



27
28
29
# File 'lib/openapi_client/models/rate.rb', line 27

def shipping_amount
  @shipping_amount
end

#tax_amountObject

Tariff and additional taxes associated with an international shipment.



39
40
41
# File 'lib/openapi_client/models/rate.rb', line 39

def tax_amount
  @tax_amount
end

#trackableObject

Indicates if rate is trackable



71
72
73
# File 'lib/openapi_client/models/rate.rb', line 71

def trackable
  @trackable
end

#validation_statusObject

Returns the value of attribute validation_status.



82
83
84
# File 'lib/openapi_client/models/rate.rb', line 82

def validation_status
  @validation_status
end

#warning_messagesObject

The warning messages



85
86
87
# File 'lib/openapi_client/models/rate.rb', line 85

def warning_messages
  @warning_messages
end

#zoneObject

Certain carriers base [their rates](blog.stamps.com/2017/09/08/usps-postal-zones/) off of custom zones that vary depending upon the ship_to and ship_from location



42
43
44
# File 'lib/openapi_client/models/rate.rb', line 42

def zone
  @zone
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/openapi_client/models/rate.rb', line 91

def self.attribute_map
  {
    :'rate_id' => :'rate_id',
    :'rate_type' => :'rate_type',
    :'carrier_id' => :'carrier_id',
    :'shipping_amount' => :'shipping_amount',
    :'insurance_amount' => :'insurance_amount',
    :'confirmation_amount' => :'confirmation_amount',
    :'other_amount' => :'other_amount',
    :'tax_amount' => :'tax_amount',
    :'zone' => :'zone',
    :'package_type' => :'package_type',
    :'delivery_days' => :'delivery_days',
    :'guaranteed_service' => :'guaranteed_service',
    :'estimated_delivery_date' => :'estimated_delivery_date',
    :'carrier_delivery_days' => :'carrier_delivery_days',
    :'ship_date' => :'ship_date',
    :'negotiated_rate' => :'negotiated_rate',
    :'service_type' => :'service_type',
    :'service_code' => :'service_code',
    :'trackable' => :'trackable',
    :'carrier_code' => :'carrier_code',
    :'carrier_nickname' => :'carrier_nickname',
    :'carrier_friendly_name' => :'carrier_friendly_name',
    :'validation_status' => :'validation_status',
    :'warning_messages' => :'warning_messages',
    :'error_messages' => :'error_messages'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



585
586
587
# File 'lib/openapi_client/models/rate.rb', line 585

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



153
154
155
156
157
158
# File 'lib/openapi_client/models/rate.rb', line 153

def self.openapi_nullable
  Set.new([
    :'zone',
    :'package_type',
  ])
end

.openapi_typesObject

Attribute type mapping.



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
150
# File 'lib/openapi_client/models/rate.rb', line 122

def self.openapi_types
  {
    :'rate_id' => :'String',
    :'rate_type' => :'RateType',
    :'carrier_id' => :'String',
    :'shipping_amount' => :'MonetaryValue',
    :'insurance_amount' => :'MonetaryValue',
    :'confirmation_amount' => :'MonetaryValue',
    :'other_amount' => :'MonetaryValue',
    :'tax_amount' => :'MonetaryValue',
    :'zone' => :'Integer',
    :'package_type' => :'String',
    :'delivery_days' => :'Integer',
    :'guaranteed_service' => :'Boolean',
    :'estimated_delivery_date' => :'DateTime',
    :'carrier_delivery_days' => :'String',
    :'ship_date' => :'DateTime',
    :'negotiated_rate' => :'Boolean',
    :'service_type' => :'String',
    :'service_code' => :'String',
    :'trackable' => :'Boolean',
    :'carrier_code' => :'String',
    :'carrier_nickname' => :'String',
    :'carrier_friendly_name' => :'String',
    :'validation_status' => :'ValidationStatus',
    :'warning_messages' => :'Array<String>',
    :'error_messages' => :'Array<String>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# File 'lib/openapi_client/models/rate.rb', line 540

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      rate_id == o.rate_id &&
      rate_type == o.rate_type &&
      carrier_id == o.carrier_id &&
      shipping_amount == o.shipping_amount &&
      insurance_amount == o.insurance_amount &&
      confirmation_amount == o.confirmation_amount &&
      other_amount == o.other_amount &&
      tax_amount == o.tax_amount &&
      zone == o.zone &&
      package_type == o.package_type &&
      delivery_days == o.delivery_days &&
      guaranteed_service == o.guaranteed_service &&
      estimated_delivery_date == o.estimated_delivery_date &&
      carrier_delivery_days == o.carrier_delivery_days &&
      ship_date == o.ship_date &&
      negotiated_rate == o.negotiated_rate &&
      service_type == o.service_type &&
      service_code == o.service_code &&
      trackable == o.trackable &&
      carrier_code == o.carrier_code &&
      carrier_nickname == o.carrier_nickname &&
      carrier_friendly_name == o.carrier_friendly_name &&
      validation_status == o.validation_status &&
      warning_messages == o.warning_messages &&
      error_messages == o.error_messages
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/openapi_client/models/rate.rb', line 613

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    OpenapiClient.const_get(type).build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



682
683
684
685
686
687
688
689
690
691
692
693
694
# File 'lib/openapi_client/models/rate.rb', line 682

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
# File 'lib/openapi_client/models/rate.rb', line 592

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


572
573
574
# File 'lib/openapi_client/models/rate.rb', line 572

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



578
579
580
# File 'lib/openapi_client/models/rate.rb', line 578

def hash
  [rate_id, rate_type, carrier_id, shipping_amount, insurance_amount, confirmation_amount, other_amount, tax_amount, zone, package_type, delivery_days, guaranteed_service, estimated_delivery_date, carrier_delivery_days, ship_date, negotiated_rate, service_type, service_code, trackable, carrier_code, carrier_nickname, carrier_friendly_name, validation_status, warning_messages, error_messages].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/openapi_client/models/rate.rb', line 282

def list_invalid_properties
  invalid_properties = Array.new
  if @rate_id.nil?
    invalid_properties.push('invalid value for "rate_id", rate_id cannot be nil.')
  end

  if @rate_type.nil?
    invalid_properties.push('invalid value for "rate_type", rate_type cannot be nil.')
  end

  if @carrier_id.nil?
    invalid_properties.push('invalid value for "carrier_id", carrier_id cannot be nil.')
  end

  if @shipping_amount.nil?
    invalid_properties.push('invalid value for "shipping_amount", shipping_amount cannot be nil.')
  end

  if @insurance_amount.nil?
    invalid_properties.push('invalid value for "insurance_amount", insurance_amount cannot be nil.')
  end

  if @confirmation_amount.nil?
    invalid_properties.push('invalid value for "confirmation_amount", confirmation_amount cannot be nil.')
  end

  if @other_amount.nil?
    invalid_properties.push('invalid value for "other_amount", other_amount cannot be nil.')
  end

  if @zone < 0
    invalid_properties.push('invalid value for "zone", must be greater than or equal to 0.')
  end

  if @package_type.to_s.length < 1
    invalid_properties.push('invalid value for "package_type", the character length must be great than or equal to 1.')
  end

  if !@delivery_days.nil? && @delivery_days < 1
    invalid_properties.push('invalid value for "delivery_days", must be greater than or equal to 1.')
  end

  if @guaranteed_service.nil?
    invalid_properties.push('invalid value for "guaranteed_service", guaranteed_service cannot be nil.')
  end

  if !@carrier_delivery_days.nil? && @carrier_delivery_days.to_s.length < 1
    invalid_properties.push('invalid value for "carrier_delivery_days", the character length must be great than or equal to 1.')
  end

  if @negotiated_rate.nil?
    invalid_properties.push('invalid value for "negotiated_rate", negotiated_rate cannot be nil.')
  end

  if @service_type.nil?
    invalid_properties.push('invalid value for "service_type", service_type cannot be nil.')
  end

  if @service_type.to_s.length < 1
    invalid_properties.push('invalid value for "service_type", the character length must be great than or equal to 1.')
  end

  if @service_code.nil?
    invalid_properties.push('invalid value for "service_code", service_code cannot be nil.')
  end

  if @service_code.to_s.length < 1
    invalid_properties.push('invalid value for "service_code", the character length must be great than or equal to 1.')
  end

  if @trackable.nil?
    invalid_properties.push('invalid value for "trackable", trackable cannot be nil.')
  end

  if @carrier_code.nil?
    invalid_properties.push('invalid value for "carrier_code", carrier_code cannot be nil.')
  end

  if @carrier_code.to_s.length < 1
    invalid_properties.push('invalid value for "carrier_code", the character length must be great than or equal to 1.')
  end

  if @carrier_nickname.nil?
    invalid_properties.push('invalid value for "carrier_nickname", carrier_nickname cannot be nil.')
  end

  if @carrier_nickname.to_s.length < 1
    invalid_properties.push('invalid value for "carrier_nickname", the character length must be great than or equal to 1.')
  end

  if @carrier_friendly_name.nil?
    invalid_properties.push('invalid value for "carrier_friendly_name", carrier_friendly_name cannot be nil.')
  end

  if @carrier_friendly_name.to_s.length < 1
    invalid_properties.push('invalid value for "carrier_friendly_name", the character length must be great than or equal to 1.')
  end

  if @validation_status.nil?
    invalid_properties.push('invalid value for "validation_status", validation_status cannot be nil.')
  end

  if @warning_messages.nil?
    invalid_properties.push('invalid value for "warning_messages", warning_messages cannot be nil.')
  end

  if @error_messages.nil?
    invalid_properties.push('invalid value for "error_messages", error_messages cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



658
659
660
# File 'lib/openapi_client/models/rate.rb', line 658

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



664
665
666
667
668
669
670
671
672
673
674
675
676
# File 'lib/openapi_client/models/rate.rb', line 664

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end
    
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



652
653
654
# File 'lib/openapi_client/models/rate.rb', line 652

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/openapi_client/models/rate.rb', line 397

def valid?
  return false if @rate_id.nil?
  return false if @rate_type.nil?
  return false if @carrier_id.nil?
  return false if @shipping_amount.nil?
  return false if @insurance_amount.nil?
  return false if @confirmation_amount.nil?
  return false if @other_amount.nil?
  return false if @zone < 0
  return false if @package_type.to_s.length < 1
  return false if !@delivery_days.nil? && @delivery_days < 1
  return false if @guaranteed_service.nil?
  return false if !@carrier_delivery_days.nil? && @carrier_delivery_days.to_s.length < 1
  return false if @negotiated_rate.nil?
  return false if @service_type.nil?
  return false if @service_type.to_s.length < 1
  return false if @service_code.nil?
  return false if @service_code.to_s.length < 1
  return false if @trackable.nil?
  return false if @carrier_code.nil?
  return false if @carrier_code.to_s.length < 1
  return false if @carrier_nickname.nil?
  return false if @carrier_nickname.to_s.length < 1
  return false if @carrier_friendly_name.nil?
  return false if @carrier_friendly_name.to_s.length < 1
  return false if @validation_status.nil?
  return false if @warning_messages.nil?
  return false if @error_messages.nil?
  true
end