Class: Bfwd::Refund

Inherits:
Object
  • Object
show all
Defined in:
lib/bf_ruby2/models/refund.rb

Overview

Refund

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Refund

Initializes the object

Parameters:

  • (defaults to: {})

    Model attributes in the form of hash



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
# File 'lib/bf_ruby2/models/refund.rb', line 205

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'created')
    self.created = attributes[:'created']
  end

  if attributes.has_key?(:'changedBy')
    self.changed_by = attributes[:'changedBy']
  end

  if attributes.has_key?(:'updated')
    self.updated = attributes[:'updated']
  end

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

  if attributes.has_key?(:'organizationID')
    self.organization_id = attributes[:'organizationID']
  end

  if attributes.has_key?(:'accountID')
    self. = attributes[:'accountID']
  end

  if attributes.has_key?(:'reason')
    self.reason = attributes[:'reason']
  end

  if attributes.has_key?(:'nominalValue')
    self.nominal_value = attributes[:'nominalValue']
  end

  if attributes.has_key?(:'value')
    self.value = attributes[:'value']
  end

  if attributes.has_key?(:'refunded')
    self.refunded = attributes[:'refunded']
  end

  if attributes.has_key?(:'actualValue')
    self.actual_value = attributes[:'actualValue']
  end

  if attributes.has_key?(:'nominalRefundedValue')
    self.nominal_refunded_value = attributes[:'nominalRefundedValue']
  end

  if attributes.has_key?(:'actualRefundedValue')
    self.actual_refunded_value = attributes[:'actualRefundedValue']
  end

  if attributes.has_key?(:'refundState')
    self.refund_state = attributes[:'refundState']
  end

  if attributes.has_key?(:'refundType')
    self.refund_type = attributes[:'refundType']
  end

  if attributes.has_key?(:'refundNature')
    self.refund_nature = attributes[:'refundNature']
  end

  if attributes.has_key?(:'refundCompleted')
    self.refund_completed = attributes[:'refundCompleted']
  end

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

  if attributes.has_key?(:'paymentMethodID')
    self.payment_method_id = attributes[:'paymentMethodID']
  end

  if attributes.has_key?(:'invoicePaymentID')
    self.invoice_payment_id = attributes[:'invoicePaymentID']
  end

  if attributes.has_key?(:'refundInvoicePaymentID')
    self.refund_invoice_payment_id = attributes[:'refundInvoicePaymentID']
  end

  if attributes.has_key?(:'originalPaymentID')
    self.original_payment_id = attributes[:'originalPaymentID']
  end

  if attributes.has_key?(:'originalGatewayPaymentReference')
    self.original_gateway_payment_reference = attributes[:'originalGatewayPaymentReference']
  end

  if attributes.has_key?(:'refundPaymentID')
    self.refund_payment_id = attributes[:'refundPaymentID']
  end

  if attributes.has_key?(:'invoiceID')
    self.invoice_id = attributes[:'invoiceID']
  end

  if attributes.has_key?(:'receiptID')
    self.receipt_id = attributes[:'receiptID']
  end

  if attributes.has_key?(:'originalReceiptID')
    self.original_receipt_id = attributes[:'originalReceiptID']
  end

  if attributes.has_key?(:'createdBy')
    self.created_by = attributes[:'createdBy']
  end

end

Instance Attribute Details

#account_idObject

{ "description" : "Identifier of account to refund.", "verbs“: }



45
46
47
# File 'lib/bf_ruby2/models/refund.rb', line 45

def 
  @account_id
end

#actual_refunded_valueObject

{ "description" : "Refunded amount", "verbs":[] }



66
67
68
# File 'lib/bf_ruby2/models/refund.rb', line 66

def actual_refunded_value
  @actual_refunded_value
end

#actual_valueObject

{ "description" : "", "verbs":[] }



60
61
62
# File 'lib/bf_ruby2/models/refund.rb', line 60

def actual_value
  @actual_value
end

#changed_byObject

{ "description" : "ID of the user who last updated the entity.", "verbs":[] }



33
34
35
# File 'lib/bf_ruby2/models/refund.rb', line 33

def changed_by
  @changed_by
end

#createdObject

{ "description" : "The UTC DateTime when the object was created.", "verbs":[] }



30
31
32
# File 'lib/bf_ruby2/models/refund.rb', line 30

def created
  @created
end

#created_byObject

{ "description" : "Refund requested by this account", "verbs“: }



111
112
113
# File 'lib/bf_ruby2/models/refund.rb', line 111

def created_by
  @created_by
end

#currencyObject

{ "description" : "Currency of the refund specified by a three character ISO 4217 currency code.", "verbs“: }



81
82
83
# File 'lib/bf_ruby2/models/refund.rb', line 81

def currency
  @currency
end

#idObject

{ "description" : "", "verbs":["GET", "PUT"] }



39
40
41
# File 'lib/bf_ruby2/models/refund.rb', line 39

def id
  @id
end

#invoice_idObject

{ "description" : "Invoice to refund.", "verbs“: }



102
103
104
# File 'lib/bf_ruby2/models/refund.rb', line 102

def invoice_id
  @invoice_id
end

#invoice_payment_idObject

{ "description" : "Invoice payment to refund", "verbs":["POST", "GET"] }



87
88
89
# File 'lib/bf_ruby2/models/refund.rb', line 87

def invoice_payment_id
  @invoice_payment_id
end

#nominal_refunded_valueObject

{ "description" : "Nominal value refunded.", "verbs":[] }



63
64
65
# File 'lib/bf_ruby2/models/refund.rb', line 63

def nominal_refunded_value
  @nominal_refunded_value
end

#nominal_valueObject

{ "description" : "", "verbs":[] }



51
52
53
# File 'lib/bf_ruby2/models/refund.rb', line 51

def nominal_value
  @nominal_value
end

#organization_idObject

{ "description" : "", "verbs":[] }



42
43
44
# File 'lib/bf_ruby2/models/refund.rb', line 42

def organization_id
  @organization_id
end

#original_gateway_payment_referenceObject

{ "description" : "Reference in the gateway to the payment being refunded.", "verbs“: }



96
97
98
# File 'lib/bf_ruby2/models/refund.rb', line 96

def original_gateway_payment_reference
  @original_gateway_payment_reference
end

#original_payment_idObject

{ "description" : "Original payment being refunded.", "verbs“: }



93
94
95
# File 'lib/bf_ruby2/models/refund.rb', line 93

def original_payment_id
  @original_payment_id
end

#original_receipt_idObject

{ "description" : "ID of the receipt for the successful payment that this entity refunds.", "verbs“: }



108
109
110
# File 'lib/bf_ruby2/models/refund.rb', line 108

def original_receipt_id
  @original_receipt_id
end

#payment_method_idObject

{ "description" : "Payment method to refund from", "verbs“: }



84
85
86
# File 'lib/bf_ruby2/models/refund.rb', line 84

def payment_method_id
  @payment_method_id
end

#reasonObject

{ "description" : "The reason for the refund.", "verbs“: }



48
49
50
# File 'lib/bf_ruby2/models/refund.rb', line 48

def reason
  @reason
end

#receipt_idObject

{ "description" : "ID of the receipt for this refund.", "verbs“: }



105
106
107
# File 'lib/bf_ruby2/models/refund.rb', line 105

def receipt_id
  @receipt_id
end

#refund_completedObject

{ "description" : "When the refund was completed", "verbs“: }



78
79
80
# File 'lib/bf_ruby2/models/refund.rb', line 78

def refund_completed
  @refund_completed
end

#refund_invoice_payment_idObject

{ "description" : "", "verbs":[] }



90
91
92
# File 'lib/bf_ruby2/models/refund.rb', line 90

def refund_invoice_payment_id
  @refund_invoice_payment_id
end

#refund_natureObject

class=\"label label-default\">SingleAttempt</span>","description":The mechanism by which credit is returned to the customer:
<span class=\"label label-default\">Void</span> &mdash; The original authorized payment is voided before capture.
<span class=\"label label-default\">Refund</span> &mdash; A refund is issued against an already-captured payment.“,”verbs“:



75
76
77
# File 'lib/bf_ruby2/models/refund.rb', line 75

def refund_nature
  @refund_nature
end

#refund_payment_idObject

{ "description" : "Identifier for the payment used to refund", "verbs“: }



99
100
101
# File 'lib/bf_ruby2/models/refund.rb', line 99

def refund_payment_id
  @refund_payment_id
end

#refund_stateObject

{ "default" : "AwaitingRefund", "PUT_description" : "<span class=\"label label-default\">Pending</span> refunds can be set to <span class=\"label label-default\">AwaitingRefund</span> to initiate the refund or <span class=\"label label-default\">Cancelled</span> to stop the refund.", "description" : "Initially a refund is in the <span class=\"label label-default\">AwaitingRefund</span> state. Once the funds are successfully returned the state is <span class=\"label label-default\">Refunded</span>. If the refund fails or is rejected is it set as <span class=\"label label-default\">Failed</span>. Refunds can be set to a <span class=\"label label-default\">Pending</span> state to support authorization flows, and will leave the refund pending until updated to <span class=\"label label-default\">AwaitingRefund</span>. <span class=\"label label-default\">Cancelled</span> is when a refund will not be executed.", "verbs":["GET", "POST", "PUT"] }



69
70
71
# File 'lib/bf_ruby2/models/refund.rb', line 69

def refund_state
  @refund_state
end

#refund_typeObject

{ "description" : "This is the type of refund. Refunds are associated with either an invoice and payment, a payment or unreferenced.", "verbs":[] }



72
73
74
# File 'lib/bf_ruby2/models/refund.rb', line 72

def refund_type
  @refund_type
end

#refundedObject

{ "description" : "Value refunded", "verbs“: }



57
58
59
# File 'lib/bf_ruby2/models/refund.rb', line 57

def refunded
  @refunded
end

#updatedObject

{ "description" : "The UTC DateTime when the object was last updated.", "verbs":[] }



36
37
38
# File 'lib/bf_ruby2/models/refund.rb', line 36

def updated
  @updated
end

#valueObject

{ "description" : "Positive decimal representing the total value to refund. This is at most the amount un-refunded on the payment. If amount is the total payment amount is refunded.", "verbs“: }



54
55
56
# File 'lib/bf_ruby2/models/refund.rb', line 54

def value
  @value
end

Class Method Details

.attribute_mapObject

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



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
# File 'lib/bf_ruby2/models/refund.rb', line 136

def self.attribute_map
  {
    :'created' => :'created',
    :'changed_by' => :'changedBy',
    :'updated' => :'updated',
    :'id' => :'id',
    :'organization_id' => :'organizationID',
    :'account_id' => :'accountID',
    :'reason' => :'reason',
    :'nominal_value' => :'nominalValue',
    :'value' => :'value',
    :'refunded' => :'refunded',
    :'actual_value' => :'actualValue',
    :'nominal_refunded_value' => :'nominalRefundedValue',
    :'actual_refunded_value' => :'actualRefundedValue',
    :'refund_state' => :'refundState',
    :'refund_type' => :'refundType',
    :'refund_nature' => :'refundNature',
    :'refund_completed' => :'refundCompleted',
    :'currency' => :'currency',
    :'payment_method_id' => :'paymentMethodID',
    :'invoice_payment_id' => :'invoicePaymentID',
    :'refund_invoice_payment_id' => :'refundInvoicePaymentID',
    :'original_payment_id' => :'originalPaymentID',
    :'original_gateway_payment_reference' => :'originalGatewayPaymentReference',
    :'refund_payment_id' => :'refundPaymentID',
    :'invoice_id' => :'invoiceID',
    :'receipt_id' => :'receiptID',
    :'original_receipt_id' => :'originalReceiptID',
    :'created_by' => :'createdBy'
  }
end

.swagger_typesObject

Attribute type mapping.



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
# File 'lib/bf_ruby2/models/refund.rb', line 170

def self.swagger_types
  {
    :'created' => :'DateTime',
    :'changed_by' => :'String',
    :'updated' => :'DateTime',
    :'id' => :'String',
    :'organization_id' => :'String',
    :'account_id' => :'String',
    :'reason' => :'String',
    :'nominal_value' => :'Float',
    :'value' => :'Float',
    :'refunded' => :'Float',
    :'actual_value' => :'Float',
    :'nominal_refunded_value' => :'Float',
    :'actual_refunded_value' => :'Float',
    :'refund_state' => :'String',
    :'refund_type' => :'String',
    :'refund_nature' => :'String',
    :'refund_completed' => :'DateTime',
    :'currency' => :'String',
    :'payment_method_id' => :'String',
    :'invoice_payment_id' => :'String',
    :'refund_invoice_payment_id' => :'String',
    :'original_payment_id' => :'String',
    :'original_gateway_payment_reference' => :'String',
    :'refund_payment_id' => :'String',
    :'invoice_id' => :'String',
    :'receipt_id' => :'String',
    :'original_receipt_id' => :'String',
    :'created_by' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • to be compared



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/bf_ruby2/models/refund.rb', line 384

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created == o.created &&
      changed_by == o.changed_by &&
      updated == o.updated &&
      id == o.id &&
      organization_id == o.organization_id &&
       == o. &&
      reason == o.reason &&
      nominal_value == o.nominal_value &&
      value == o.value &&
      refunded == o.refunded &&
      actual_value == o.actual_value &&
      nominal_refunded_value == o.nominal_refunded_value &&
      actual_refunded_value == o.actual_refunded_value &&
      refund_state == o.refund_state &&
      refund_type == o.refund_type &&
      refund_nature == o.refund_nature &&
      refund_completed == o.refund_completed &&
      currency == o.currency &&
      payment_method_id == o.payment_method_id &&
      invoice_payment_id == o.invoice_payment_id &&
      refund_invoice_payment_id == o.refund_invoice_payment_id &&
      original_payment_id == o.original_payment_id &&
      original_gateway_payment_reference == o.original_gateway_payment_reference &&
      refund_payment_id == o.refund_payment_id &&
      invoice_id == o.invoice_id &&
      receipt_id == o.receipt_id &&
      original_receipt_id == o.original_receipt_id &&
      created_by == o.created_by
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • type Data type

  • value Value to be deserialized

Returns:

  • Deserialized data



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/bf_ruby2/models/refund.rb', line 453

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 =~ /^(true|t|yes|y|1)$/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
    temp_model = Bfwd.const_get(type).new
    temp_model.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:

  • Any valid value

Returns:

  • Returns the value in the form of hash



519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/bf_ruby2/models/refund.rb', line 519

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:

  • Model attributes in the form of hash

Returns:

  • Returns the model itself



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/bf_ruby2/models/refund.rb', line 432

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the 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:

  • to be compared

Returns:

See Also:

  • `==` method


419
420
421
# File 'lib/bf_ruby2/models/refund.rb', line 419

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • Hash code



425
426
427
# File 'lib/bf_ruby2/models/refund.rb', line 425

def hash
  [created, changed_by, updated, id, organization_id, , reason, nominal_value, value, refunded, actual_value, nominal_refunded_value, actual_refunded_value, refund_state, refund_type, refund_nature, refund_completed, currency, payment_method_id, invoice_payment_id, refund_invoice_payment_id, original_payment_id, original_gateway_payment_reference, refund_payment_id, invoice_id, receipt_id, original_receipt_id, created_by].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



327
328
329
330
# File 'lib/bf_ruby2/models/refund.rb', line 327

def list_invalid_properties
  invalid_properties = Array.new
  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • Returns the object in the form of hash



499
500
501
# File 'lib/bf_ruby2/models/refund.rb', line 499

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • Returns the object in the form of hash



505
506
507
508
509
510
511
512
513
# File 'lib/bf_ruby2/models/refund.rb', line 505

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • String presentation of the object



493
494
495
# File 'lib/bf_ruby2/models/refund.rb', line 493

def to_s
  to_hash.to_s
end

#valid?Boolean

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

Returns:

  • true if the model is valid



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/bf_ruby2/models/refund.rb', line 334

def valid?
  return false if @nominal_value.nil?
  return false if @actual_value.nil?
  return false if @nominal_refunded_value.nil?
  return false if @actual_refunded_value.nil?
  return false if @refund_state.nil?
  refund_state_validator = EnumAttributeValidator.new('String', ["Pending", "AwaitingRefund", "Refunded", "Cancelled", "Failed"])
  return false unless refund_state_validator.valid?(@refund_state)
  return false if @refund_type.nil?
  refund_type_validator = EnumAttributeValidator.new('String', ["InvoicePayment", "Payment"])
  return false unless refund_type_validator.valid?(@refund_type)
  return false if @refund_nature.nil?
  refund_nature_validator = EnumAttributeValidator.new('String', ["Refund", "Void"])
  return false unless refund_nature_validator.valid?(@refund_nature)
  return false if @currency.nil?
  return true
end