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, additional_properties: {}) ⇒ PrepaidComponentPricePoint

Returns a new instance of PrepaidComponentPricePoint.



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 65

def initialize(name: SKIP, handle: SKIP, pricing_scheme: SKIP, prices: SKIP,
               overage_pricing: SKIP, additional_properties: {})
  @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

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
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

The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.

Returns:



36
37
38
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 36

def overage_pricing
  @overage_pricing
end

#pricesArray[Price]

The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.

Returns:



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

def prices
  @prices
end

#pricing_schemePricingScheme

The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.

Returns:



24
25
26
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 24

def pricing_scheme
  @pricing_scheme
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 80

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

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  PrepaidComponentPricePoint.new(name: name,
                                 handle: handle,
                                 pricing_scheme: pricing_scheme,
                                 prices: prices,
                                 overage_pricing: overage_pricing,
                                 additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



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

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



61
62
63
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
58
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 50

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:



115
116
117
118
119
120
121
# File 'lib/advanced_billing/models/prepaid_component_price_point.rb', line 115

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

  return false unless value.instance_of? Hash

  true
end