Class: AdvancedBilling::ComponentPricePointItem

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

Overview

ComponentPricePointItem 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) ⇒ ComponentPricePointItem

Returns a new instance of ComponentPricePointItem.



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

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

Instance Attribute Details

#handleString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/component_price_point_item.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/component_price_point_item.rb', line 14

def name
  @name
end

#pricesArray[Price]

TODO: Write general description for this method

Returns:



26
27
28
# File 'lib/advanced_billing/models/component_price_point_item.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/component_price_point_item.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.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 62

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')

  # Create object from extracted values.

  ComponentPricePointItem.new(name,
                              handle,
                              pricing_scheme,
                              prices)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 29

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

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 39

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

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



90
91
92
93
94
95
96
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 90

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

  return false unless value.instance_of? Hash

  true
end