Class: AdvancedBilling::CreatePrepayment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/create_prepayment.rb

Overview

CreatePrepayment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(amount:, details:, memo:, method:, payment_profile_id: SKIP, additional_properties: {}) ⇒ CreatePrepayment

Returns a new instance of CreatePrepayment.



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/advanced_billing/models/create_prepayment.rb', line 61

def initialize(amount:, details:, memo:, method:, payment_profile_id: SKIP,
               additional_properties: {})
  @amount = amount
  @details = details
  @memo = memo
  @method = method
  @payment_profile_id = payment_profile_id unless payment_profile_id == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#amountFloat

TODO: Write general description for this method

Returns:

  • (Float)


14
15
16
# File 'lib/advanced_billing/models/create_prepayment.rb', line 14

def amount
  @amount
end

#detailsString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/create_prepayment.rb', line 18

def details
  @details
end

#memoString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/create_prepayment.rb', line 22

def memo
  @memo
end

#methodCreatePrepaymentMethod

:- When the ‘method` specified is `“credit_card_on_file”`, the prepayment amount will be collected using the default credit card payment profile and applied to the prepayment account balance. This is especially useful for manual replenishment of prepaid subscriptions.



29
30
31
# File 'lib/advanced_billing/models/create_prepayment.rb', line 29

def method
  @method
end

#payment_profile_idInteger

:- When the ‘method` specified is `“credit_card_on_file”`, the prepayment amount will be collected using the default credit card payment profile and applied to the prepayment account balance. This is especially useful for manual replenishment of prepaid subscriptions.

Returns:

  • (Integer)


36
37
38
# File 'lib/advanced_billing/models/create_prepayment.rb', line 36

def payment_profile_id
  @payment_profile_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/advanced_billing/models/create_prepayment.rb', line 76

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
  details = hash.key?('details') ? hash['details'] : nil
  memo = hash.key?('memo') ? hash['memo'] : nil
  method = hash.key?('method') ? hash['method'] : nil
  payment_profile_id =
    hash.key?('payment_profile_id') ? hash['payment_profile_id'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  CreatePrepayment.new(amount: amount,
                       details: details,
                       memo: memo,
                       method: method,
                       payment_profile_id: payment_profile_id,
                       additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
# File 'lib/advanced_billing/models/create_prepayment.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['details'] = 'details'
  @_hash['memo'] = 'memo'
  @_hash['method'] = 'method'
  @_hash['payment_profile_id'] = 'payment_profile_id'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/advanced_billing/models/create_prepayment.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
# File 'lib/advanced_billing/models/create_prepayment.rb', line 50

def self.optionals
  %w[
    payment_profile_id
  ]
end