Class: AdvancedBilling::OverrideSubscription
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::OverrideSubscription
- Defined in:
- lib/advanced_billing/models/override_subscription.rb
Overview
OverrideSubscription Model.
Instance Attribute Summary collapse
-
#activated_at ⇒ String
Can be used to record an external signup date.
-
#canceled_at ⇒ String
Can be used to record an external cancellation date.
-
#cancellation_message ⇒ String
Can be used to record a reason for the original cancellation.
-
#current_period_starts_at ⇒ String
Can only be used when a subscription is unbilled, which happens when a future initial billing date is passed at subscription creation.
-
#expires_at ⇒ String
Can be used to record an external expiration date.
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(activated_at = SKIP, canceled_at = SKIP, cancellation_message = SKIP, expires_at = SKIP, current_period_starts_at = SKIP) ⇒ OverrideSubscription
constructor
A new instance of OverrideSubscription.
Methods inherited from BaseModel
Constructor Details
#initialize(activated_at = SKIP, canceled_at = SKIP, cancellation_message = SKIP, expires_at = SKIP, current_period_starts_at = SKIP) ⇒ OverrideSubscription
Returns a new instance of OverrideSubscription.
69 70 71 72 73 74 75 76 77 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 69 def initialize(activated_at = SKIP, canceled_at = SKIP, = SKIP, expires_at = SKIP, current_period_starts_at = SKIP) @activated_at = activated_at unless activated_at == SKIP @canceled_at = canceled_at unless canceled_at == SKIP @cancellation_message = unless == SKIP @expires_at = expires_at unless expires_at == SKIP @current_period_starts_at = current_period_starts_at unless current_period_starts_at == SKIP end |
Instance Attribute Details
#activated_at ⇒ String
Can be used to record an external signup date. Chargify uses this field to record when a subscription first goes active (either at signup or at trial end)
16 17 18 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 16 def activated_at @activated_at end |
#canceled_at ⇒ String
Can be used to record an external cancellation date. Chargify sets this field automatically when a subscription is canceled, whether by request or via dunning.
22 23 24 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 22 def canceled_at @canceled_at end |
#cancellation_message ⇒ String
Can be used to record a reason for the original cancellation.
26 27 28 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 26 def @cancellation_message end |
#current_period_starts_at ⇒ String
Can only be used when a subscription is unbilled, which happens when a future initial billing date is passed at subscription creation. The value passed must be before the current date and time. Allows you to set when the period started so mid period component allocations have the correct proration.
40 41 42 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 40 def current_period_starts_at @current_period_starts_at end |
#expires_at ⇒ String
Can be used to record an external expiration date. Chargify sets this field automatically when a subscription expires (ceases billing) after a prescribed amount of time.
32 33 34 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 32 def expires_at @expires_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 80 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. activated_at = hash.key?('activated_at') ? hash['activated_at'] : SKIP canceled_at = hash.key?('canceled_at') ? hash['canceled_at'] : SKIP = hash.key?('cancellation_message') ? hash['cancellation_message'] : SKIP expires_at = hash.key?('expires_at') ? hash['expires_at'] : SKIP current_period_starts_at = hash.key?('current_period_starts_at') ? hash['current_period_starts_at'] : SKIP # Create object from extracted values. OverrideSubscription.new(activated_at, canceled_at, , expires_at, current_period_starts_at) end |
.names ⇒ Object
A mapping from model property names to API property names.
43 44 45 46 47 48 49 50 51 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 43 def self.names @_hash = {} if @_hash.nil? @_hash['activated_at'] = 'activated_at' @_hash['canceled_at'] = 'canceled_at' @_hash['cancellation_message'] = 'cancellation_message' @_hash['expires_at'] = 'expires_at' @_hash['current_period_starts_at'] = 'current_period_starts_at' @_hash end |
.nullables ⇒ Object
An array for nullable fields
65 66 67 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 65 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 61 62 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 54 def self.optionals %w[ activated_at canceled_at cancellation_message expires_at current_period_starts_at ] end |