Class: AdvancedBilling::ComponentCostDataRateTier

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

Overview

ComponentCostDataRateTier Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(starting_quantity = SKIP, ending_quantity = SKIP, quantity = SKIP, unit_price = SKIP, amount = SKIP) ⇒ ComponentCostDataRateTier

Returns a new instance of ComponentCostDataRateTier.



61
62
63
64
65
66
67
68
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 61

def initialize(starting_quantity = SKIP, ending_quantity = SKIP,
               quantity = SKIP, unit_price = SKIP, amount = SKIP)
  @starting_quantity = starting_quantity unless starting_quantity == SKIP
  @ending_quantity = ending_quantity unless ending_quantity == SKIP
  @quantity = quantity unless quantity == SKIP
  @unit_price = unit_price unless unit_price == SKIP
  @amount = amount unless amount == SKIP
end

Instance Attribute Details

#amountString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 30

def amount
  @amount
end

#ending_quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 18

def ending_quantity
  @ending_quantity
end

#quantityString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 22

def quantity
  @quantity
end

#starting_quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 14

def starting_quantity
  @starting_quantity
end

#unit_priceString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 26

def unit_price
  @unit_price
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 71

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  starting_quantity =
    hash.key?('starting_quantity') ? hash['starting_quantity'] : SKIP
  ending_quantity =
    hash.key?('ending_quantity') ? hash['ending_quantity'] : SKIP
  quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
  unit_price = hash.key?('unit_price') ? hash['unit_price'] : SKIP
  amount = hash.key?('amount') ? hash['amount'] : SKIP

  # Create object from extracted values.

  ComponentCostDataRateTier.new(starting_quantity,
                                ending_quantity,
                                quantity,
                                unit_price,
                                amount)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['starting_quantity'] = 'starting_quantity'
  @_hash['ending_quantity'] = 'ending_quantity'
  @_hash['quantity'] = 'quantity'
  @_hash['unit_price'] = 'unit_price'
  @_hash['amount'] = 'amount'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
58
59
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 55

def self.nullables
  %w[
    ending_quantity
  ]
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
51
52
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 44

def self.optionals
  %w[
    starting_quantity
    ending_quantity
    quantity
    unit_price
    amount
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



93
94
95
96
97
98
99
# File 'lib/advanced_billing/models/component_cost_data_rate_tier.rb', line 93

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end