Class: HelloextendApiClient::Contract

Inherits:
Object
  • Object
show all
Defined in:
lib/helloextend_api_client/models/contract.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Contract

Initializes the object

Parameters:

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

    Model attributes in the form of hash



116
117
118
119
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
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
# File 'lib/helloextend_api_client/models/contract.rb', line 116

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `HelloextendApiClient::Contract` 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 `HelloextendApiClient::Contract`. 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?(:'id')
    self.id = attributes[:'id']
  end

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#created_atObject

The timestamp when the object was created (internal).



21
22
23
# File 'lib/helloextend_api_client/models/contract.rb', line 21

def created_at
  @created_at
end

#currencyObject

This is an ISO-4217 currency code. See <a href=‘en.wikipedia.org/wiki/ISO_4217’>en.wikipedia.org/wiki/ISO_4217</a> for more information



40
41
42
# File 'lib/helloextend_api_client/models/contract.rb', line 40

def currency
  @currency
end

#customerObject

Returns the value of attribute customer.



35
36
37
# File 'lib/helloextend_api_client/models/contract.rb', line 35

def customer
  @customer
end

#idObject

The unique Extend ID for the warranty contract. Use this for reference when recording returns / refunds.



18
19
20
# File 'lib/helloextend_api_client/models/contract.rb', line 18

def id
  @id
end

#planObject

Returns the value of attribute plan.



45
46
47
# File 'lib/helloextend_api_client/models/contract.rb', line 45

def plan
  @plan
end

#po_numberObject

An optional merchant generated purchase order number used for reconciliation



30
31
32
# File 'lib/helloextend_api_client/models/contract.rb', line 30

def po_number
  @po_number
end

#productObject

Returns the value of attribute product.



37
38
39
# File 'lib/helloextend_api_client/models/contract.rb', line 37

def product
  @product
end

#statusObject

The current status of the contract. When requesting a refund, this will have a different value.



48
49
50
# File 'lib/helloextend_api_client/models/contract.rb', line 48

def status
  @status
end

#transaction_dateObject

The sale transaction date. The warranty contract term is based on this date. This is the epoch time as an integer.



43
44
45
# File 'lib/helloextend_api_client/models/contract.rb', line 43

def transaction_date
  @transaction_date
end

#transaction_idObject

Your store’s unique transaction identifier, which may be used to query for transactions in the future



27
28
29
# File 'lib/helloextend_api_client/models/contract.rb', line 27

def transaction_id
  @transaction_id
end

#transaction_totalObject

The total sale transaction amount, in the base unit (i.e. cents) with no currency code. This will help us more easily find transactions and associated warranty contracts during the claims process.



33
34
35
# File 'lib/helloextend_api_client/models/contract.rb', line 33

def transaction_total
  @transaction_total
end

#updated_atObject

The timestamp when the object was updated (internal).



24
25
26
# File 'lib/helloextend_api_client/models/contract.rb', line 24

def updated_at
  @updated_at
end

Class Method Details

.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
88
# File 'lib/helloextend_api_client/models/contract.rb', line 73

def self.attribute_map
  {
    :'id' => :'id',
    :'created_at' => :'createdAt',
    :'updated_at' => :'updatedAt',
    :'transaction_id' => :'transactionId',
    :'po_number' => :'poNumber',
    :'transaction_total' => :'transactionTotal',
    :'customer' => :'customer',
    :'product' => :'product',
    :'currency' => :'currency',
    :'transaction_date' => :'transactionDate',
    :'plan' => :'plan',
    :'status' => :'status'
  }
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



267
268
269
# File 'lib/helloextend_api_client/models/contract.rb', line 267

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

.openapi_nullableObject

List of attributes with nullable: true



109
110
111
112
# File 'lib/helloextend_api_client/models/contract.rb', line 109

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/helloextend_api_client/models/contract.rb', line 91

def self.openapi_types
  {
    :'id' => :'String',
    :'created_at' => :'Float',
    :'updated_at' => :'Float',
    :'transaction_id' => :'String',
    :'po_number' => :'String',
    :'transaction_total' => :'Integer',
    :'customer' => :'Customer',
    :'product' => :'ContractProduct',
    :'currency' => :'String',
    :'transaction_date' => :'Float',
    :'plan' => :'ContractPlan',
    :'status' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/helloextend_api_client/models/contract.rb', line 235

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      created_at == o.created_at &&
      updated_at == o.updated_at &&
      transaction_id == o.transaction_id &&
      po_number == o.po_number &&
      transaction_total == o.transaction_total &&
      customer == o.customer &&
      product == o.product &&
      currency == o.currency &&
      transaction_date == o.transaction_date &&
      plan == o.plan &&
      status == o.status
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



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
# File 'lib/helloextend_api_client/models/contract.rb', line 295

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
    HelloextendApiClient.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



364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/helloextend_api_client/models/contract.rb', line 364

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



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/helloextend_api_client/models/contract.rb', line 274

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


254
255
256
# File 'lib/helloextend_api_client/models/contract.rb', line 254

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



260
261
262
# File 'lib/helloextend_api_client/models/contract.rb', line 260

def hash
  [id, created_at, updated_at, transaction_id, po_number, transaction_total, customer, product, currency, transaction_date, plan, status].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/helloextend_api_client/models/contract.rb', line 180

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

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

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

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

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

  if @plan.nil?
    invalid_properties.push('invalid value for "plan", plan 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



340
341
342
# File 'lib/helloextend_api_client/models/contract.rb', line 340

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



346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/helloextend_api_client/models/contract.rb', line 346

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



334
335
336
# File 'lib/helloextend_api_client/models/contract.rb', line 334

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



211
212
213
214
215
216
217
218
219
220
221
# File 'lib/helloextend_api_client/models/contract.rb', line 211

def valid?
  return false if @transaction_id.nil?
  return false if @customer.nil?
  return false if @product.nil?
  return false if @currency.nil?
  return false if @transaction_date.nil?
  return false if @plan.nil?
  status_validator = EnumAttributeValidator.new('String', ["live", "refund_requested", "refund_accepted", "refund_paid", "refund_denied", "expired"])
  return false unless status_validator.valid?(@status)
  true
end