Class: UnivapayClientSdk::SubscriptionPayment

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

Overview

Represents a single scheduled or historical payment 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, additional_properties: nil) ⇒ SubscriptionPayment

Returns a new instance of SubscriptionPayment.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 91

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,
               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
  @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_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_payment.rb', line 35

def amount_formatted
  @amount_formatted
end

#created_onDateTime

Timestamp when the resource was created.

Returns:

  • (DateTime)


48
49
50
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 48

def created_on
  @created_on
end

#currencyString

ISO-4217 currency code.

Returns:

  • (String)


31
32
33
# File 'lib/univapay_client_sdk/models/subscription_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_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_payment.rb', line 15

def id
  @id
end

#is_last_paymentTrueClass | FalseClass

Indicates if this is the final payment in a limited-cycle subscription.

Returns:

  • (TrueClass | FalseClass)


44
45
46
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 44

def is_last_payment
  @is_last_payment
end

#is_paidTrueClass | FalseClass

Indicates whether this specific payment cycle has been successfully charged.

Returns:

  • (TrueClass | FalseClass)


40
41
42
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 40

def is_paid
  @is_paid
end

#updated_onDateTime

Timestamp when the resource was last updated.

Returns:

  • (DateTime)


52
53
54
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 52

def updated_on
  @updated_on
end

#zone_idString

IANA Timezone ID.

Returns:

  • (String)


23
24
25
# File 'lib/univapay_client_sdk/models/subscription_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.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 112

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

  # 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.
  SubscriptionPayment.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,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 55

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
end

.nullablesObject

An array for nullable fields



87
88
89
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 87

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



176
177
178
179
180
181
182
183
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 176

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}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_onObject



158
159
160
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 158

def to_custom_created_on
  DateTimeHelper.to_rfc3339(created_on)
end

#to_custom_updated_onObject



162
163
164
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 162

def to_custom_updated_on
  DateTimeHelper.to_rfc3339(updated_on)
end

#to_sObject

Provides a human-readable string representation of the object.



167
168
169
170
171
172
173
# File 'lib/univapay_client_sdk/models/subscription_payment.rb', line 167

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}, additional_properties: #{@additional_properties}>"
end