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 ⇒ DateTime
Can be used to record an external signup date.
-
#canceled_at ⇒ DateTime
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 ⇒ DateTime
Can only be used when a subscription is unbilled, which happens when a future initial billing date is passed at subscription creation.
-
#expires_at ⇒ DateTime
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, additional_properties: {}) ⇒ OverrideSubscription
constructor
A new instance of OverrideSubscription.
- #to_custom_activated_at ⇒ Object
- #to_custom_canceled_at ⇒ Object
- #to_custom_current_period_starts_at ⇒ Object
- #to_custom_expires_at ⇒ Object
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(activated_at: SKIP, canceled_at: SKIP, cancellation_message: SKIP, expires_at: SKIP, current_period_starts_at: SKIP, additional_properties: {}) ⇒ OverrideSubscription
Returns a new instance of OverrideSubscription.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 70 def initialize(activated_at: SKIP, canceled_at: SKIP, cancellation_message: SKIP, expires_at: SKIP, current_period_starts_at: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @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 ⇒ DateTime
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). Only ISO8601 format is supported.
17 18 19 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 17 def activated_at @activated_at end |
#canceled_at ⇒ DateTime
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. Only ISO8601 format is supported.
23 24 25 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 23 def canceled_at @canceled_at end |
#cancellation_message ⇒ String
Can be used to record a reason for the original cancellation.
27 28 29 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 27 def @cancellation_message end |
#current_period_starts_at ⇒ DateTime
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. Only ISO8601 format is supported.
41 42 43 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 41 def current_period_starts_at @current_period_starts_at end |
#expires_at ⇒ DateTime
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. Only ISO8601 format is supported.
33 34 35 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 33 def expires_at @expires_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 86 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. activated_at = if hash.key?('activated_at') (DateTimeHelper.from_rfc3339(hash['activated_at']) if hash['activated_at']) else SKIP end canceled_at = if hash.key?('canceled_at') (DateTimeHelper.from_rfc3339(hash['canceled_at']) if hash['canceled_at']) else SKIP end = hash.key?('cancellation_message') ? hash['cancellation_message'] : SKIP expires_at = if hash.key?('expires_at') (DateTimeHelper.from_rfc3339(hash['expires_at']) if hash['expires_at']) else SKIP end current_period_starts_at = if hash.key?('current_period_starts_at') (DateTimeHelper.from_rfc3339(hash['current_period_starts_at']) if hash['current_period_starts_at']) else SKIP end # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. OverrideSubscription.new(activated_at: activated_at, canceled_at: canceled_at, cancellation_message: , expires_at: expires_at, current_period_starts_at: current_period_starts_at, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
44 45 46 47 48 49 50 51 52 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 44 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
66 67 68 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 66 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 58 59 60 61 62 63 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 55 def self.optionals %w[ activated_at canceled_at cancellation_message expires_at current_period_starts_at ] end |
Instance Method Details
#to_custom_activated_at ⇒ Object
125 126 127 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 125 def to_custom_activated_at DateTimeHelper.to_rfc3339(activated_at) end |
#to_custom_canceled_at ⇒ Object
129 130 131 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 129 def to_custom_canceled_at DateTimeHelper.to_rfc3339(canceled_at) end |
#to_custom_current_period_starts_at ⇒ Object
137 138 139 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 137 def to_custom_current_period_starts_at DateTimeHelper.to_rfc3339(current_period_starts_at) end |
#to_custom_expires_at ⇒ Object
133 134 135 |
# File 'lib/advanced_billing/models/override_subscription.rb', line 133 def to_custom_expires_at DateTimeHelper.to_rfc3339(expires_at) end |