Class: AdvancedBilling::RefundConsolidatedInvoice
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::RefundConsolidatedInvoice
- Defined in:
- lib/advanced_billing/models/refund_consolidated_invoice.rb
Overview
Refund consolidated invoice
Instance Attribute Summary collapse
-
#amount ⇒ String
The amount of payment to be refunded in decimal format.
-
#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 for 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.
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(memo:, payment_id:, segment_uids:, external: SKIP, apply_credit: SKIP, amount: SKIP, additional_properties: {}) ⇒ RefundConsolidatedInvoice
constructor
A new instance of RefundConsolidatedInvoice.
Methods inherited from BaseModel
Constructor Details
#initialize(memo:, payment_id:, segment_uids:, external: SKIP, apply_credit: SKIP, amount: SKIP, additional_properties: {}) ⇒ RefundConsolidatedInvoice
Returns a new instance of RefundConsolidatedInvoice.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 66 def initialize(memo:, payment_id:, segment_uids:, external: SKIP, apply_credit: SKIP, amount: SKIP, additional_properties: {}) @memo = memo @payment_id = payment_id @segment_uids = segment_uids @external = external unless external == SKIP @apply_credit = apply_credit unless apply_credit == SKIP @amount = amount unless amount == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#amount ⇒ String
The amount of payment to be refunded in decimal format. Example: “10.50”. This will default to the full amount of the payment if not provided.
38 39 40 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 38 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_consolidated_invoice.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_consolidated_invoice.rb', line 28 def external @external end |
#memo ⇒ String
A description for the refund
14 15 16 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 14 def memo @memo end |
#payment_id ⇒ Integer
The ID of the payment to be refunded
18 19 20 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 18 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
23 24 25 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 23 def segment_uids @segment_uids end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 82 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. memo = hash.key?('memo') ? hash['memo'] : nil payment_id = hash.key?('payment_id') ? hash['payment_id'] : nil segment_uids = hash.key?('segment_uids') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:RefundConsolidatedInvoiceSegmentUids), hash['segment_uids'] ) : nil external = hash.key?('external') ? hash['external'] : SKIP apply_credit = hash.key?('apply_credit') ? hash['apply_credit'] : SKIP amount = hash.key?('amount') ? hash['amount'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. RefundConsolidatedInvoice.new(memo: memo, payment_id: payment_id, segment_uids: segment_uids, external: external, apply_credit: apply_credit, amount: amount, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['memo'] = 'memo' @_hash['payment_id'] = 'payment_id' @_hash['segment_uids'] = 'segment_uids' @_hash['external'] = 'external' @_hash['apply_credit'] = 'apply_credit' @_hash['amount'] = 'amount' @_hash end |
.nullables ⇒ Object
An array for nullable fields
62 63 64 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 62 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
53 54 55 56 57 58 59 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 53 def self.optionals %w[ external apply_credit amount ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/advanced_billing/models/refund_consolidated_invoice.rb', line 110 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.memo, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.payment_id, ->(val) { val.instance_of? Integer }) and UnionTypeLookUp.get(:RefundConsolidatedInvoiceSegmentUids) .validate(value.segment_uids) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['memo'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['payment_id'], ->(val) { val.instance_of? Integer }) and UnionTypeLookUp.get(:RefundConsolidatedInvoiceSegmentUids) .validate(value['segment_uids']) ) end |