Class: AdvancedBilling::UpdateComponentPricePoint

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

Overview

UpdateComponentPricePoint 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, use_site_exchange_rate: SKIP, tax_included: SKIP, interval: SKIP, interval_unit: SKIP, prices: SKIP, additional_properties: {}) ⇒ UpdateComponentPricePoint

Returns a new instance of UpdateComponentPricePoint.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 89

def initialize(name: SKIP, handle: SKIP, pricing_scheme: SKIP,
               use_site_exchange_rate: SKIP, tax_included: SKIP,
               interval: SKIP, interval_unit: SKIP, prices: SKIP,
               additional_properties: {})
  @name = name unless name == SKIP
  @handle = handle unless handle == SKIP
  @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP
  @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP
  @tax_included = tax_included unless tax_included == SKIP
  @interval = interval unless interval == SKIP
  @interval_unit = interval_unit unless interval_unit == SKIP
  @prices = prices unless prices == 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/update_component_price_point.rb', line 18

def handle
  @handle
end

#intervalInteger

The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this component price point would renew every 30 days. This property is only available for sites with Multifrequency enabled.

Returns:

  • (Integer)


40
41
42
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 40

def interval
  @interval
end

#interval_unitIntervalUnit

A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.

Returns:



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

def interval_unit
  @interval_unit
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#pricesArray[UpdatePrice]

A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.

Returns:



52
53
54
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 52

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/update_component_price_point.rb', line 24

def pricing_scheme
  @pricing_scheme
end

#tax_includedTrueClass | FalseClass

Whether or not the price point includes tax

Returns:

  • (TrueClass | FalseClass)


33
34
35
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 33

def tax_included
  @tax_included
end

#use_site_exchange_rateTrueClass | FalseClass

Whether to use the site level exchange rate or define your own prices for each currency if you have multiple currencies defined on the site.

Returns:

  • (TrueClass | FalseClass)


29
30
31
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 29

def use_site_exchange_rate
  @use_site_exchange_rate
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 109

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
  use_site_exchange_rate =
    hash.key?('use_site_exchange_rate') ? hash['use_site_exchange_rate'] : SKIP
  tax_included = hash.key?('tax_included') ? hash['tax_included'] : SKIP
  interval = hash.key?('interval') ? hash['interval'] : SKIP
  interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : 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 << (UpdatePrice.from_hash(structure) if structure)
    end
  end

  prices = SKIP unless hash.key?('prices')

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

  # Create object from extracted values.
  UpdateComponentPricePoint.new(name: name,
                                handle: handle,
                                pricing_scheme: pricing_scheme,
                                use_site_exchange_rate: use_site_exchange_rate,
                                tax_included: tax_included,
                                interval: interval,
                                interval_unit: interval_unit,
                                prices: prices,
                                additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 55

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

.nullablesObject

An array for nullable fields



83
84
85
86
87
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 83

def self.nullables
  %w[
    interval_unit
  ]
end

.optionalsObject

An array for optional fields



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/advanced_billing/models/update_component_price_point.rb', line 69

def self.optionals
  %w[
    name
    handle
    pricing_scheme
    use_site_exchange_rate
    tax_included
    interval
    interval_unit
    prices
  ]
end