Class: AdvancedBilling::PrepaidComponentPricePoint

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

Overview

PrepaidComponentPricePoint Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(name = SKIP, handle = SKIP, pricing_scheme = SKIP, prices = SKIP, overage_pricing = SKIP) ⇒ PrepaidComponentPricePoint

Returns a new instance of PrepaidComponentPricePoint.



59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 59

def initialize(name = SKIP, handle = SKIP, pricing_scheme = SKIP,
               prices = SKIP, overage_pricing = SKIP)
  @name = name unless name == SKIP
  @handle = handle unless handle == SKIP
  @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP
  @prices = prices unless prices == SKIP
  @overage_pricing = overage_pricing unless overage_pricing == SKIP
end

Instance Attribute Details

#handleString

TODO: Write general description for this method

Returns:

  • (String)


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

def handle
  @handle
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#overage_pricingOveragePricing

TODO: Write general description for this method

Returns:



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

def overage_pricing
  @overage_pricing
end

#pricesArray[Price]

TODO: Write general description for this method

Returns:



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

def prices
  @prices
end

#pricing_schemeString

TODO: Write general description for this method

Returns:

  • (String)


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

def pricing_scheme
  @pricing_scheme
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  handle = hash.key?('handle') ? hash['handle'] : SKIP
  pricing_scheme =
    hash.key?('pricing_scheme') ? hash['pricing_scheme'] : SKIP
  # Parameter is an array, so we need to iterate through it
  prices = nil
  unless hash['prices'].nil?
    prices = []
    hash['prices'].each do |structure|
      prices << (Price.from_hash(structure) if structure)
    end
  end

  prices = SKIP unless hash.key?('prices')
  overage_pricing = OveragePricing.from_hash(hash['overage_pricing']) if
    hash['overage_pricing']

  # Create object from extracted values.
  PrepaidComponentPricePoint.new(name,
                                 handle,
                                 pricing_scheme,
                                 prices,
                                 overage_pricing)
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/prepaid_component_price_point.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['handle'] = 'handle'
  @_hash['pricing_scheme'] = 'pricing_scheme'
  @_hash['prices'] = 'prices'
  @_hash['overage_pricing'] = 'overage_pricing'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    name
    handle
    pricing_scheme
    prices
    overage_pricing
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



100
101
102
103
104
105
106
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 100

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

  return false unless value.instance_of? Hash

  true
end