Class: UnivapayClientSdk::SubscriptionUpdateRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/univapay_client_sdk/models/subscription_update_request.rb

Overview

Request payload for updating a subscription.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(transaction_token_id: SKIP, amount: SKIP, period: SKIP, cyclical_period: SKIP, initial_amount: SKIP, subscription_plan: SKIP, installment_plan: SKIP, metadata: SKIP, status: SKIP, schedule_settings: SKIP, next_payment: SKIP, additional_properties: nil) ⇒ SubscriptionUpdateRequest

Returns a new instance of SubscriptionUpdateRequest.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 104

def initialize(transaction_token_id: SKIP, amount: SKIP, period: SKIP,
               cyclical_period: SKIP, initial_amount: SKIP,
               subscription_plan: SKIP, installment_plan: SKIP,
               metadata: SKIP, status: SKIP, schedule_settings: SKIP,
               next_payment: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @transaction_token_id = transaction_token_id unless transaction_token_id == SKIP
  @amount = amount unless amount == SKIP
  @period = period unless period == SKIP
  @cyclical_period = cyclical_period unless cyclical_period == SKIP
  @initial_amount = initial_amount unless initial_amount == SKIP
  @subscription_plan = subscription_plan unless subscription_plan == SKIP
  @installment_plan = installment_plan unless installment_plan == SKIP
  @metadata =  unless  == SKIP
  @status = status unless status == SKIP
  @schedule_settings = schedule_settings unless schedule_settings == SKIP
  @next_payment = next_payment unless next_payment == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountInteger

The recurring charge amount (applied to the cycle after the next one). Not available for limited-cycle subscriptions. To change the immediate next payment amount, update next_payment.amount instead.

Returns:

  • (Integer)


22
23
24
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 22

def amount
  @amount
end

#cyclical_periodString

ISO-8601 Duration for custom frequency (e.g., P3D, P2M). Cannot be used together with period. Only allowed before the subscription's first payment has been paid.

Returns:

  • (String)


32
33
34
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 32

def cyclical_period
  @cyclical_period
end

#initial_amountInteger

Different amount for the first charge. Only allowed while the subscription status is still editable (before it has started) and requires the App Token Secret.

Returns:

  • (Integer)


38
39
40
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 38

def initial_amount
  @initial_amount
end

#installment_planSubscriptionInstallmentPlan

Configuration for credit card company side installments.



46
47
48
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 46

def installment_plan
  @installment_plan
end

#metadataGenericMetadata

A free-form dictionary for custom metadata.

Returns:



50
51
52
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 50

def 
  @metadata
end

#next_paymentSubscriptionUpdateNextPayment

Fields that can be updated on the next scheduled payment.



63
64
65
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 63

def next_payment
  @next_payment
end

#periodSubscriptionPeriod

Subscription Period schema.

Returns:



26
27
28
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 26

def period
  @period
end

#schedule_settingsSubscriptionUpdateScheduleSettings

Schedule settings that can be updated on a subscription.



59
60
61
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 59

def schedule_settings
  @schedule_settings
end

#statusSubscriptionUpdateStatus

Update the subscription status. suspended: Pause the subscription. unpaid: Resume a suspended subscription.



55
56
57
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 55

def status
  @status
end

#subscription_planSubscriptionPlanSettings

Configuration for limited-cycle subscriptions (Univapay side).



42
43
44
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 42

def subscription_plan
  @subscription_plan
end

#transaction_token_idUUID | String

Transaction token ID used for the subscription. Can be changed to update the payment method (e.g., when a card expires). Allowed only when the status is unconfirmed, unpaid, current, or suspended.

Returns:

  • (UUID | String)


16
17
18
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 16

def transaction_token_id
  @transaction_token_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 127

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_token_id =
    hash.key?('transaction_token_id') ? hash['transaction_token_id'] : SKIP
  amount = hash.key?('amount') ? hash['amount'] : SKIP
  period = hash.key?('period') ? hash['period'] : SKIP
  cyclical_period =
    hash.key?('cyclical_period') ? hash['cyclical_period'] : SKIP
  initial_amount =
    hash.key?('initial_amount') ? hash['initial_amount'] : SKIP
  subscription_plan = SubscriptionPlanSettings.from_hash(hash['subscription_plan']) if
    hash['subscription_plan']
  installment_plan = SubscriptionInstallmentPlan.from_hash(hash['installment_plan']) if
    hash['installment_plan']
   = GenericMetadata.from_hash(hash['metadata']) if hash['metadata']
  status = hash.key?('status') ? hash['status'] : SKIP
  schedule_settings = SubscriptionUpdateScheduleSettings.from_hash(hash['schedule_settings']) if
    hash['schedule_settings']
  next_payment = SubscriptionUpdateNextPayment.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.
  SubscriptionUpdateRequest.new(transaction_token_id: transaction_token_id,
                                amount: amount,
                                period: period,
                                cyclical_period: cyclical_period,
                                initial_amount: initial_amount,
                                subscription_plan: subscription_plan,
                                installment_plan: installment_plan,
                                metadata: ,
                                status: status,
                                schedule_settings: schedule_settings,
                                next_payment: next_payment,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 66

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_token_id'] = 'transaction_token_id'
  @_hash['amount'] = 'amount'
  @_hash['period'] = 'period'
  @_hash['cyclical_period'] = 'cyclical_period'
  @_hash['initial_amount'] = 'initial_amount'
  @_hash['subscription_plan'] = 'subscription_plan'
  @_hash['installment_plan'] = 'installment_plan'
  @_hash['metadata'] = 'metadata'
  @_hash['status'] = 'status'
  @_hash['schedule_settings'] = 'schedule_settings'
  @_hash['next_payment'] = 'next_payment'
  @_hash
end

.nullablesObject

An array for nullable fields



100
101
102
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 100

def self.nullables
  []
end

.optionalsObject

An array for optional fields



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 83

def self.optionals
  %w[
    transaction_token_id
    amount
    period
    cyclical_period
    initial_amount
    subscription_plan
    installment_plan
    metadata
    status
    schedule_settings
    next_payment
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



183
184
185
186
187
188
189
190
191
192
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 183

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_token_id: #{@transaction_token_id.inspect}, amount:"\
  " #{@amount.inspect}, period: #{@period.inspect}, cyclical_period:"\
  " #{@cyclical_period.inspect}, initial_amount: #{@initial_amount.inspect},"\
  " subscription_plan: #{@subscription_plan.inspect}, installment_plan:"\
  " #{@installment_plan.inspect}, metadata: #{@metadata.inspect}, status: #{@status.inspect},"\
  " schedule_settings: #{@schedule_settings.inspect}, next_payment: #{@next_payment.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



173
174
175
176
177
178
179
180
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 173

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_token_id: #{@transaction_token_id}, amount: #{@amount}, period:"\
  " #{@period}, cyclical_period: #{@cyclical_period}, initial_amount: #{@initial_amount},"\
  " subscription_plan: #{@subscription_plan}, installment_plan: #{@installment_plan},"\
  " metadata: #{@metadata}, status: #{@status}, schedule_settings: #{@schedule_settings},"\
  " next_payment: #{@next_payment}, additional_properties: #{@additional_properties}>"
end