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



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

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“: }



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

def 
  @account_id
end

#actual_refunded_valueObject

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



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

def actual_refunded_value
  @actual_refunded_value
end

#actual_valueObject

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



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

def actual_value
  @actual_value
end

#changed_byObject

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



22
23
24
# File 'lib/bf_ruby2/models/refund.rb', line 22

def changed_by
  @changed_by
end

#createdObject

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



19
20
21
# File 'lib/bf_ruby2/models/refund.rb', line 19

def created
  @created
end

#created_byObject

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



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

def created_by
  @created_by
end

#currencyObject

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



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

def currency
  @currency
end

#idObject

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



28
29
30
# File 'lib/bf_ruby2/models/refund.rb', line 28

def id
  @id
end

#invoice_idObject

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



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

def invoice_id
  @invoice_id
end

#invoice_payment_idObject

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



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

def invoice_payment_id
  @invoice_payment_id
end

#nominal_refunded_valueObject

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



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

def nominal_refunded_value
  @nominal_refunded_value
end

#nominal_valueObject

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



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

def nominal_value
  @nominal_value
end

#organization_idObject

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



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

def organization_id
  @organization_id
end

#original_gateway_payment_referenceObject

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



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

def original_gateway_payment_reference
  @original_gateway_payment_reference
end

#original_payment_idObject

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



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

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“: }



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

def original_receipt_id
  @original_receipt_id
end

#payment_method_idObject

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



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

def payment_method_id
  @payment_method_id
end

#reasonObject

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



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

def reason
  @reason
end

#receipt_idObject

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



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

def receipt_id
  @receipt_id
end

#refund_completedObject

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



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

def refund_completed
  @refund_completed
end

#refund_invoice_payment_idObject

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



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

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“:



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

def refund_nature
  @refund_nature
end

#refund_payment_idObject

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



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

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"] }



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

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":[] }



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

def refund_type
  @refund_type
end

#refundedObject

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



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

def refunded
  @refunded
end

#updatedObject

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



25
26
27
# File 'lib/bf_ruby2/models/refund.rb', line 25

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“: }



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

def value
  @value
end

Class Method Details

.attribute_mapObject

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



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

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.



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

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.



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/bf_ruby2/models/refund.rb', line 405

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



474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/bf_ruby2/models/refund.rb', line 474

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



540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/bf_ruby2/models/refund.rb', line 540

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



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/bf_ruby2/models/refund.rb', line 453

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/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

See Also:

  • `==` method


440
441
442
# File 'lib/bf_ruby2/models/refund.rb', line 440

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.



446
447
448
# File 'lib/bf_ruby2/models/refund.rb', line 446

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?



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

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

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

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

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

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

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

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

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

  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



520
521
522
# File 'lib/bf_ruby2/models/refund.rb', line 520

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



526
527
528
529
530
531
532
533
534
# File 'lib/bf_ruby2/models/refund.rb', line 526

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



514
515
516
# File 'lib/bf_ruby2/models/refund.rb', line 514

def to_s
  to_hash.to_s
end

#valid?Boolean

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



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/bf_ruby2/models/refund.rb', line 355

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