Class: AdvancedBilling::ServiceCredit

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

Overview

ServiceCredit Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id: SKIP, amount_in_cents: SKIP, ending_balance_in_cents: SKIP, entry_type: SKIP, memo: SKIP, additional_properties: {}) ⇒ ServiceCredit

Returns a new instance of ServiceCredit.



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

def initialize(id: SKIP, amount_in_cents: SKIP,
               ending_balance_in_cents: SKIP, entry_type: SKIP, memo: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @id = id unless id == SKIP
  @amount_in_cents = amount_in_cents unless amount_in_cents == SKIP
  @ending_balance_in_cents = ending_balance_in_cents unless ending_balance_in_cents == SKIP
  @entry_type = entry_type unless entry_type == SKIP
  @memo = memo unless memo == SKIP
end

Instance Attribute Details

#amount_in_centsInteger

The amount in cents of the entry

Returns:

  • (Integer)


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

def amount_in_cents
  @amount_in_cents
end

#ending_balance_in_centsInteger

The new balance for the credit account

Returns:

  • (Integer)


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

def ending_balance_in_cents
  @ending_balance_in_cents
end

#entry_typeServiceCreditType

The type of entry

Returns:



26
27
28
# File 'lib/advanced_billing/models/service_credit.rb', line 26

def entry_type
  @entry_type
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def id
  @id
end

#memoString

The memo attached to the entry

Returns:

  • (String)


30
31
32
# File 'lib/advanced_billing/models/service_credit.rb', line 30

def memo
  @memo
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
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/service_credit.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  amount_in_cents =
    hash.key?('amount_in_cents') ? hash['amount_in_cents'] : SKIP
  ending_balance_in_cents =
    hash.key?('ending_balance_in_cents') ? hash['ending_balance_in_cents'] : SKIP
  entry_type = hash.key?('entry_type') ? hash['entry_type'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  ServiceCredit.new(id: id,
                    amount_in_cents: amount_in_cents,
                    ending_balance_in_cents: ending_balance_in_cents,
                    entry_type: entry_type,
                    memo: memo,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/advanced_billing/models/service_credit.rb', line 33

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

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/advanced_billing/models/service_credit.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    amount_in_cents
    ending_balance_in_cents
    entry_type
    memo
  ]
end