Class: AdvancedBilling::CreatedPrepayment

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

Overview

CreatedPrepayment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id: SKIP, subscription_id: SKIP, amount_in_cents: SKIP, memo: SKIP, created_at: SKIP, starting_balance_in_cents: SKIP, ending_balance_in_cents: SKIP, additional_properties: {}) ⇒ CreatedPrepayment

Returns a new instance of CreatedPrepayment.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/advanced_billing/models/created_prepayment.rb', line 72

def initialize(id: SKIP, subscription_id: SKIP, amount_in_cents: SKIP,
               memo: SKIP, created_at: SKIP,
               starting_balance_in_cents: SKIP,
               ending_balance_in_cents: SKIP, additional_properties: {})
  @id = id unless id == SKIP
  @subscription_id = subscription_id unless subscription_id == SKIP
  @amount_in_cents = amount_in_cents unless amount_in_cents == SKIP
  @memo = memo unless memo == SKIP
  @created_at = created_at unless created_at == SKIP
  unless starting_balance_in_cents == SKIP
    @starting_balance_in_cents =
      starting_balance_in_cents
  end
  @ending_balance_in_cents = ending_balance_in_cents unless ending_balance_in_cents == 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_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


23
24
25
# File 'lib/advanced_billing/models/created_prepayment.rb', line 23

def amount_in_cents
  @amount_in_cents
end

#created_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


31
32
33
# File 'lib/advanced_billing/models/created_prepayment.rb', line 31

def created_at
  @created_at
end

#ending_balance_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


39
40
41
# File 'lib/advanced_billing/models/created_prepayment.rb', line 39

def ending_balance_in_cents
  @ending_balance_in_cents
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


15
16
17
# File 'lib/advanced_billing/models/created_prepayment.rb', line 15

def id
  @id
end

#memoString

TODO: Write general description for this method

Returns:

  • (String)


27
28
29
# File 'lib/advanced_billing/models/created_prepayment.rb', line 27

def memo
  @memo
end

#starting_balance_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


35
36
37
# File 'lib/advanced_billing/models/created_prepayment.rb', line 35

def starting_balance_in_cents
  @starting_balance_in_cents
end

#subscription_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


19
20
21
# File 'lib/advanced_billing/models/created_prepayment.rb', line 19

def subscription_id
  @subscription_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/advanced_billing/models/created_prepayment.rb', line 94

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : SKIP
  amount_in_cents =
    hash.key?('amount_in_cents') ? hash['amount_in_cents'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  starting_balance_in_cents =
    hash.key?('starting_balance_in_cents') ? hash['starting_balance_in_cents'] : SKIP
  ending_balance_in_cents =
    hash.key?('ending_balance_in_cents') ? hash['ending_balance_in_cents'] : SKIP

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

  # Create object from extracted values.
  CreatedPrepayment.new(id: id,
                        subscription_id: subscription_id,
                        amount_in_cents: amount_in_cents,
                        memo: memo,
                        created_at: created_at,
                        starting_balance_in_cents: starting_balance_in_cents,
                        ending_balance_in_cents: ending_balance_in_cents,
                        additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/advanced_billing/models/created_prepayment.rb', line 42

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['amount_in_cents'] = 'amount_in_cents'
  @_hash['memo'] = 'memo'
  @_hash['created_at'] = 'created_at'
  @_hash['starting_balance_in_cents'] = 'starting_balance_in_cents'
  @_hash['ending_balance_in_cents'] = 'ending_balance_in_cents'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
# File 'lib/advanced_billing/models/created_prepayment.rb', line 68

def self.nullables
  []
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/advanced_billing/models/created_prepayment.rb', line 55

def self.optionals
  %w[
    id
    subscription_id
    amount_in_cents
    memo
    created_at
    starting_balance_in_cents
    ending_balance_in_cents
  ]
end

Instance Method Details

#to_custom_created_atObject



128
129
130
# File 'lib/advanced_billing/models/created_prepayment.rb', line 128

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end