Class: AdvancedBilling::Usage
- Defined in:
- lib/advanced_billing/models/usage.rb
Overview
Usage Model.
Instance Attribute Summary collapse
-
#component_handle ⇒ String
TODO: Write general description for this method.
-
#component_id ⇒ Integer
TODO: Write general description for this method.
-
#created_at ⇒ DateTime
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#memo ⇒ String
TODO: Write general description for this method.
-
#overage_quantity ⇒ Integer
TODO: Write general description for this method.
-
#price_point_id ⇒ Integer
TODO: Write general description for this method.
-
#quantity ⇒ Object
TODO: Write general description for this method.
-
#subscription_id ⇒ Integer
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id: SKIP, memo: SKIP, created_at: SKIP, price_point_id: SKIP, quantity: SKIP, overage_quantity: SKIP, component_id: SKIP, component_handle: SKIP, subscription_id: SKIP, additional_properties: {}) ⇒ Usage
constructor
A new instance of Usage.
- #to_custom_created_at ⇒ 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(id: SKIP, memo: SKIP, created_at: SKIP, price_point_id: SKIP, quantity: SKIP, overage_quantity: SKIP, component_id: SKIP, component_handle: SKIP, subscription_id: SKIP, additional_properties: {}) ⇒ Usage
Returns a new instance of Usage.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/advanced_billing/models/usage.rb', line 86 def initialize(id: SKIP, memo: SKIP, created_at: SKIP, price_point_id: SKIP, quantity: SKIP, overage_quantity: SKIP, component_id: SKIP, component_handle: SKIP, subscription_id: 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 @memo = memo unless memo == SKIP @created_at = created_at unless created_at == SKIP @price_point_id = price_point_id unless price_point_id == SKIP @quantity = quantity unless quantity == SKIP @overage_quantity = overage_quantity unless overage_quantity == SKIP @component_id = component_id unless component_id == SKIP @component_handle = component_handle unless component_handle == SKIP @subscription_id = subscription_id unless subscription_id == SKIP end |
Instance Attribute Details
#component_handle ⇒ String
TODO: Write general description for this method
43 44 45 |
# File 'lib/advanced_billing/models/usage.rb', line 43 def component_handle @component_handle end |
#component_id ⇒ Integer
TODO: Write general description for this method
39 40 41 |
# File 'lib/advanced_billing/models/usage.rb', line 39 def component_id @component_id end |
#created_at ⇒ DateTime
TODO: Write general description for this method
23 24 25 |
# File 'lib/advanced_billing/models/usage.rb', line 23 def created_at @created_at end |
#id ⇒ Integer
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/usage.rb', line 15 def id @id end |
#memo ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/usage.rb', line 19 def memo @memo end |
#overage_quantity ⇒ Integer
TODO: Write general description for this method
35 36 37 |
# File 'lib/advanced_billing/models/usage.rb', line 35 def overage_quantity @overage_quantity end |
#price_point_id ⇒ Integer
TODO: Write general description for this method
27 28 29 |
# File 'lib/advanced_billing/models/usage.rb', line 27 def price_point_id @price_point_id end |
#quantity ⇒ Object
TODO: Write general description for this method
31 32 33 |
# File 'lib/advanced_billing/models/usage.rb', line 31 def quantity @quantity end |
#subscription_id ⇒ Integer
TODO: Write general description for this method
47 48 49 |
# File 'lib/advanced_billing/models/usage.rb', line 47 def subscription_id @subscription_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/advanced_billing/models/usage.rb', line 107 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : 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 price_point_id = hash.key?('price_point_id') ? hash['price_point_id'] : SKIP quantity = hash.key?('quantity') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:UsageQuantity), hash['quantity'] ) : SKIP overage_quantity = hash.key?('overage_quantity') ? hash['overage_quantity'] : SKIP component_id = hash.key?('component_id') ? hash['component_id'] : SKIP component_handle = hash.key?('component_handle') ? hash['component_handle'] : SKIP subscription_id = hash.key?('subscription_id') ? hash['subscription_id'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. Usage.new(id: id, memo: memo, created_at: created_at, price_point_id: price_point_id, quantity: quantity, overage_quantity: overage_quantity, component_id: component_id, component_handle: component_handle, subscription_id: subscription_id, 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/usage.rb', line 50 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['memo'] = 'memo' @_hash['created_at'] = 'created_at' @_hash['price_point_id'] = 'price_point_id' @_hash['quantity'] = 'quantity' @_hash['overage_quantity'] = 'overage_quantity' @_hash['component_id'] = 'component_id' @_hash['component_handle'] = 'component_handle' @_hash['subscription_id'] = 'subscription_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
80 81 82 83 84 |
# File 'lib/advanced_billing/models/usage.rb', line 80 def self.nullables %w[ memo ] 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/usage.rb', line 65 def self.optionals %w[ id memo created_at price_point_id quantity overage_quantity component_id component_handle subscription_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
153 154 155 156 157 158 159 |
# File 'lib/advanced_billing/models/usage.rb', line 153 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#to_custom_created_at ⇒ Object
147 148 149 |
# File 'lib/advanced_billing/models/usage.rb', line 147 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |