Class: AdvancedBilling::Movement
- Defined in:
- lib/advanced_billing/models/movement.rb
Overview
Movement Model.
Instance Attribute Summary collapse
-
#amount_formatted ⇒ String
TODO: Write general description for this method.
-
#amount_in_cents ⇒ Integer
TODO: Write general description for this method.
-
#breakouts ⇒ Breakouts
TODO: Write general description for this method.
-
#category ⇒ String
TODO: Write general description for this method.
-
#description ⇒ String
TODO: Write general description for this method.
-
#line_items ⇒ Array[MovementLineItem]
TODO: Write general description for this method.
-
#subscriber_name ⇒ String
TODO: Write general description for this method.
-
#subscription_id ⇒ Integer
TODO: Write general description for this method.
-
#timestamp ⇒ String
TODO: Write general description for this method.
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.
Instance Method Summary collapse
-
#initialize(timestamp = SKIP, amount_in_cents = SKIP, amount_formatted = SKIP, description = SKIP, category = SKIP, breakouts = SKIP, line_items = SKIP, subscription_id = SKIP, subscriber_name = SKIP) ⇒ Movement
constructor
A new instance of Movement.
Methods inherited from BaseModel
Constructor Details
#initialize(timestamp = SKIP, amount_in_cents = SKIP, amount_formatted = SKIP, description = SKIP, category = SKIP, breakouts = SKIP, line_items = SKIP, subscription_id = SKIP, subscriber_name = SKIP) ⇒ Movement
Returns a new instance of Movement.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/advanced_billing/models/movement.rb', line 83 def initialize( = SKIP, amount_in_cents = SKIP, amount_formatted = SKIP, description = SKIP, category = SKIP, breakouts = SKIP, line_items = SKIP, subscription_id = SKIP, subscriber_name = SKIP) = unless == SKIP @amount_in_cents = amount_in_cents unless amount_in_cents == SKIP @amount_formatted = amount_formatted unless amount_formatted == SKIP @description = description unless description == SKIP @category = category unless category == SKIP @breakouts = breakouts unless breakouts == SKIP @line_items = line_items unless line_items == SKIP @subscription_id = subscription_id unless subscription_id == SKIP @subscriber_name = subscriber_name unless subscriber_name == SKIP end |
Instance Attribute Details
#amount_formatted ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/movement.rb', line 22 def amount_formatted @amount_formatted end |
#amount_in_cents ⇒ Integer
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/movement.rb', line 18 def amount_in_cents @amount_in_cents end |
#breakouts ⇒ Breakouts
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/movement.rb', line 34 def breakouts @breakouts end |
#category ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/movement.rb', line 30 def category @category end |
#description ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/movement.rb', line 26 def description @description end |
#line_items ⇒ Array[MovementLineItem]
TODO: Write general description for this method
38 39 40 |
# File 'lib/advanced_billing/models/movement.rb', line 38 def line_items @line_items end |
#subscriber_name ⇒ String
TODO: Write general description for this method
46 47 48 |
# File 'lib/advanced_billing/models/movement.rb', line 46 def subscriber_name @subscriber_name end |
#subscription_id ⇒ Integer
TODO: Write general description for this method
42 43 44 |
# File 'lib/advanced_billing/models/movement.rb', line 42 def subscription_id @subscription_id end |
#timestamp ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/movement.rb', line 14 def end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/advanced_billing/models/movement.rb', line 99 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = hash.key?('timestamp') ? hash['timestamp'] : SKIP amount_in_cents = hash.key?('amount_in_cents') ? hash['amount_in_cents'] : SKIP amount_formatted = hash.key?('amount_formatted') ? hash['amount_formatted'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP category = hash.key?('category') ? hash['category'] : SKIP breakouts = Breakouts.from_hash(hash['breakouts']) if hash['breakouts'] # Parameter is an array, so we need to iterate through it line_items = nil unless hash['line_items'].nil? line_items = [] hash['line_items'].each do |structure| line_items << (MovementLineItem.from_hash(structure) if structure) end end line_items = SKIP unless hash.key?('line_items') subscription_id = hash.key?('subscription_id') ? hash['subscription_id'] : SKIP subscriber_name = hash.key?('subscriber_name') ? hash['subscriber_name'] : SKIP # Create object from extracted values. Movement.new(, amount_in_cents, amount_formatted, description, category, breakouts, line_items, subscription_id, subscriber_name) end |
.names ⇒ Object
A mapping from model property names to API property names.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/advanced_billing/models/movement.rb', line 49 def self.names @_hash = {} if @_hash.nil? @_hash['timestamp'] = 'timestamp' @_hash['amount_in_cents'] = 'amount_in_cents' @_hash['amount_formatted'] = 'amount_formatted' @_hash['description'] = 'description' @_hash['category'] = 'category' @_hash['breakouts'] = 'breakouts' @_hash['line_items'] = 'line_items' @_hash['subscription_id'] = 'subscription_id' @_hash['subscriber_name'] = 'subscriber_name' @_hash end |
.nullables ⇒ Object
An array for nullable fields
79 80 81 |
# File 'lib/advanced_billing/models/movement.rb', line 79 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/advanced_billing/models/movement.rb', line 64 def self.optionals %w[ timestamp amount_in_cents amount_formatted description category breakouts line_items subscription_id subscriber_name ] end |