Class: AdvancedBilling::CreateUsage

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

Overview

CreateUsage Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(quantity = SKIP, price_point_id = SKIP, memo = SKIP) ⇒ CreateUsage

Returns a new instance of CreateUsage.



50
51
52
53
54
# File 'lib/advanced_billing/models/create_usage.rb', line 50

def initialize(quantity = SKIP, price_point_id = SKIP, memo = SKIP)
  @quantity = quantity unless quantity == SKIP
  @price_point_id = price_point_id unless price_point_id == SKIP
  @memo = memo unless memo == SKIP
end

Instance Attribute Details

#memoString

integer by default or decimal number if fractional quantities are enabled for the component

Returns:

  • (String)


25
26
27
# File 'lib/advanced_billing/models/create_usage.rb', line 25

def memo
  @memo
end

#price_point_idString

integer by default or decimal number if fractional quantities are enabled for the component

Returns:

  • (String)


20
21
22
# File 'lib/advanced_billing/models/create_usage.rb', line 20

def price_point_id
  @price_point_id
end

#quantityFloat

integer by default or decimal number if fractional quantities are enabled for the component

Returns:

  • (Float)


15
16
17
# File 'lib/advanced_billing/models/create_usage.rb', line 15

def quantity
  @quantity
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/advanced_billing/models/create_usage.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
  price_point_id =
    hash.key?('price_point_id') ? hash['price_point_id'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP

  # Create object from extracted values.
  CreateUsage.new(quantity,
                  price_point_id,
                  memo)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/advanced_billing/models/create_usage.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['quantity'] = 'quantity'
  @_hash['price_point_id'] = 'price_point_id'
  @_hash['memo'] = 'memo'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/advanced_billing/models/create_usage.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



37
38
39
40
41
42
43
# File 'lib/advanced_billing/models/create_usage.rb', line 37

def self.optionals
  %w[
    quantity
    price_point_id
    memo
  ]
end