Class: UnivapayClientSdk::SubscriptionNextPayment

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

Overview

Next scheduled payment details for 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(id: SKIP, due_date: SKIP, zone_id: SKIP, amount: SKIP, currency: SKIP, amount_formatted: SKIP, is_paid: SKIP, is_last_payment: SKIP, created_on: SKIP, updated_on: SKIP, retry_date: SKIP, terminate_with_status: SKIP, additional_properties: nil) ⇒ SubscriptionNextPayment

Returns a new instance of SubscriptionNextPayment.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 107

def initialize(id: SKIP, due_date: SKIP, zone_id: SKIP, amount: SKIP,
               currency: SKIP, amount_formatted: SKIP, is_paid: SKIP,
               is_last_payment: SKIP, created_on: SKIP, updated_on: SKIP,
               retry_date: SKIP, terminate_with_status: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id unless id == SKIP
  @due_date = due_date unless due_date == SKIP
  @zone_id = zone_id unless zone_id == SKIP
  @amount = amount unless amount == SKIP
  @currency = currency unless currency == SKIP
  @amount_formatted = amount_formatted unless amount_formatted == SKIP
  @is_paid = is_paid unless is_paid == SKIP
  @is_last_payment = is_last_payment unless is_last_payment == SKIP
  @created_on = created_on unless created_on == SKIP
  @updated_on = updated_on unless updated_on == SKIP
  @retry_date = retry_date unless retry_date == SKIP
  @terminate_with_status = terminate_with_status unless terminate_with_status == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountInteger

Amount in the smallest currency unit.

Returns:

  • (Integer)


27
28
29
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 27

def amount
  @amount
end

#amount_formattedFloat

Amount formatted for display.

Returns:

  • (Float)


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

def amount_formatted
  @amount_formatted
end

#created_onDateTime

Timestamp when the resource was created.

Returns:

  • (DateTime)


47
48
49
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 47

def created_on
  @created_on
end

#currencyString

ISO-4217 currency code.

Returns:

  • (String)


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

def currency
  @currency
end

#due_dateDate

Scheduled due date.

Returns:

  • (Date)


19
20
21
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 19

def due_date
  @due_date
end

#idUUID | String

Unique identifier.

Returns:

  • (UUID | String)


15
16
17
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 15

def id
  @id
end

#is_last_paymentTrueClass | FalseClass

Whether this is the final payment in the schedule.

Returns:

  • (TrueClass | FalseClass)


43
44
45
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 43

def is_last_payment
  @is_last_payment
end

#is_paidTrueClass | FalseClass

Whether the payment has been paid.

Returns:

  • (TrueClass | FalseClass)


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

def is_paid
  @is_paid
end

#retry_dateDate

Scheduled retry date.

Returns:

  • (Date)


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

def retry_date
  @retry_date
end

#terminate_with_statusSubscriptionTerminateWithStatus

Schedule a status transition on a payment's due date. Set to suspended or canceled to schedule termination. Send null to cancel a previously scheduled transition.



61
62
63
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 61

def terminate_with_status
  @terminate_with_status
end

#updated_onDateTime

Timestamp when the resource was last updated.

Returns:

  • (DateTime)


51
52
53
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 51

def updated_on
  @updated_on
end

#zone_idString

IANA timezone identifier.

Returns:

  • (String)


23
24
25
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 23

def zone_id
  @zone_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
171
172
173
174
175
176
177
178
179
180
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 131

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  due_date = hash.key?('due_date') ? hash['due_date'] : SKIP
  zone_id = hash.key?('zone_id') ? hash['zone_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
  is_paid = hash.key?('is_paid') ? hash['is_paid'] : SKIP
  is_last_payment =
    hash.key?('is_last_payment') ? hash['is_last_payment'] : SKIP
  created_on = if hash.key?('created_on')
                 (DateTimeHelper.from_rfc3339(hash['created_on']) if hash['created_on'])
               else
                 SKIP
               end
  updated_on = if hash.key?('updated_on')
                 (DateTimeHelper.from_rfc3339(hash['updated_on']) if hash['updated_on'])
               else
                 SKIP
               end
  retry_date = hash.key?('retry_date') ? hash['retry_date'] : SKIP
  terminate_with_status =
    hash.key?('terminate_with_status') ? hash['terminate_with_status'] : SKIP

  # 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.
  SubscriptionNextPayment.new(id: id,
                              due_date: due_date,
                              zone_id: zone_id,
                              amount: amount,
                              currency: currency,
                              amount_formatted: amount_formatted,
                              is_paid: is_paid,
                              is_last_payment: is_last_payment,
                              created_on: created_on,
                              updated_on: updated_on,
                              retry_date: retry_date,
                              terminate_with_status: terminate_with_status,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['due_date'] = 'due_date'
  @_hash['zone_id'] = 'zone_id'
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['amount_formatted'] = 'amount_formatted'
  @_hash['is_paid'] = 'is_paid'
  @_hash['is_last_payment'] = 'is_last_payment'
  @_hash['created_on'] = 'created_on'
  @_hash['updated_on'] = 'updated_on'
  @_hash['retry_date'] = 'retry_date'
  @_hash['terminate_with_status'] = 'terminate_with_status'
  @_hash
end

.nullablesObject

An array for nullable fields



100
101
102
103
104
105
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 100

def self.nullables
  %w[
    retry_date
    terminate_with_status
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    due_date
    zone_id
    amount
    currency
    amount_formatted
    is_paid
    is_last_payment
    created_on
    updated_on
    retry_date
    terminate_with_status
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



192
193
194
195
196
197
198
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 192

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



211
212
213
214
215
216
217
218
219
220
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 211

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, due_date: #{@due_date.inspect}, zone_id:"\
  " #{@zone_id.inspect}, amount: #{@amount.inspect}, currency: #{@currency.inspect},"\
  " amount_formatted: #{@amount_formatted.inspect}, is_paid: #{@is_paid.inspect},"\
  " is_last_payment: #{@is_last_payment.inspect}, created_on: #{@created_on.inspect},"\
  " updated_on: #{@updated_on.inspect}, retry_date: #{@retry_date.inspect},"\
  " terminate_with_status: #{@terminate_with_status.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_created_onObject



182
183
184
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 182

def to_custom_created_on
  DateTimeHelper.to_rfc3339(created_on)
end

#to_custom_updated_onObject



186
187
188
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 186

def to_custom_updated_on
  DateTimeHelper.to_rfc3339(updated_on)
end

#to_sObject

Provides a human-readable string representation of the object.



201
202
203
204
205
206
207
208
# File 'lib/univapay_client_sdk/models/subscription_next_payment.rb', line 201

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, due_date: #{@due_date}, zone_id: #{@zone_id}, amount:"\
  " #{@amount}, currency: #{@currency}, amount_formatted: #{@amount_formatted}, is_paid:"\
  " #{@is_paid}, is_last_payment: #{@is_last_payment}, created_on: #{@created_on}, updated_on:"\
  " #{@updated_on}, retry_date: #{@retry_date}, terminate_with_status:"\
  " #{@terminate_with_status}, additional_properties: #{@additional_properties}>"
end