Class: AdvancedBilling::RefundPrepayment
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::RefundPrepayment
- Defined in:
- lib/advanced_billing/models/refund_prepayment.rb
Overview
RefundPrepayment Model.
Instance Attribute Summary collapse
-
#amount ⇒ Object
‘amount_in_cents` is not required if you pass `amount`.
-
#amount_in_cents ⇒ Integer
‘amount` is not required if you pass `amount_in_cents`.
-
#external ⇒ TrueClass | FalseClass
Specify the type of refund you wish to initiate.
-
#memo ⇒ String
‘amount_in_cents` is not required if you pass `amount`.
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_in_cents:, amount:, memo:, external: SKIP, additional_properties: {}) ⇒ RefundPrepayment
constructor
A new instance of RefundPrepayment.
Methods inherited from BaseModel
Constructor Details
#initialize(amount_in_cents:, amount:, memo:, external: SKIP, additional_properties: {}) ⇒ RefundPrepayment
Returns a new instance of RefundPrepayment.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 54 def initialize(amount_in_cents:, amount:, memo:, external: SKIP, additional_properties: {}) @amount_in_cents = amount_in_cents @amount = amount @memo = memo @external = external unless external == 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 ⇒ Object
‘amount_in_cents` is not required if you pass `amount`.
18 19 20 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 18 def amount @amount end |
#amount_in_cents ⇒ Integer
‘amount` is not required if you pass `amount_in_cents`.
14 15 16 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 14 def amount_in_cents @amount_in_cents end |
#external ⇒ TrueClass | FalseClass
Specify the type of refund you wish to initiate. When the prepayment is external, the ‘external` flag is optional. But if the prepayment was made through a payment profile, the `external` flag is required.
28 29 30 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 28 def external @external end |
#memo ⇒ String
‘amount_in_cents` is not required if you pass `amount`.
22 23 24 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 22 def memo @memo end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 68 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount_in_cents = hash.key?('amount_in_cents') ? hash['amount_in_cents'] : nil amount = hash.key?('amount') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:RefundPrepaymentAmount), hash['amount'] ) : nil memo = hash.key?('memo') ? hash['memo'] : nil external = hash.key?('external') ? hash['external'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. RefundPrepayment.new(amount_in_cents: amount_in_cents, amount: amount, memo: memo, external: external, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
31 32 33 34 35 36 37 38 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 31 def self.names @_hash = {} if @_hash.nil? @_hash['amount_in_cents'] = 'amount_in_cents' @_hash['amount'] = 'amount' @_hash['memo'] = 'memo' @_hash['external'] = 'external' @_hash end |
.nullables ⇒ Object
An array for nullable fields
48 49 50 51 52 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 48 def self.nullables %w[ amount_in_cents ] end |
.optionals ⇒ Object
An array for optional fields
41 42 43 44 45 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 41 def self.optionals %w[ external ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/advanced_billing/models/refund_prepayment.rb', line 93 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.amount_in_cents, ->(val) { val.instance_of? Integer }) and UnionTypeLookUp.get(:RefundPrepaymentAmount) .validate(value.amount) and APIHelper.valid_type?(value.memo, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['amount_in_cents'], ->(val) { val.instance_of? Integer }) and UnionTypeLookUp.get(:RefundPrepaymentAmount) .validate(value['amount']) and APIHelper.valid_type?(value['memo'], ->(val) { val.instance_of? String }) ) end |