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 ⇒ String
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) ⇒ Usage
constructor
A new instance of Usage.
Methods inherited from BaseModel
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) ⇒ Usage
Returns a new instance of Usage.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/advanced_billing/models/usage.rb', line 83 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) @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
42 43 44 |
# File 'lib/advanced_billing/models/usage.rb', line 42 def component_handle @component_handle end |
#component_id ⇒ Integer
TODO: Write general description for this method
38 39 40 |
# File 'lib/advanced_billing/models/usage.rb', line 38 def component_id @component_id end |
#created_at ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/usage.rb', line 22 def created_at @created_at end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/usage.rb', line 14 def id @id end |
#memo ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/usage.rb', line 18 def memo @memo end |
#overage_quantity ⇒ Integer
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/usage.rb', line 34 def overage_quantity @overage_quantity end |
#price_point_id ⇒ Integer
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/usage.rb', line 26 def price_point_id @price_point_id end |
#quantity ⇒ Object
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/usage.rb', line 30 def quantity @quantity end |
#subscription_id ⇒ Integer
TODO: Write general description for this method
46 47 48 |
# File 'lib/advanced_billing/models/usage.rb', line 46 def subscription_id @subscription_id 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 |
# File 'lib/advanced_billing/models/usage.rb', line 99 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 = hash.key?('created_at') ? hash['created_at'] : SKIP 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 # Create object from extracted values. Usage.new(id, memo, created_at, price_point_id, quantity, overage_quantity, component_id, component_handle, subscription_id) 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/usage.rb', line 49 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
79 80 81 |
# File 'lib/advanced_billing/models/usage.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/usage.rb', line 64 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.
133 134 135 136 137 138 139 |
# File 'lib/advanced_billing/models/usage.rb', line 133 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |