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, metadata: SKIP, status: SKIP, schedule_settings: SKIP, next_payment: SKIP, additional_properties: nil) ⇒ SubscriptionUpdateRequest

Returns a new instance of SubscriptionUpdateRequest.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 70

def initialize(transaction_token_id: SKIP, amount: 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
  @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

#metadataGenericMetadata

A free-form dictionary for custom metadata.

Returns:



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

def 
  @metadata
end

#next_paymentSubscriptionUpdateNextPayment

Fields that can be updated on the next scheduled payment.



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

def next_payment
  @next_payment
end

#schedule_settingsSubscriptionUpdateScheduleSettings

Schedule settings that can be updated on a subscription.



35
36
37
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 35

def schedule_settings
  @schedule_settings
end

#statusSubscriptionUpdateStatus

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



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

def status
  @status
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.



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
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 86

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
   = 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,
                                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.



42
43
44
45
46
47
48
49
50
51
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 42

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

.nullablesObject

An array for nullable fields



66
67
68
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 66

def self.nullables
  []
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
63
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 54

def self.optionals
  %w[
    transaction_token_id
    amount
    metadata
    status
    schedule_settings
    next_payment
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



126
127
128
129
130
131
132
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 126

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_token_id: #{@transaction_token_id.inspect}, amount:"\
  " #{@amount.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.



118
119
120
121
122
123
# File 'lib/univapay_client_sdk/models/subscription_update_request.rb', line 118

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