Class: AdvancedBilling::CancellationOptions
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CancellationOptions
- Defined in:
- lib/advanced_billing/models/cancellation_options.rb
Overview
CancellationOptions Model.
Instance Attribute Summary collapse
-
#cancel_at_end_of_period ⇒ TrueClass | FalseClass
When true, the subscription is cancelled at the current period end instead of immediately.
-
#cancellation_message ⇒ String
An indication as to why the subscription is being canceled.
-
#reason_code ⇒ String
The reason code associated with the cancellation.
-
#refund_prepayment_account_balance ⇒ TrueClass | FalseClass
Applies to prepaid subscriptions.
-
#scheduled_cancellation_at ⇒ DateTime
Schedules the cancellation on the provided 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(cancellation_message: SKIP, reason_code: SKIP, cancel_at_end_of_period: SKIP, scheduled_cancellation_at: SKIP, refund_prepayment_account_balance: SKIP, additional_properties: {}) ⇒ CancellationOptions
constructor
A new instance of CancellationOptions.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_scheduled_cancellation_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(cancellation_message: SKIP, reason_code: SKIP, cancel_at_end_of_period: SKIP, scheduled_cancellation_at: SKIP, refund_prepayment_account_balance: SKIP, additional_properties: {}) ⇒ CancellationOptions
Returns a new instance of CancellationOptions.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 74 def initialize(cancellation_message: SKIP, reason_code: SKIP, cancel_at_end_of_period: SKIP, scheduled_cancellation_at: SKIP, refund_prepayment_account_balance: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end = unless == SKIP @reason_code = reason_code unless reason_code == SKIP @cancel_at_end_of_period = cancel_at_end_of_period unless cancel_at_end_of_period == SKIP unless scheduled_cancellation_at == SKIP @scheduled_cancellation_at = scheduled_cancellation_at end unless refund_prepayment_account_balance == SKIP @refund_prepayment_account_balance = refund_prepayment_account_balance end end |
Instance Attribute Details
#cancel_at_end_of_period ⇒ TrueClass | FalseClass
When true, the subscription is cancelled at the current period end instead of immediately. To use this option, the Schedule Subscription Cancellation feature must be enabled on your site.
28 29 30 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 28 def cancel_at_end_of_period @cancel_at_end_of_period end |
#cancellation_message ⇒ String
An indication as to why the subscription is being canceled. For your internal use.
16 17 18 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 16 def end |
#reason_code ⇒ String
The reason code associated with the cancellation. Use the [List Reason Codes]($e/Reason%20Codes/listReasonCodes) endpoint to retrieve the reason codes associated with your site.
22 23 24 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 22 def reason_code @reason_code end |
#refund_prepayment_account_balance ⇒ TrueClass | FalseClass
Applies to prepaid subscriptions. When true, which is the default, the remaining prepaid balance is refunded as part of cancellation processing. When false, prepaid balance is not refunded as part of cancellation processing. To use this option, the Schedule Subscription Cancellation feature must be enabled on your site.
42 43 44 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 42 def refund_prepayment_account_balance @refund_prepayment_account_balance end |
#scheduled_cancellation_at ⇒ DateTime
Schedules the cancellation on the provided date. This is option is not applicable for prepaid subscriptions. To use this option, the Schedule Subscription Cancellation feature must be enabled on your site.
34 35 36 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 34 def scheduled_cancellation_at @scheduled_cancellation_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 124 125 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 98 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = hash.key?('cancellation_message') ? hash['cancellation_message'] : SKIP reason_code = hash.key?('reason_code') ? hash['reason_code'] : SKIP cancel_at_end_of_period = hash.key?('cancel_at_end_of_period') ? hash['cancel_at_end_of_period'] : SKIP scheduled_cancellation_at = if hash.key?('scheduled_cancellation_at') (DateTimeHelper.from_rfc3339(hash['scheduled_cancellation_at']) if hash['scheduled_cancellation_at']) else SKIP end refund_prepayment_account_balance = hash.key?('refund_prepayment_account_balance') ? hash['refund_prepayment_account_balance'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CancellationOptions.new(cancellation_message: , reason_code: reason_code, cancel_at_end_of_period: cancel_at_end_of_period, scheduled_cancellation_at: scheduled_cancellation_at, refund_prepayment_account_balance: refund_prepayment_account_balance, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 45 def self.names @_hash = {} if @_hash.nil? @_hash['cancellation_message'] = 'cancellation_message' @_hash['reason_code'] = 'reason_code' @_hash['cancel_at_end_of_period'] = 'cancel_at_end_of_period' @_hash['scheduled_cancellation_at'] = 'scheduled_cancellation_at' @_hash['refund_prepayment_account_balance'] = 'refund_prepayment_account_balance' @_hash end |
.nullables ⇒ Object
An array for nullable fields
68 69 70 71 72 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 68 def self.nullables %w[ scheduled_cancellation_at ] end |
.optionals ⇒ Object
An array for optional fields
57 58 59 60 61 62 63 64 65 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 57 def self.optionals %w[ cancellation_message reason_code cancel_at_end_of_period scheduled_cancellation_at refund_prepayment_account_balance ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
142 143 144 145 146 147 148 149 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 142 def inspect class_name = self.class.name.split('::').last "<#{class_name} cancellation_message: #{@cancellation_message.inspect}, reason_code:"\ " #{@reason_code.inspect}, cancel_at_end_of_period: #{@cancel_at_end_of_period.inspect},"\ " scheduled_cancellation_at: #{@scheduled_cancellation_at.inspect},"\ " refund_prepayment_account_balance: #{@refund_prepayment_account_balance.inspect},"\ " additional_properties: #{get_additional_properties}>" end |
#to_custom_scheduled_cancellation_at ⇒ Object
127 128 129 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 127 def to_custom_scheduled_cancellation_at DateTimeHelper.to_rfc3339(scheduled_cancellation_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
132 133 134 135 136 137 138 139 |
# File 'lib/advanced_billing/models/cancellation_options.rb', line 132 def to_s class_name = self.class.name.split('::').last "<#{class_name} cancellation_message: #{@cancellation_message}, reason_code:"\ " #{@reason_code}, cancel_at_end_of_period: #{@cancel_at_end_of_period},"\ " scheduled_cancellation_at: #{@scheduled_cancellation_at},"\ " refund_prepayment_account_balance: #{@refund_prepayment_account_balance},"\ " additional_properties: #{get_additional_properties}>" end |