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 ⇒ DateTime
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, additional_properties: {}) ⇒ Movement
constructor
A new instance of Movement.
- #to_custom_timestamp ⇒ Object
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
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, additional_properties: {}) ⇒ Movement
Returns a new instance of Movement.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/advanced_billing/models/movement.rb', line 84 def 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, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @timestamp = 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
23 24 25 |
# File 'lib/advanced_billing/models/movement.rb', line 23 def amount_formatted @amount_formatted end |
#amount_in_cents ⇒ Integer
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/movement.rb', line 19 def amount_in_cents @amount_in_cents end |
#breakouts ⇒ Breakouts
TODO: Write general description for this method
35 36 37 |
# File 'lib/advanced_billing/models/movement.rb', line 35 def breakouts @breakouts end |
#category ⇒ String
TODO: Write general description for this method
31 32 33 |
# File 'lib/advanced_billing/models/movement.rb', line 31 def category @category end |
#description ⇒ String
TODO: Write general description for this method
27 28 29 |
# File 'lib/advanced_billing/models/movement.rb', line 27 def description @description end |
#line_items ⇒ Array[MovementLineItem]
TODO: Write general description for this method
39 40 41 |
# File 'lib/advanced_billing/models/movement.rb', line 39 def line_items @line_items end |
#subscriber_name ⇒ String
TODO: Write general description for this method
47 48 49 |
# File 'lib/advanced_billing/models/movement.rb', line 47 def subscriber_name @subscriber_name end |
#subscription_id ⇒ Integer
TODO: Write general description for this method
43 44 45 |
# File 'lib/advanced_billing/models/movement.rb', line 43 def subscription_id @subscription_id end |
#timestamp ⇒ DateTime
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/movement.rb', line 15 def @timestamp end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/advanced_billing/models/movement.rb', line 105 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = if hash.key?('timestamp') (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp']) else SKIP end 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 # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. Movement.new(timestamp: , amount_in_cents: amount_in_cents, amount_formatted: amount_formatted, description: description, category: category, breakouts: breakouts, line_items: line_items, subscription_id: subscription_id, subscriber_name: subscriber_name, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/advanced_billing/models/movement.rb', line 50 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
80 81 82 |
# File 'lib/advanced_billing/models/movement.rb', line 80 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/advanced_billing/models/movement.rb', line 65 def self.optionals %w[ timestamp amount_in_cents amount_formatted description category breakouts line_items subscription_id subscriber_name ] end |
Instance Method Details
#to_custom_timestamp ⇒ Object
152 153 154 |
# File 'lib/advanced_billing/models/movement.rb', line 152 def DateTimeHelper.to_rfc3339() end |