Class: Zippendo::CreateShipment201ResponseParcelsInner

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/zippendo/models/create_shipment201_response_parcels_inner.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ CreateShipment201ResponseParcelsInner

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 130

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

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

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

  if attributes.key?(:'weight')
    self.weight = attributes[:'weight']
  else
    self.weight = nil
  end

  if attributes.key?(:'weight_unit')
    self.weight_unit = attributes[:'weight_unit']
  else
    self.weight_unit = nil
  end

  if attributes.key?(:'dimensions')
    self.dimensions = attributes[:'dimensions']
  else
    self.dimensions = nil
  end

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

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

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

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

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

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

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

Instance Attribute Details

#dimensionsObject

Returns the value of attribute dimensions.



27
28
29
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 27

def dimensions
  @dimensions
end

#idObject

Unique parcel identifier.



19
20
21
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 19

def id
  @id
end

#label_free_codeObject

Label-free drop-off code for the parcel.



39
40
41
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 39

def label_free_code
  @label_free_code
end

#order_linesObject

Order lines contained in this parcel.



30
31
32
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 30

def order_lines
  @order_lines
end

#qr_code_data_uriObject

Embeddable data: URI of the QR code image for label-free drop-off — base64 image bytes you can drop straight into an /email. Null when the carrier returns a hosted link instead (see qrCodeUrl).



45
46
47
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 45

def qr_code_data_uri
  @qr_code_data_uri
end

DEPRECATED — use qrCodeDataUri (embeddable data URI) or qrCodeUrl (hosted link). Catch-all that carries whichever applies, kept populated for backwards compatibility during the migration and until it is disabled.



42
43
44
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 42

def qr_code_link
  @qr_code_link
end

#qr_code_urlObject

Carrier-hosted URL of the QR code image for label-free drop-off, returned by carriers (e.g. Bring) that link to the image rather than embedding it. Null when the carrier returns embeddable bytes (see qrCodeDataUri).



48
49
50
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 48

def qr_code_url
  @qr_code_url
end

#tracking_numberObject

Carrier tracking number for this parcel.



33
34
35
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 33

def tracking_number
  @tracking_number
end

#tracking_urlObject

Public carrier tracking URL for this parcel.



36
37
38
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 36

def tracking_url
  @tracking_url
end

#weightObject

Parcel weight in the given weight unit.



22
23
24
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 22

def weight
  @weight
end

#weight_unitObject

Unit of measurement for parcel weight.



25
26
27
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 25

def weight_unit
  @weight_unit
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



90
91
92
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 90

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



95
96
97
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 95

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 73

def self.attribute_map
  {
    :'id' => :'id',
    :'weight' => :'weight',
    :'weight_unit' => :'weightUnit',
    :'dimensions' => :'dimensions',
    :'order_lines' => :'orderLines',
    :'tracking_number' => :'trackingNumber',
    :'tracking_url' => :'trackingUrl',
    :'label_free_code' => :'labelFreeCode',
    :'qr_code_link' => :'qrCodeLink',
    :'qr_code_data_uri' => :'qrCodeDataUri',
    :'qr_code_url' => :'qrCodeUrl'
  }
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



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 318

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif 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[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



117
118
119
120
121
122
123
124
125
126
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 117

def self.openapi_nullable
  Set.new([
    :'tracking_number',
    :'tracking_url',
    :'label_free_code',
    :'qr_code_link',
    :'qr_code_data_uri',
    :'qr_code_url'
  ])
end

.openapi_typesObject

Attribute type mapping.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 100

def self.openapi_types
  {
    :'id' => :'String',
    :'weight' => :'Float',
    :'weight_unit' => :'String',
    :'dimensions' => :'CreateShipment201ResponseParcelsInnerDimensions',
    :'order_lines' => :'Array<CreateShipment201ResponseParcelsInnerOrderLinesInner>',
    :'tracking_number' => :'String',
    :'tracking_url' => :'String',
    :'label_free_code' => :'String',
    :'qr_code_link' => :'String',
    :'qr_code_data_uri' => :'String',
    :'qr_code_url' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 287

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      weight == o.weight &&
      weight_unit == o.weight_unit &&
      dimensions == o.dimensions &&
      order_lines == o.order_lines &&
      tracking_number == o.tracking_number &&
      tracking_url == o.tracking_url &&
      label_free_code == o.label_free_code &&
      qr_code_link == o.qr_code_link &&
      qr_code_data_uri == o.qr_code_data_uri &&
      qr_code_url == o.qr_code_url
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


305
306
307
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 305

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



311
312
313
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 311

def hash
  [id, weight, weight_unit, dimensions, order_lines, tracking_number, tracking_url, label_free_code, qr_code_link, qr_code_data_uri, qr_code_url].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 201

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @weight.nil?
    invalid_properties.push('invalid value for "weight", weight cannot be nil.')
  end

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

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

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

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 340

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

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



229
230
231
232
233
234
235
236
237
238
239
# File 'lib/zippendo/models/create_shipment201_response_parcels_inner.rb', line 229

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @weight.nil?
  return false if @weight < 0
  return false if @weight_unit.nil?
  weight_unit_validator = EnumAttributeValidator.new('String', ["kg", "g", "lb", "oz"])
  return false unless weight_unit_validator.valid?(@weight_unit)
  return false if @dimensions.nil?
  return false if @order_lines.nil?
  true
end