Class: Solifyn::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/solifyn/models/order.rb

Overview

Represents an order (payment) processed under your business, containing customer, billing, product cart, and refund details.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Order

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
279
280
281
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
# File 'lib/solifyn/models/order.rb', line 174

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#amount_after_feesObject

Net amount after fees in cents.



44
45
46
# File 'lib/solifyn/models/order.rb', line 44

def amount_after_fees
  @amount_after_fees
end

#application_feeObject

Application fee in cents.



41
42
43
# File 'lib/solifyn/models/order.rb', line 41

def application_fee
  @application_fee
end

#billingObject

Billing address details.



71
72
73
# File 'lib/solifyn/models/order.rb', line 71

def billing
  @billing
end

#billing_reasonObject

Billing reason detail.



95
96
97
# File 'lib/solifyn/models/order.rb', line 95

def billing_reason
  @billing_reason
end

#business_idObject

Business unique ID identifier.



89
90
91
# File 'lib/solifyn/models/order.rb', line 89

def business_id
  @business_id
end

#business_nameObject

Business display title/name.



92
93
94
# File 'lib/solifyn/models/order.rb', line 92

def business_name
  @business_name
end

#card_last_fourObject

Last four digits of card used.



62
63
64
# File 'lib/solifyn/models/order.rb', line 62

def card_last_four
  @card_last_four
end

#card_networkObject

Card network/brand.



65
66
67
# File 'lib/solifyn/models/order.rb', line 65

def card_network
  @card_network
end

#card_typeObject

Card type.



68
69
70
# File 'lib/solifyn/models/order.rb', line 68

def card_type
  @card_type
end

#created_atObject

Payment creation timestamp.



53
54
55
# File 'lib/solifyn/models/order.rb', line 53

def created_at
  @created_at
end

#currencyObject

Currency code.



47
48
49
# File 'lib/solifyn/models/order.rb', line 47

def currency
  @currency
end

#customerObject

Customer details.



26
27
28
# File 'lib/solifyn/models/order.rb', line 26

def customer
  @customer
end

#idObject

Unique internal database identifier.



20
21
22
# File 'lib/solifyn/models/order.rb', line 20

def id
  @id
end

#invoice_urlObject

The invoice print URL.



23
24
25
# File 'lib/solifyn/models/order.rb', line 23

def invoice_url
  @invoice_url
end

#metadataObject

Custom metadata payload associated with this payment.



77
78
79
# File 'lib/solifyn/models/order.rb', line 77

def 
  @metadata
end

#orderObject

Order details snapshot.



80
81
82
# File 'lib/solifyn/models/order.rb', line 80

def order
  @order
end

Payment completion/paid timestamp.



56
57
58
# File 'lib/solifyn/models/order.rb', line 56

def paid_at
  @paid_at
end

#payment_methodObject

Payment method utilized.



59
60
61
# File 'lib/solifyn/models/order.rb', line 59

def payment_method
  @payment_method
end

#product_cartObject

Products purchased in this order.



74
75
76
# File 'lib/solifyn/models/order.rb', line 74

def product_cart
  @product_cart
end

#refundableObject

Indicates whether the order is eligible for refund.



83
84
85
# File 'lib/solifyn/models/order.rb', line 83

def refundable
  @refundable
end

#refundsObject

List of refunds associated with this payment.



86
87
88
# File 'lib/solifyn/models/order.rb', line 86

def refunds
  @refunds
end

#statusObject

Current status of the payment.



50
51
52
# File 'lib/solifyn/models/order.rb', line 50

def status
  @status
end

#subtotalObject

Subtotal amount in cents.



32
33
34
# File 'lib/solifyn/models/order.rb', line 32

def subtotal
  @subtotal
end

#tax_amountObject

Tax amount in cents.



38
39
40
# File 'lib/solifyn/models/order.rb', line 38

def tax_amount
  @tax_amount
end

#total_amountObject

Total paid amount in cents.



29
30
31
# File 'lib/solifyn/models/order.rb', line 29

def total_amount
  @total_amount
end

#usd_totalObject

Total paid amount converted to USD.



35
36
37
# File 'lib/solifyn/models/order.rb', line 35

def usd_total
  @usd_total
end

Class Method Details

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



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/solifyn/models/order.rb', line 495

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.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
    # models (e.g. Pet) or oneOf
    klass = Solifyn.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



130
131
132
# File 'lib/solifyn/models/order.rb', line 130

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/solifyn/models/order.rb', line 98

def self.attribute_map
  {
    :'id' => :'id',
    :'invoice_url' => :'invoice_url',
    :'customer' => :'customer',
    :'total_amount' => :'total_amount',
    :'subtotal' => :'subtotal',
    :'usd_total' => :'usdTotal',
    :'tax_amount' => :'tax_amount',
    :'application_fee' => :'application_fee',
    :'amount_after_fees' => :'amount_after_fees',
    :'currency' => :'currency',
    :'status' => :'status',
    :'created_at' => :'created_at',
    :'paid_at' => :'paidAt',
    :'payment_method' => :'payment_method',
    :'card_last_four' => :'card_last_four',
    :'card_network' => :'card_network',
    :'card_type' => :'card_type',
    :'billing' => :'billing',
    :'product_cart' => :'product_cart',
    :'metadata' => :'metadata',
    :'order' => :'order',
    :'refundable' => :'refundable',
    :'refunds' => :'refunds',
    :'business_id' => :'businessId',
    :'business_name' => :'businessName',
    :'billing_reason' => :'billing_reason'
  }
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



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/solifyn/models/order.rb', line 471

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



167
168
169
170
# File 'lib/solifyn/models/order.rb', line 167

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

.openapi_typesObject

Attribute type mapping.



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
# File 'lib/solifyn/models/order.rb', line 135

def self.openapi_types
  {
    :'id' => :'String',
    :'invoice_url' => :'String',
    :'customer' => :'OrderCustomer',
    :'total_amount' => :'Integer',
    :'subtotal' => :'Integer',
    :'usd_total' => :'Float',
    :'tax_amount' => :'Integer',
    :'application_fee' => :'Integer',
    :'amount_after_fees' => :'Integer',
    :'currency' => :'String',
    :'status' => :'String',
    :'created_at' => :'Time',
    :'paid_at' => :'Time',
    :'payment_method' => :'String',
    :'card_last_four' => :'String',
    :'card_network' => :'String',
    :'card_type' => :'String',
    :'billing' => :'OrderBilling',
    :'product_cart' => :'Array<OrderProductCart>',
    :'metadata' => :'Object',
    :'order' => :'OrderDetail',
    :'refundable' => :'Boolean',
    :'refunds' => :'Array<OrderRefund>',
    :'business_id' => :'String',
    :'business_name' => :'String',
    :'billing_reason' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/solifyn/models/order.rb', line 425

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      invoice_url == o.invoice_url &&
      customer == o.customer &&
      total_amount == o.total_amount &&
      subtotal == o.subtotal &&
      usd_total == o.usd_total &&
      tax_amount == o.tax_amount &&
      application_fee == o.application_fee &&
      amount_after_fees == o.amount_after_fees &&
      currency == o.currency &&
      status == o.status &&
      created_at == o.created_at &&
      paid_at == o.paid_at &&
      payment_method == o.payment_method &&
      card_last_four == o.card_last_four &&
      card_network == o.card_network &&
      card_type == o.card_type &&
      billing == o.billing &&
      product_cart == o.product_cart &&
       == o. &&
      order == o.order &&
      refundable == o.refundable &&
      refunds == o.refunds &&
      business_id == o.business_id &&
      business_name == o.business_name &&
      billing_reason == o.billing_reason
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



566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/solifyn/models/order.rb', line 566

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

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


458
459
460
# File 'lib/solifyn/models/order.rb', line 458

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



464
465
466
# File 'lib/solifyn/models/order.rb', line 464

def hash
  [id, invoice_url, customer, total_amount, subtotal, usd_total, tax_amount, application_fee, amount_after_fees, currency, status, created_at, paid_at, payment_method, card_last_four, card_network, card_type, billing, product_cart, , order, refundable, refunds, business_id, business_name, billing_reason].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
394
395
396
397
398
# File 'lib/solifyn/models/order.rb', line 330

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



542
543
544
# File 'lib/solifyn/models/order.rb', line 542

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



548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/solifyn/models/order.rb', line 548

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



536
537
538
# File 'lib/solifyn/models/order.rb', line 536

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



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/solifyn/models/order.rb', line 402

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @invoice_url.nil?
  return false if @customer.nil?
  return false if @total_amount.nil?
  return false if @subtotal.nil?
  return false if @tax_amount.nil?
  return false if @application_fee.nil?
  return false if @amount_after_fees.nil?
  return false if @currency.nil?
  return false if @status.nil?
  return false if @created_at.nil?
  return false if @payment_method.nil?
  return false if @product_cart.nil?
  return false if @refundable.nil?
  return false if @business_id.nil?
  return false if @business_name.nil?
  true
end