Class: AdvancedBilling::Breakouts

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

Overview

Breakouts 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(plan_amount_in_cents: SKIP, plan_amount_formatted: SKIP, usage_amount_in_cents: SKIP, usage_amount_formatted: SKIP, additional_properties: {}) ⇒ Breakouts

Returns a new instance of Breakouts.



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

def initialize(plan_amount_in_cents: SKIP, plan_amount_formatted: SKIP,
               usage_amount_in_cents: SKIP, usage_amount_formatted: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @plan_amount_in_cents = plan_amount_in_cents unless plan_amount_in_cents == SKIP
  @plan_amount_formatted = plan_amount_formatted unless plan_amount_formatted == SKIP
  @usage_amount_in_cents = usage_amount_in_cents unless usage_amount_in_cents == SKIP
  @usage_amount_formatted = usage_amount_formatted unless usage_amount_formatted == SKIP
end

Instance Attribute Details

#plan_amount_formattedString

TODO: Write general description for this method

Returns:

  • (String)


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

def plan_amount_formatted
  @plan_amount_formatted
end

#plan_amount_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def plan_amount_in_cents
  @plan_amount_in_cents
end

#usage_amount_formattedString

TODO: Write general description for this method

Returns:

  • (String)


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

def usage_amount_formatted
  @usage_amount_formatted
end

#usage_amount_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def usage_amount_in_cents
  @usage_amount_in_cents
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
90
# File 'lib/advanced_billing/models/breakouts.rb', line 68

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  plan_amount_in_cents =
    hash.key?('plan_amount_in_cents') ? hash['plan_amount_in_cents'] : SKIP
  plan_amount_formatted =
    hash.key?('plan_amount_formatted') ? hash['plan_amount_formatted'] : SKIP
  usage_amount_in_cents =
    hash.key?('usage_amount_in_cents') ? hash['usage_amount_in_cents'] : SKIP
  usage_amount_formatted =
    hash.key?('usage_amount_formatted') ? hash['usage_amount_formatted'] : SKIP

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

  # Create object from extracted values.
  Breakouts.new(plan_amount_in_cents: plan_amount_in_cents,
                plan_amount_formatted: plan_amount_formatted,
                usage_amount_in_cents: usage_amount_in_cents,
                usage_amount_formatted: usage_amount_formatted,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/advanced_billing/models/breakouts.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['plan_amount_in_cents'] = 'plan_amount_in_cents'
  @_hash['plan_amount_formatted'] = 'plan_amount_formatted'
  @_hash['usage_amount_in_cents'] = 'usage_amount_in_cents'
  @_hash['usage_amount_formatted'] = 'usage_amount_formatted'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/advanced_billing/models/breakouts.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    plan_amount_in_cents
    plan_amount_formatted
    usage_amount_in_cents
    usage_amount_formatted
  ]
end