Class: AdvancedBilling::ComponentCustomPrice
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ComponentCustomPrice
- Defined in:
- lib/advanced_billing/models/component_custom_price.rb
Overview
Create or update custom pricing unique to the subscription. Used in place of ‘price_point_id`.
Instance Attribute Summary collapse
-
#expiration_interval ⇒ Integer
Applicable only when rollover is enabled.
-
#expiration_interval_unit ⇒ ExpirationIntervalUnit
Applicable only when rollover is enabled.
-
#interval ⇒ Integer
The numerical interval.
-
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this component price point, either month or day.
-
#prices ⇒ Array[Price]
On/off components only need one price bracket starting at 1.
-
#pricing_scheme ⇒ PricingScheme
Omit for On/Off components.
-
#renew_prepaid_allocation ⇒ TrueClass | FalseClass
Applicable only to prepaid usage components.
-
#rollover_prepaid_remainder ⇒ TrueClass | FalseClass
Applicable only to prepaid usage components.
-
#tax_included ⇒ TrueClass | FalseClass
Whether or not the price point includes tax.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(prices:, tax_included: SKIP, pricing_scheme: SKIP, interval: SKIP, interval_unit: SKIP, renew_prepaid_allocation: SKIP, rollover_prepaid_remainder: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, additional_properties: {}) ⇒ ComponentCustomPrice
constructor
A new instance of ComponentCustomPrice.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(prices:, tax_included: SKIP, pricing_scheme: SKIP, interval: SKIP, interval_unit: SKIP, renew_prepaid_allocation: SKIP, rollover_prepaid_remainder: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, additional_properties: {}) ⇒ ComponentCustomPrice
Returns a new instance of ComponentCustomPrice.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 96 def initialize(prices:, tax_included: SKIP, pricing_scheme: SKIP, interval: SKIP, interval_unit: SKIP, renew_prepaid_allocation: SKIP, rollover_prepaid_remainder: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @tax_included = tax_included unless tax_included == SKIP @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP @interval = interval unless interval == SKIP @interval_unit = interval_unit unless interval_unit == SKIP @prices = prices @renew_prepaid_allocation = renew_prepaid_allocation unless renew_prepaid_allocation == SKIP unless rollover_prepaid_remainder == SKIP @rollover_prepaid_remainder = rollover_prepaid_remainder end @expiration_interval = expiration_interval unless expiration_interval == SKIP @expiration_interval_unit = expiration_interval_unit unless expiration_interval_unit == SKIP end |
Instance Attribute Details
#expiration_interval ⇒ Integer
Applicable only when rollover is enabled. Number of ‘expiration_interval_unit`s after which rollover amounts expire.
51 52 53 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 51 def expiration_interval @expiration_interval end |
#expiration_interval_unit ⇒ ExpirationIntervalUnit
Applicable only when rollover is enabled. Interval unit for rollover expiration (month or day).
56 57 58 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 56 def expiration_interval_unit @expiration_interval_unit end |
#interval ⇒ Integer
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.
26 27 28 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 26 def interval @interval end |
#interval_unit ⇒ IntervalUnit
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.
32 33 34 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 32 def interval_unit @interval_unit end |
#prices ⇒ Array[Price]
On/off components only need one price bracket starting at 1
36 37 38 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 36 def prices @prices end |
#pricing_scheme ⇒ PricingScheme
Omit for On/Off components
19 20 21 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 19 def pricing_scheme @pricing_scheme end |
#renew_prepaid_allocation ⇒ TrueClass | FalseClass
Applicable only to prepaid usage components. Controls whether the allocated quantity renews each period.
41 42 43 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 41 def renew_prepaid_allocation @renew_prepaid_allocation end |
#rollover_prepaid_remainder ⇒ TrueClass | FalseClass
Applicable only to prepaid usage components. Controls whether remaining units roll over to the next period.
46 47 48 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 46 def rollover_prepaid_remainder @rollover_prepaid_remainder end |
#tax_included ⇒ TrueClass | FalseClass
Whether or not the price point includes tax
15 16 17 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 15 def tax_included @tax_included end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 121 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # 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 = nil unless hash.key?('prices') tax_included = hash.key?('tax_included') ? hash['tax_included'] : SKIP pricing_scheme = hash.key?('pricing_scheme') ? hash['pricing_scheme'] : SKIP interval = hash.key?('interval') ? hash['interval'] : SKIP interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : SKIP renew_prepaid_allocation = hash.key?('renew_prepaid_allocation') ? hash['renew_prepaid_allocation'] : SKIP rollover_prepaid_remainder = hash.key?('rollover_prepaid_remainder') ? hash['rollover_prepaid_remainder'] : SKIP expiration_interval = hash.key?('expiration_interval') ? hash['expiration_interval'] : SKIP expiration_interval_unit = hash.key?('expiration_interval_unit') ? hash['expiration_interval_unit'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. ComponentCustomPrice.new(prices: prices, tax_included: tax_included, pricing_scheme: pricing_scheme, interval: interval, interval_unit: interval_unit, renew_prepaid_allocation: renew_prepaid_allocation, rollover_prepaid_remainder: rollover_prepaid_remainder, expiration_interval: expiration_interval, expiration_interval_unit: expiration_interval_unit, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 59 def self.names @_hash = {} if @_hash.nil? @_hash['tax_included'] = 'tax_included' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['interval'] = 'interval' @_hash['interval_unit'] = 'interval_unit' @_hash['prices'] = 'prices' @_hash['renew_prepaid_allocation'] = 'renew_prepaid_allocation' @_hash['rollover_prepaid_remainder'] = 'rollover_prepaid_remainder' @_hash['expiration_interval'] = 'expiration_interval' @_hash['expiration_interval_unit'] = 'expiration_interval_unit' @_hash end |
.nullables ⇒ Object
An array for nullable fields
88 89 90 91 92 93 94 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 88 def self.nullables %w[ interval_unit expiration_interval expiration_interval_unit ] end |
.optionals ⇒ Object
An array for optional fields
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 74 def self.optionals %w[ tax_included pricing_scheme interval interval_unit renew_prepaid_allocation rollover_prepaid_remainder expiration_interval expiration_interval_unit ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 167 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.prices, ->(val) { Price.validate(val) }, is_model_hash: true, is_inner_model_hash: true) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['prices'], ->(val) { Price.validate(val) }, is_model_hash: true, is_inner_model_hash: true) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 195 def inspect class_name = self.class.name.split('::').last "<#{class_name} tax_included: #{@tax_included.inspect}, pricing_scheme:"\ " #{@pricing_scheme.inspect}, interval: #{@interval.inspect}, interval_unit:"\ " #{@interval_unit.inspect}, prices: #{@prices.inspect}, renew_prepaid_allocation:"\ " #{@renew_prepaid_allocation.inspect}, rollover_prepaid_remainder:"\ " #{@rollover_prepaid_remainder.inspect}, expiration_interval:"\ " #{@expiration_interval.inspect}, expiration_interval_unit:"\ " #{@expiration_interval_unit.inspect}, additional_properties:"\ " #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
184 185 186 187 188 189 190 191 192 |
# File 'lib/advanced_billing/models/component_custom_price.rb', line 184 def to_s class_name = self.class.name.split('::').last "<#{class_name} tax_included: #{@tax_included}, pricing_scheme: #{@pricing_scheme},"\ " interval: #{@interval}, interval_unit: #{@interval_unit}, prices: #{@prices},"\ " renew_prepaid_allocation: #{@renew_prepaid_allocation}, rollover_prepaid_remainder:"\ " #{@rollover_prepaid_remainder}, expiration_interval: #{@expiration_interval},"\ " expiration_interval_unit: #{@expiration_interval_unit}, additional_properties:"\ " #{get_additional_properties}>" end |