Class: AdvancedBilling::EBBComponent
- Defined in:
- lib/advanced_billing/models/ebb_component.rb
Overview
EBBComponent Model.
Instance Attribute Summary collapse
-
#description ⇒ String
A description for the component that will be displayed to the user on the hosted signup page.
-
#downgrade_credit ⇒ String
(Not required for ‘per_unit’ pricing schemes) One or more price brackets.
-
#event_based_billing_metric_id ⇒ Integer
The ID of an event based billing metric that will be attached to this component.
-
#handle ⇒ String
A unique identifier for your use that can be used to retrieve this component is subsequent requests.
-
#hide_date_range_on_invoice ⇒ TrueClass | FalseClass
(Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices.
-
#name ⇒ String
A name for this component that is suitable for showing customers and displaying on billing statements, ie.
-
#price_in_cents ⇒ String
deprecated May 2011 - use unit_price instead.
-
#price_points ⇒ Array[ComponentPricePointItem]
(Not required for ‘per_unit’ pricing schemes) One or more price brackets.
-
#prices ⇒ Array[Price]
(Not required for ‘per_unit’ pricing schemes) One or more price brackets.
-
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme.
-
#tax_code ⇒ String
A string representing the tax code related to the component type.
-
#taxable ⇒ TrueClass | FalseClass
Boolean flag describing whether a component is taxable or not.
-
#unit_name ⇒ String
The name of the unit of measurement for the component.
-
#unit_price ⇒ Object
The amount the customer will be charged per unit when the pricing scheme is “per_unit”.
-
#upgrade_charge ⇒ String
(Not required for ‘per_unit’ pricing schemes) One or more price brackets.
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(name = nil, unit_name = nil, pricing_scheme = nil, event_based_billing_metric_id = nil, description = SKIP, handle = SKIP, taxable = SKIP, prices = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, price_points = SKIP, unit_price = SKIP, tax_code = SKIP, hide_date_range_on_invoice = SKIP, price_in_cents = SKIP) ⇒ EBBComponent
constructor
A new instance of EBBComponent.
Methods inherited from BaseModel
Constructor Details
#initialize(name = nil, unit_name = nil, pricing_scheme = nil, event_based_billing_metric_id = nil, description = SKIP, handle = SKIP, taxable = SKIP, prices = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, price_points = SKIP, unit_price = SKIP, tax_code = SKIP, hide_date_range_on_invoice = SKIP, price_in_cents = SKIP) ⇒ EBBComponent
Returns a new instance of EBBComponent.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 149 def initialize(name = nil, unit_name = nil, pricing_scheme = nil, event_based_billing_metric_id = nil, description = SKIP, handle = SKIP, taxable = SKIP, prices = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, price_points = SKIP, unit_price = SKIP, tax_code = SKIP, hide_date_range_on_invoice = SKIP, price_in_cents = SKIP) @name = name @unit_name = unit_name @description = description unless description == SKIP @handle = handle unless handle == SKIP @taxable = taxable unless taxable == SKIP @pricing_scheme = pricing_scheme @prices = prices unless prices == SKIP @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP @price_points = price_points unless price_points == SKIP @unit_price = unit_price unless unit_price == SKIP @tax_code = tax_code unless tax_code == SKIP unless hide_date_range_on_invoice == SKIP @hide_date_range_on_invoice = hide_date_range_on_invoice end @price_in_cents = price_in_cents unless price_in_cents == SKIP @event_based_billing_metric_id = event_based_billing_metric_id end |
Instance Attribute Details
#description ⇒ String
A description for the component that will be displayed to the user on the hosted signup page.
27 28 29 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 27 def description @description end |
#downgrade_credit ⇒ String
(Not required for ‘per_unit’ pricing schemes) One or more price brackets. See [Price Bracket Rules](help.chargify.com/products/product-components.html#general- price-bracket-rules) for an overview of how price brackets work for different pricing schemes.
68 69 70 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 68 def downgrade_credit @downgrade_credit end |
#event_based_billing_metric_id ⇒ Integer
The ID of an event based billing metric that will be attached to this component.
103 104 105 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 103 def event_based_billing_metric_id @event_based_billing_metric_id end |
#handle ⇒ String
A unique identifier for your use that can be used to retrieve this component is subsequent requests. Must start with a letter or number and may only contain lowercase letters, numbers, or the characters ‘.’, ‘:’, ‘-’, or ‘_’.
34 35 36 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 34 def handle @handle end |
#hide_date_range_on_invoice ⇒ TrueClass | FalseClass
(Only available on Relationship Invoicing sites) Boolean flag describing if the service date range should show for the component on generated invoices.
94 95 96 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 94 def hide_date_range_on_invoice @hide_date_range_on_invoice end |
#name ⇒ String
A name for this component that is suitable for showing customers and displaying on billing statements, ie. “Minutes”.
15 16 17 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 15 def name @name end |
#price_in_cents ⇒ String
deprecated May 2011 - use unit_price instead
98 99 100 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 98 def price_in_cents @price_in_cents end |
#price_points ⇒ Array[ComponentPricePointItem]
(Not required for ‘per_unit’ pricing schemes) One or more price brackets. See [Price Bracket Rules](help.chargify.com/products/product-components.html#general- price-bracket-rules) for an overview of how price brackets work for different pricing schemes.
76 77 78 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 76 def price_points @price_points end |
#prices ⇒ Array[Price]
(Not required for ‘per_unit’ pricing schemes) One or more price brackets. See [Price Bracket Rules](help.chargify.com/products/product-components.html#general- price-bracket-rules) for an overview of how price brackets work for different pricing schemes.
52 53 54 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 52 def prices @prices end |
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
44 45 46 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 44 def pricing_scheme @pricing_scheme end |
#tax_code ⇒ String
A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters.
88 89 90 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 88 def tax_code @tax_code end |
#taxable ⇒ TrueClass | FalseClass
Boolean flag describing whether a component is taxable or not.
38 39 40 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 38 def taxable @taxable end |
#unit_name ⇒ String
The name of the unit of measurement for the component. It should be singular since it will be automatically pluralized when necessary. i.e. “message”, which may then be shown as “5 messages” on a subscription’s component line-item
22 23 24 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 22 def unit_name @unit_name end |
#unit_price ⇒ Object
The amount the customer will be charged per unit when the pricing scheme is “per_unit”. The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065
82 83 84 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 82 def unit_price @unit_price end |
#upgrade_charge ⇒ String
(Not required for ‘per_unit’ pricing schemes) One or more price brackets. See [Price Bracket Rules](help.chargify.com/products/product-components.html#general- price-bracket-rules) for an overview of how price brackets work for different pricing schemes.
60 61 62 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 60 def upgrade_charge @upgrade_charge end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 176 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil unit_name = hash.key?('unit_name') ? hash['unit_name'] : nil pricing_scheme = hash.key?('pricing_scheme') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:EBBComponentPricingScheme), hash['pricing_scheme'] ) : nil event_based_billing_metric_id = hash.key?('event_based_billing_metric_id') ? hash['event_based_billing_metric_id'] : nil description = hash.key?('description') ? hash['description'] : SKIP handle = hash.key?('handle') ? hash['handle'] : SKIP taxable = hash.key?('taxable') ? hash['taxable'] : 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') upgrade_charge = hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP downgrade_credit = hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP # Parameter is an array, so we need to iterate through it price_points = nil unless hash['price_points'].nil? price_points = [] hash['price_points'].each do |structure| price_points << (ComponentPricePointItem.from_hash(structure) if structure) end end price_points = SKIP unless hash.key?('price_points') unit_price = hash.key?('unit_price') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:EBBComponentUnitPrice), hash['unit_price'] ) : SKIP tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP hide_date_range_on_invoice = hash.key?('hide_date_range_on_invoice') ? hash['hide_date_range_on_invoice'] : SKIP price_in_cents = hash.key?('price_in_cents') ? hash['price_in_cents'] : SKIP # Create object from extracted values. EBBComponent.new(name, unit_name, pricing_scheme, event_based_billing_metric_id, description, handle, taxable, prices, upgrade_charge, downgrade_credit, price_points, unit_price, tax_code, hide_date_range_on_invoice, price_in_cents) end |
.names ⇒ Object
A mapping from model property names to API property names.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 106 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['unit_name'] = 'unit_name' @_hash['description'] = 'description' @_hash['handle'] = 'handle' @_hash['taxable'] = 'taxable' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['prices'] = 'prices' @_hash['upgrade_charge'] = 'upgrade_charge' @_hash['downgrade_credit'] = 'downgrade_credit' @_hash['price_points'] = 'price_points' @_hash['unit_price'] = 'unit_price' @_hash['tax_code'] = 'tax_code' @_hash['hide_date_range_on_invoice'] = 'hide_date_range_on_invoice' @_hash['price_in_cents'] = 'price_in_cents' @_hash['event_based_billing_metric_id'] = 'event_based_billing_metric_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
145 146 147 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 145 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 128 def self.optionals %w[ description handle taxable prices upgrade_charge downgrade_credit price_points unit_price tax_code hide_date_range_on_invoice price_in_cents ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/advanced_billing/models/ebb_component.rb', line 243 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.name, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.unit_name, ->(val) { val.instance_of? String }) and UnionTypeLookUp.get(:EBBComponentPricingScheme) .validate(value.pricing_scheme) and APIHelper.valid_type?(value.event_based_billing_metric_id, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['name'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['unit_name'], ->(val) { val.instance_of? String }) and UnionTypeLookUp.get(:EBBComponentPricingScheme) .validate(value['pricing_scheme']) and APIHelper.valid_type?(value['event_based_billing_metric_id'], ->(val) { val.instance_of? Integer }) ) end |