Class: UnivapayClientSdk::Subscription
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UnivapayClientSdk::Subscription
- Defined in:
- lib/univapay_client_sdk/models/subscription.rb
Overview
The Subscription object represents a recurring payment schedule.
Instance Attribute Summary collapse
-
#amount ⇒ Integer
Amount in the smallest currency unit.
-
#amount_formatted ⇒ Float
Amount formatted for display.
-
#created_on ⇒ DateTime
Timestamp when the resource was created.
-
#currency ⇒ String
ISO-4217 currency code.
-
#first_charge_authorization_only ⇒ TrueClass | FalseClass
Whether the first charge is authorization-only.
-
#first_charge_capture_after ⇒ String
ISO-8601 Duration (e.g., P3D).
-
#id ⇒ UUID | String
Unique identifier.
-
#initial_amount ⇒ Integer
Initial amount in the smallest currency unit.
-
#initial_amount_formatted ⇒ Float
Initial amount formatted for display.
-
#metadata ⇒ GenericMetadata
A free-form dictionary for custom metadata.
-
#mode ⇒ ChargeMode
Charge Mode schema.
-
#next_payment ⇒ SubscriptionNextPayment
Next scheduled payment details for a subscription.
-
#only_direct_currency ⇒ TrueClass | FalseClass
Whether only direct currency processing is allowed.
-
#period ⇒ SubscriptionPeriod
Subscription Period schema.
-
#schedule_settings ⇒ SubscriptionScheduleSettings
Schedule settings applied to a subscription.
-
#status ⇒ SubscriptionStatus
Subscription Status schema.
-
#store_id ⇒ UUID | String
Store identifier.
-
#subsequent_cycles_start ⇒ DateTime
Timestamp when recurring cycles begin.
-
#transaction_token_id ⇒ UUID | String
Transaction token identifier.
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(id: SKIP, store_id: SKIP, transaction_token_id: SKIP, amount: SKIP, currency: SKIP, amount_formatted: SKIP, initial_amount: SKIP, initial_amount_formatted: SKIP, subsequent_cycles_start: SKIP, schedule_settings: SKIP, only_direct_currency: SKIP, first_charge_capture_after: SKIP, first_charge_authorization_only: SKIP, status: SKIP, metadata: SKIP, mode: SKIP, created_on: SKIP, period: SKIP, next_payment: SKIP, additional_properties: nil) ⇒ Subscription
constructor
A new instance of Subscription.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_on ⇒ Object
- #to_custom_subsequent_cycles_start ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the 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(id: SKIP, store_id: SKIP, transaction_token_id: SKIP, amount: SKIP, currency: SKIP, amount_formatted: SKIP, initial_amount: SKIP, initial_amount_formatted: SKIP, subsequent_cycles_start: SKIP, schedule_settings: SKIP, only_direct_currency: SKIP, first_charge_capture_after: SKIP, first_charge_authorization_only: SKIP, status: SKIP, metadata: SKIP, mode: SKIP, created_on: SKIP, period: SKIP, next_payment: SKIP, additional_properties: nil) ⇒ Subscription
Returns a new instance of Subscription.
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 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 150 def initialize(id: SKIP, store_id: SKIP, transaction_token_id: SKIP, amount: SKIP, currency: SKIP, amount_formatted: SKIP, initial_amount: SKIP, initial_amount_formatted: SKIP, subsequent_cycles_start: SKIP, schedule_settings: SKIP, only_direct_currency: SKIP, first_charge_capture_after: SKIP, first_charge_authorization_only: SKIP, status: SKIP, metadata: SKIP, mode: SKIP, created_on: SKIP, period: SKIP, next_payment: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id unless id == SKIP @store_id = store_id unless store_id == SKIP @transaction_token_id = transaction_token_id unless transaction_token_id == SKIP @amount = amount unless amount == SKIP @currency = currency unless currency == SKIP @amount_formatted = amount_formatted unless amount_formatted == SKIP @initial_amount = initial_amount unless initial_amount == SKIP @initial_amount_formatted = initial_amount_formatted unless initial_amount_formatted == SKIP @subsequent_cycles_start = subsequent_cycles_start unless subsequent_cycles_start == SKIP @schedule_settings = schedule_settings unless schedule_settings == SKIP @only_direct_currency = only_direct_currency unless only_direct_currency == SKIP unless first_charge_capture_after == SKIP @first_charge_capture_after = first_charge_capture_after end unless == SKIP @first_charge_authorization_only = end @status = status unless status == SKIP @metadata = unless == SKIP @mode = mode unless mode == SKIP @created_on = created_on unless created_on == SKIP @period = period unless period == SKIP @next_payment = next_payment unless next_payment == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Integer
Amount in the smallest currency unit.
27 28 29 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 27 def amount @amount end |
#amount_formatted ⇒ Float
Amount formatted for display.
35 36 37 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 35 def amount_formatted @amount_formatted end |
#created_on ⇒ DateTime
Timestamp when the resource was created.
79 80 81 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 79 def created_on @created_on end |
#currency ⇒ String
ISO-4217 currency code.
31 32 33 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 31 def currency @currency end |
#first_charge_authorization_only ⇒ TrueClass | FalseClass
Whether the first charge is authorization-only.
63 64 65 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 63 def @first_charge_authorization_only end |
#first_charge_capture_after ⇒ String
ISO-8601 Duration (e.g., P3D).
59 60 61 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 59 def first_charge_capture_after @first_charge_capture_after end |
#id ⇒ UUID | String
Unique identifier.
15 16 17 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 15 def id @id end |
#initial_amount ⇒ Integer
Initial amount in the smallest currency unit.
39 40 41 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 39 def initial_amount @initial_amount end |
#initial_amount_formatted ⇒ Float
Initial amount formatted for display.
43 44 45 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 43 def initial_amount_formatted @initial_amount_formatted end |
#metadata ⇒ GenericMetadata
A free-form dictionary for custom metadata.
71 72 73 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 71 def @metadata end |
#mode ⇒ ChargeMode
Charge Mode schema.
75 76 77 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 75 def mode @mode end |
#next_payment ⇒ SubscriptionNextPayment
Next scheduled payment details for a subscription.
87 88 89 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 87 def next_payment @next_payment end |
#only_direct_currency ⇒ TrueClass | FalseClass
Whether only direct currency processing is allowed.
55 56 57 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 55 def only_direct_currency @only_direct_currency end |
#period ⇒ SubscriptionPeriod
Subscription Period schema.
83 84 85 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 83 def period @period end |
#schedule_settings ⇒ SubscriptionScheduleSettings
Schedule settings applied to a subscription.
51 52 53 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 51 def schedule_settings @schedule_settings end |
#status ⇒ SubscriptionStatus
Subscription Status schema.
67 68 69 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 67 def status @status end |
#store_id ⇒ UUID | String
Store identifier.
19 20 21 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 19 def store_id @store_id end |
#subsequent_cycles_start ⇒ DateTime
Timestamp when recurring cycles begin.
47 48 49 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 47 def subsequent_cycles_start @subsequent_cycles_start end |
#transaction_token_id ⇒ UUID | String
Transaction token identifier.
23 24 25 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 23 def transaction_token_id @transaction_token_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 190 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP store_id = hash.key?('store_id') ? hash['store_id'] : SKIP transaction_token_id = hash.key?('transaction_token_id') ? hash['transaction_token_id'] : SKIP amount = hash.key?('amount') ? hash['amount'] : SKIP currency = hash.key?('currency') ? hash['currency'] : SKIP amount_formatted = hash.key?('amount_formatted') ? hash['amount_formatted'] : SKIP initial_amount = hash.key?('initial_amount') ? hash['initial_amount'] : SKIP initial_amount_formatted = hash.key?('initial_amount_formatted') ? hash['initial_amount_formatted'] : SKIP subsequent_cycles_start = if hash.key?('subsequent_cycles_start') (DateTimeHelper.from_rfc3339(hash['subsequent_cycles_start']) if hash['subsequent_cycles_start']) else SKIP end schedule_settings = SubscriptionScheduleSettings.from_hash(hash['schedule_settings']) if hash['schedule_settings'] only_direct_currency = hash.key?('only_direct_currency') ? hash['only_direct_currency'] : SKIP first_charge_capture_after = hash.key?('first_charge_capture_after') ? hash['first_charge_capture_after'] : SKIP = hash.key?('first_charge_authorization_only') ? hash['first_charge_authorization_only'] : SKIP status = hash.key?('status') ? hash['status'] : SKIP = GenericMetadata.from_hash(hash['metadata']) if hash['metadata'] mode = hash.key?('mode') ? hash['mode'] : SKIP created_on = if hash.key?('created_on') (DateTimeHelper.from_rfc3339(hash['created_on']) if hash['created_on']) else SKIP end period = hash.key?('period') ? hash['period'] : SKIP next_payment = SubscriptionNextPayment.from_hash(hash['next_payment']) if hash['next_payment'] # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Subscription.new(id: id, store_id: store_id, transaction_token_id: transaction_token_id, amount: amount, currency: currency, amount_formatted: amount_formatted, initial_amount: initial_amount, initial_amount_formatted: initial_amount_formatted, subsequent_cycles_start: subsequent_cycles_start, schedule_settings: schedule_settings, only_direct_currency: only_direct_currency, first_charge_capture_after: first_charge_capture_after, first_charge_authorization_only: , status: status, metadata: , mode: mode, created_on: created_on, period: period, next_payment: next_payment, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 90 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['store_id'] = 'store_id' @_hash['transaction_token_id'] = 'transaction_token_id' @_hash['amount'] = 'amount' @_hash['currency'] = 'currency' @_hash['amount_formatted'] = 'amount_formatted' @_hash['initial_amount'] = 'initial_amount' @_hash['initial_amount_formatted'] = 'initial_amount_formatted' @_hash['subsequent_cycles_start'] = 'subsequent_cycles_start' @_hash['schedule_settings'] = 'schedule_settings' @_hash['only_direct_currency'] = 'only_direct_currency' @_hash['first_charge_capture_after'] = 'first_charge_capture_after' @_hash['first_charge_authorization_only'] = 'first_charge_authorization_only' @_hash['status'] = 'status' @_hash['metadata'] = 'metadata' @_hash['mode'] = 'mode' @_hash['created_on'] = 'created_on' @_hash['period'] = 'period' @_hash['next_payment'] = 'next_payment' @_hash end |
.nullables ⇒ Object
An array for nullable fields
141 142 143 144 145 146 147 148 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 141 def self.nullables %w[ initial_amount initial_amount_formatted subsequent_cycles_start first_charge_capture_after ] end |
.optionals ⇒ Object
An array for optional fields
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 116 def self.optionals %w[ id store_id transaction_token_id amount currency amount_formatted initial_amount initial_amount_formatted subsequent_cycles_start schedule_settings only_direct_currency first_charge_capture_after first_charge_authorization_only status metadata mode created_on period next_payment ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
271 272 273 274 275 276 277 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 271 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 294 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, store_id: #{@store_id.inspect}, transaction_token_id:"\ " #{@transaction_token_id.inspect}, amount: #{@amount.inspect}, currency:"\ " #{@currency.inspect}, amount_formatted: #{@amount_formatted.inspect}, initial_amount:"\ " #{@initial_amount.inspect}, initial_amount_formatted:"\ " #{@initial_amount_formatted.inspect}, subsequent_cycles_start:"\ " #{@subsequent_cycles_start.inspect}, schedule_settings: #{@schedule_settings.inspect},"\ " only_direct_currency: #{@only_direct_currency.inspect}, first_charge_capture_after:"\ " #{@first_charge_capture_after.inspect}, first_charge_authorization_only:"\ " #{@first_charge_authorization_only.inspect}, status: #{@status.inspect}, metadata:"\ " #{@metadata.inspect}, mode: #{@mode.inspect}, created_on: #{@created_on.inspect}, period:"\ " #{@period.inspect}, next_payment: #{@next_payment.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_created_on ⇒ Object
265 266 267 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 265 def to_custom_created_on DateTimeHelper.to_rfc3339(created_on) end |
#to_custom_subsequent_cycles_start ⇒ Object
261 262 263 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 261 def to_custom_subsequent_cycles_start DateTimeHelper.to_rfc3339(subsequent_cycles_start) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/univapay_client_sdk/models/subscription.rb', line 280 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, store_id: #{@store_id}, transaction_token_id:"\ " #{@transaction_token_id}, amount: #{@amount}, currency: #{@currency}, amount_formatted:"\ " #{@amount_formatted}, initial_amount: #{@initial_amount}, initial_amount_formatted:"\ " #{@initial_amount_formatted}, subsequent_cycles_start: #{@subsequent_cycles_start},"\ " schedule_settings: #{@schedule_settings}, only_direct_currency: #{@only_direct_currency},"\ " first_charge_capture_after: #{@first_charge_capture_after},"\ " first_charge_authorization_only: #{@first_charge_authorization_only}, status: #{@status},"\ " metadata: #{@metadata}, mode: #{@mode}, created_on: #{@created_on}, period: #{@period},"\ " next_payment: #{@next_payment}, additional_properties: #{@additional_properties}>" end |