Class: AdvancedBilling::Refund
- Defined in:
- lib/advanced_billing/models/refund.rb
Overview
Refund Model.
Instance Attribute Summary collapse
-
#amount ⇒ String
The amount to be refunded in decimal format as a string.
-
#apply_credit ⇒ TrueClass | FalseClass
If set to true, creates credit and applies it to an invoice.
-
#external ⇒ TrueClass | FalseClass
Flag that marks refund as external (no money is returned to the customer).
-
#memo ⇒ String
A description that will be attached to the refund.
-
#payment_id ⇒ Integer
The ID of the payment to be refunded.
-
#segment_uids ⇒ Object
An array of segment uids to refund or the string ‘all’ to indicate that all segments should be refunded.
-
#void_invoice ⇒ TrueClass | FalseClass
If ‘apply_credit` set to false and refunding full amount, if `void_invoice` set to true, invoice will be voided after refund.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(amount = SKIP, memo = SKIP, payment_id = SKIP, external = SKIP, apply_credit = SKIP, void_invoice = SKIP, segment_uids = SKIP) ⇒ Refund
constructor
A new instance of Refund.
Methods inherited from BaseModel
Constructor Details
#initialize(amount = SKIP, memo = SKIP, payment_id = SKIP, external = SKIP, apply_credit = SKIP, void_invoice = SKIP, segment_uids = SKIP) ⇒ Refund
Returns a new instance of Refund.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/advanced_billing/models/refund.rb', line 77 def initialize(amount = SKIP, memo = SKIP, payment_id = SKIP, external = SKIP, apply_credit = SKIP, void_invoice = SKIP, segment_uids = SKIP) @amount = amount unless amount == SKIP @memo = memo unless memo == SKIP @payment_id = payment_id unless payment_id == SKIP @external = external unless external == SKIP @apply_credit = apply_credit unless apply_credit == SKIP @void_invoice = void_invoice unless void_invoice == SKIP @segment_uids = segment_uids unless segment_uids == SKIP end |
Instance Attribute Details
#amount ⇒ String
The amount to be refunded in decimal format as a string. Example: “10.50”. Must not exceed the remaining refundable balance of the payment.
15 16 17 |
# File 'lib/advanced_billing/models/refund.rb', line 15 def amount @amount end |
#apply_credit ⇒ TrueClass | FalseClass
If set to true, creates credit and applies it to an invoice. Defaults to ‘false`.
33 34 35 |
# File 'lib/advanced_billing/models/refund.rb', line 33 def apply_credit @apply_credit end |
#external ⇒ TrueClass | FalseClass
Flag that marks refund as external (no money is returned to the customer). Defaults to ‘false`.
28 29 30 |
# File 'lib/advanced_billing/models/refund.rb', line 28 def external @external end |
#memo ⇒ String
A description that will be attached to the refund
19 20 21 |
# File 'lib/advanced_billing/models/refund.rb', line 19 def memo @memo end |
#payment_id ⇒ Integer
The ID of the payment to be refunded
23 24 25 |
# File 'lib/advanced_billing/models/refund.rb', line 23 def payment_id @payment_id end |
#segment_uids ⇒ Object
An array of segment uids to refund or the string ‘all’ to indicate that all segments should be refunded
44 45 46 |
# File 'lib/advanced_billing/models/refund.rb', line 44 def segment_uids @segment_uids end |
#void_invoice ⇒ TrueClass | FalseClass
If ‘apply_credit` set to false and refunding full amount, if `void_invoice` set to true, invoice will be voided after refund. Defaults to `false`.
39 40 41 |
# File 'lib/advanced_billing/models/refund.rb', line 39 def void_invoice @void_invoice end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/advanced_billing/models/refund.rb', line 90 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : SKIP memo = hash.key?('memo') ? hash['memo'] : SKIP payment_id = hash.key?('payment_id') ? hash['payment_id'] : SKIP external = hash.key?('external') ? hash['external'] : SKIP apply_credit = hash.key?('apply_credit') ? hash['apply_credit'] : SKIP void_invoice = hash.key?('void_invoice') ? hash['void_invoice'] : SKIP segment_uids = hash.key?('segment_uids') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:RefundSegmentUids), hash['segment_uids'] ) : SKIP # Create object from extracted values. Refund.new(amount, memo, payment_id, external, apply_credit, void_invoice, segment_uids) end |
.names ⇒ Object
A mapping from model property names to API property names.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/advanced_billing/models/refund.rb', line 47 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['memo'] = 'memo' @_hash['payment_id'] = 'payment_id' @_hash['external'] = 'external' @_hash['apply_credit'] = 'apply_credit' @_hash['void_invoice'] = 'void_invoice' @_hash['segment_uids'] = 'segment_uids' @_hash end |
.nullables ⇒ Object
An array for nullable fields
73 74 75 |
# File 'lib/advanced_billing/models/refund.rb', line 73 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/advanced_billing/models/refund.rb', line 60 def self.optionals %w[ amount memo payment_id external apply_credit void_invoice segment_uids ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
116 117 118 119 120 121 122 |
# File 'lib/advanced_billing/models/refund.rb', line 116 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |