Class: AdvancedBilling::SubscriptionGroupSignupItem
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::SubscriptionGroupSignupItem
- Defined in:
- lib/advanced_billing/models/subscription_group_signup_item.rb
Overview
SubscriptionGroupSignupItem Model.
Instance Attribute Summary collapse
-
#calendar_billing ⇒ CalendarBilling
(Optional).
-
#components ⇒ Array[SubscriptionGroupSignupComponent]
An array for all the coupons attached to the subscription.
-
#coupon_codes ⇒ Array[String]
An array for all the coupons attached to the subscription.
-
#currency ⇒ String
(Optional) If Multi-Currency is enabled and the currency is configured in Chargify, pass it at signup to create a subscription on a non-default currency.
-
#custom_price ⇒ SubscriptionCustomPrice
(Optional) Used in place of ‘product_price_point_id` to define a custom price point unique to the subscription.
-
#metafields ⇒ Hash[String, String]
(Optional) A set of key/value pairs representing custom fields and their values.
-
#offer_id ⇒ Integer
Use in place of passing product and component information to set up the subscription with an existing offer.
-
#primary ⇒ TrueClass | FalseClass
One of the subscriptions must be marked as primary in the group.
-
#product_handle ⇒ String
The API Handle of the product for which you are creating a subscription.
-
#product_id ⇒ Integer
The Product ID of the product for which you are creating a subscription.
-
#product_price_point_handle ⇒ String
The user-friendly API handle of a product’s particular price point.
-
#product_price_point_id ⇒ Integer
The ID of the particular price point on the product.
-
#reference ⇒ String
The reference value (provided by your app) for the subscription itelf.
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(product_handle: SKIP, product_id: SKIP, product_price_point_id: SKIP, product_price_point_handle: SKIP, offer_id: SKIP, reference: SKIP, primary: SKIP, currency: SKIP, coupon_codes: SKIP, components: SKIP, custom_price: SKIP, calendar_billing: SKIP, metafields: SKIP, additional_properties: {}) ⇒ SubscriptionGroupSignupItem
constructor
A new instance of SubscriptionGroupSignupItem.
Methods inherited from BaseModel
Constructor Details
#initialize(product_handle: SKIP, product_id: SKIP, product_price_point_id: SKIP, product_price_point_handle: SKIP, offer_id: SKIP, reference: SKIP, primary: SKIP, currency: SKIP, coupon_codes: SKIP, components: SKIP, custom_price: SKIP, calendar_billing: SKIP, metafields: SKIP, additional_properties: {}) ⇒ SubscriptionGroupSignupItem
Returns a new instance of SubscriptionGroupSignupItem.
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 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 117 def initialize(product_handle: SKIP, product_id: SKIP, product_price_point_id: SKIP, product_price_point_handle: SKIP, offer_id: SKIP, reference: SKIP, primary: SKIP, currency: SKIP, coupon_codes: SKIP, components: SKIP, custom_price: SKIP, calendar_billing: SKIP, metafields: SKIP, additional_properties: {}) @product_handle = product_handle unless product_handle == SKIP @product_id = product_id unless product_id == SKIP @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP unless product_price_point_handle == SKIP @product_price_point_handle = product_price_point_handle end @offer_id = offer_id unless offer_id == SKIP @reference = reference unless reference == SKIP @primary = primary unless primary == SKIP @currency = currency unless currency == SKIP @coupon_codes = coupon_codes unless coupon_codes == SKIP @components = components unless components == SKIP @custom_price = custom_price unless custom_price == SKIP @calendar_billing = calendar_billing unless calendar_billing == SKIP @metafields = unless == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#calendar_billing ⇒ CalendarBilling
(Optional). Cannot be used when also specifying next_billing_at
66 67 68 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 66 def calendar_billing @calendar_billing end |
#components ⇒ Array[SubscriptionGroupSignupComponent]
An array for all the coupons attached to the subscription.
57 58 59 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 57 def components @components end |
#coupon_codes ⇒ Array[String]
An array for all the coupons attached to the subscription.
53 54 55 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 53 def coupon_codes @coupon_codes end |
#currency ⇒ String
(Optional) If Multi-Currency is enabled and the currency is configured in Chargify, pass it at signup to create a subscription on a non-default currency. Note that you cannot update the currency of an existing subscription.
49 50 51 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 49 def currency @currency end |
#custom_price ⇒ SubscriptionCustomPrice
(Optional) Used in place of ‘product_price_point_id` to define a custom price point unique to the subscription
62 63 64 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 62 def custom_price @custom_price end |
#metafields ⇒ Hash[String, String]
(Optional) A set of key/value pairs representing custom fields and their values. Metafields will be created “on-the-fly” in your site for a given key, if they have not been created yet.
72 73 74 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 72 def @metafields end |
#offer_id ⇒ Integer
Use in place of passing product and component information to set up the subscription with an existing offer. May be either the Chargify ID of the offer or its handle prefixed with ‘handle:`
34 35 36 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 34 def offer_id @offer_id end |
#primary ⇒ TrueClass | FalseClass
One of the subscriptions must be marked as primary in the group.
42 43 44 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 42 def primary @primary end |
#product_handle ⇒ String
The API Handle of the product for which you are creating a subscription. Required, unless a ‘product_id` is given instead.
15 16 17 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 15 def product_handle @product_handle end |
#product_id ⇒ Integer
The Product ID of the product for which you are creating a subscription. You can pass either ‘product_id` or `product_handle`.
20 21 22 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 20 def product_id @product_id end |
#product_price_point_handle ⇒ String
The user-friendly API handle of a product’s particular price point.
28 29 30 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 28 def product_price_point_handle @product_price_point_handle end |
#product_price_point_id ⇒ Integer
The ID of the particular price point on the product.
24 25 26 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 24 def product_price_point_id @product_price_point_id end |
#reference ⇒ String
The reference value (provided by your app) for the subscription itelf.
38 39 40 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 38 def reference @reference end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
148 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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 148 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. product_handle = hash.key?('product_handle') ? hash['product_handle'] : SKIP product_id = hash.key?('product_id') ? hash['product_id'] : SKIP product_price_point_id = hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP product_price_point_handle = hash.key?('product_price_point_handle') ? hash['product_price_point_handle'] : SKIP offer_id = hash.key?('offer_id') ? hash['offer_id'] : SKIP reference = hash.key?('reference') ? hash['reference'] : SKIP primary = hash.key?('primary') ? hash['primary'] : SKIP currency = hash.key?('currency') ? hash['currency'] : SKIP coupon_codes = hash.key?('coupon_codes') ? hash['coupon_codes'] : SKIP # Parameter is an array, so we need to iterate through it components = nil unless hash['components'].nil? components = [] hash['components'].each do |structure| components << (SubscriptionGroupSignupComponent.from_hash(structure) if structure) end end components = SKIP unless hash.key?('components') custom_price = SubscriptionCustomPrice.from_hash(hash['custom_price']) if hash['custom_price'] calendar_billing = CalendarBilling.from_hash(hash['calendar_billing']) if hash['calendar_billing'] = hash.key?('metafields') ? hash['metafields'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. SubscriptionGroupSignupItem.new(product_handle: product_handle, product_id: product_id, product_price_point_id: product_price_point_id, product_price_point_handle: product_price_point_handle, offer_id: offer_id, reference: reference, primary: primary, currency: currency, coupon_codes: coupon_codes, components: components, custom_price: custom_price, calendar_billing: calendar_billing, metafields: , additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 75 def self.names @_hash = {} if @_hash.nil? @_hash['product_handle'] = 'product_handle' @_hash['product_id'] = 'product_id' @_hash['product_price_point_id'] = 'product_price_point_id' @_hash['product_price_point_handle'] = 'product_price_point_handle' @_hash['offer_id'] = 'offer_id' @_hash['reference'] = 'reference' @_hash['primary'] = 'primary' @_hash['currency'] = 'currency' @_hash['coupon_codes'] = 'coupon_codes' @_hash['components'] = 'components' @_hash['custom_price'] = 'custom_price' @_hash['calendar_billing'] = 'calendar_billing' @_hash['metafields'] = 'metafields' @_hash end |
.nullables ⇒ Object
An array for nullable fields
113 114 115 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 113 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 94 def self.optionals %w[ product_handle product_id product_price_point_id product_price_point_handle offer_id reference primary currency coupon_codes components custom_price calendar_billing metafields ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
202 203 204 205 206 207 208 |
# File 'lib/advanced_billing/models/subscription_group_signup_item.rb', line 202 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |