Class: AdvancedBilling::SubscriptionProductMigration
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::SubscriptionProductMigration
- Defined in:
- lib/advanced_billing/models/subscription_product_migration.rb
Overview
SubscriptionProductMigration Model.
Instance Attribute Summary collapse
-
#include_coupons ⇒ TrueClass | FalseClass
If ‘true` is sent, any coupons associated with the subscription will be applied to the migration.
-
#include_initial_charge ⇒ TrueClass | FalseClass
If ‘true` is sent initial charges will be assessed.
-
#include_trial ⇒ TrueClass | FalseClass
Whether to include the trial period configured for the product price point when starting a new billing period.
-
#preserve_period ⇒ TrueClass | FalseClass
If ‘false` is sent, the subscription’s billing period will be reset to today and the full price of the new product will be charged.
-
#product_handle ⇒ String
The handle of the target Product.
-
#product_id ⇒ Integer
The ID of the target Product.
-
#product_price_point_handle ⇒ String
The ID or handle of the specified product’s price point.
-
#product_price_point_id ⇒ Integer
The ID of the specified product’s price point.
-
#proration ⇒ Proration
The ID or handle of the specified product’s price point.
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.
Instance Method Summary collapse
-
#initialize(product_id: SKIP, product_price_point_id: SKIP, include_trial: false, include_initial_charge: false, include_coupons: true, preserve_period: false, product_handle: SKIP, product_price_point_handle: SKIP, proration: SKIP, additional_properties: {}) ⇒ SubscriptionProductMigration
constructor
A new instance of SubscriptionProductMigration.
Methods inherited from BaseModel
Constructor Details
#initialize(product_id: SKIP, product_price_point_id: SKIP, include_trial: false, include_initial_charge: false, include_coupons: true, preserve_period: false, product_handle: SKIP, product_price_point_handle: SKIP, proration: SKIP, additional_properties: {}) ⇒ SubscriptionProductMigration
Returns a new instance of SubscriptionProductMigration.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 99 def initialize(product_id: SKIP, product_price_point_id: SKIP, include_trial: false, include_initial_charge: false, include_coupons: true, preserve_period: false, product_handle: SKIP, product_price_point_handle: SKIP, proration: SKIP, additional_properties: {}) @product_id = product_id unless product_id == SKIP @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP @include_trial = include_trial unless include_trial == SKIP @include_initial_charge = include_initial_charge unless include_initial_charge == SKIP @include_coupons = include_coupons unless include_coupons == SKIP @preserve_period = preserve_period unless preserve_period == SKIP @product_handle = product_handle unless product_handle == SKIP unless product_price_point_handle == SKIP @product_price_point_handle = product_price_point_handle end @proration = proration unless proration == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#include_coupons ⇒ TrueClass | FalseClass
If ‘true` is sent, any coupons associated with the subscription will be applied to the migration. If `false` is sent, coupons will not be applied. Note: When migrating to a new product family, the coupon cannot migrate.
38 39 40 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 38 def include_coupons @include_coupons end |
#include_initial_charge ⇒ TrueClass | FalseClass
If ‘true` is sent initial charges will be assessed.
32 33 34 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 32 def include_initial_charge @include_initial_charge end |
#include_trial ⇒ TrueClass | FalseClass
Whether to include the trial period configured for the product price point when starting a new billing period. Note that if preserve_period is set, then include_trial will be ignored.
28 29 30 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 28 def include_trial @include_trial end |
#preserve_period ⇒ TrueClass | FalseClass
If ‘false` is sent, the subscription’s billing period will be reset to today and the full price of the new product will be charged. If ‘true` is sent, the billing period will not change and a prorated charge will be issued for the new product.
45 46 47 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 45 def preserve_period @preserve_period end |
#product_handle ⇒ String
The handle of the target Product. Either a product_id or product_handle must be present. A Subscription can be migrated to another product for both the current Product Family and another Product Family. Note: Going to another Product Family, components will not be migrated as well.
52 53 54 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 52 def product_handle @product_handle end |
#product_id ⇒ Integer
The ID of the target Product. Either a product_id or product_handle must be present. A Subscription can be migrated to another product for both the current Product Family and another Product Family. Note: Going to another Product Family, components will not be migrated as well.
17 18 19 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 17 def product_id @product_id end |
#product_price_point_handle ⇒ String
The ID or handle of the specified product’s price point. This can be passed to migrate to a non-default price point.
57 58 59 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 57 def product_price_point_handle @product_price_point_handle end |
#product_price_point_id ⇒ Integer
The ID of the specified product’s price point. This can be passed to migrate to a non-default price point.
22 23 24 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 22 def product_price_point_id @product_price_point_id end |
#proration ⇒ Proration
The ID or handle of the specified product’s price point. This can be passed to migrate to a non-default price point.
62 63 64 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 62 def proration @proration end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 124 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. 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 include_trial = hash['include_trial'] ||= false include_initial_charge = hash['include_initial_charge'] ||= false include_coupons = hash['include_coupons'] ||= true preserve_period = hash['preserve_period'] ||= false product_handle = hash.key?('product_handle') ? hash['product_handle'] : SKIP product_price_point_handle = hash.key?('product_price_point_handle') ? hash['product_price_point_handle'] : SKIP proration = Proration.from_hash(hash['proration']) if hash['proration'] # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. SubscriptionProductMigration.new(product_id: product_id, product_price_point_id: product_price_point_id, include_trial: include_trial, include_initial_charge: include_initial_charge, include_coupons: include_coupons, preserve_period: preserve_period, product_handle: product_handle, product_price_point_handle: product_price_point_handle, proration: proration, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 65 def self.names @_hash = {} if @_hash.nil? @_hash['product_id'] = 'product_id' @_hash['product_price_point_id'] = 'product_price_point_id' @_hash['include_trial'] = 'include_trial' @_hash['include_initial_charge'] = 'include_initial_charge' @_hash['include_coupons'] = 'include_coupons' @_hash['preserve_period'] = 'preserve_period' @_hash['product_handle'] = 'product_handle' @_hash['product_price_point_handle'] = 'product_price_point_handle' @_hash['proration'] = 'proration' @_hash end |
.nullables ⇒ Object
An array for nullable fields
95 96 97 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 95 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/advanced_billing/models/subscription_product_migration.rb', line 80 def self.optionals %w[ product_id product_price_point_id include_trial include_initial_charge include_coupons preserve_period product_handle product_price_point_handle proration ] end |