Class: UnivapayClientSdk::QrMerchantTransactionToken

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

Overview

Stored transaction token resource for a qr_merchant (QR Merchant-Presented Mode) payment type.

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(data:, id: SKIP, store_id: SKIP, email: SKIP, active: SKIP, mode: SKIP, type: SKIP, usage_limit: SKIP, confirmed: SKIP, metadata: SKIP, created_on: SKIP, updated_on: SKIP, last_used_on: SKIP, additional_properties: nil) ⇒ QrMerchantTransactionToken

Returns a new instance of QrMerchantTransactionToken.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 118

def initialize(data:, id: SKIP, store_id: SKIP, email: SKIP, active: SKIP,
               mode: SKIP, type: SKIP, usage_limit: SKIP, confirmed: SKIP,
               metadata: SKIP, created_on: SKIP, updated_on: SKIP,
               last_used_on: 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
  @email = email unless email == SKIP
  @active = active unless active == SKIP
  @mode = mode unless mode == SKIP
  @type = type unless type == SKIP
  @usage_limit = usage_limit unless usage_limit == SKIP
  @confirmed = confirmed unless confirmed == SKIP
  @metadata =  unless  == SKIP
  @created_on = created_on unless created_on == SKIP
  @updated_on = updated_on unless updated_on == SKIP
  @last_used_on = last_used_on unless last_used_on == SKIP
  @payment_type = 'qr_merchant'
  @data = data
  @additional_properties = additional_properties
end

Instance Attribute Details

#activeTrueClass | FalseClass

Whether the resource is active.

Returns:

  • (TrueClass | FalseClass)


28
29
30
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 28

def active
  @active
end

#confirmedTrueClass | FalseClass

Whether the token has been confirmed.

Returns:

  • (TrueClass | FalseClass)


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

def confirmed
  @confirmed
end

#created_onDateTime

Timestamp when the resource was created.

Returns:

  • (DateTime)


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

def created_on
  @created_on
end

#dataTokenResponseQrMerchantData

Token Response Qr Merchant Data schema.



68
69
70
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 68

def data
  @data
end

#emailString

Customer email address.

Returns:

  • (String)


24
25
26
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 24

def email
  @email
end

#idUUID | String

Unique identifier.

Returns:

  • (UUID | String)


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

def id
  @id
end

#last_used_onDateTime

Timestamp when the token was last used.

Returns:

  • (DateTime)


60
61
62
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 60

def last_used_on
  @last_used_on
end

#metadataHash[String, Object]

Arbitrary key-value metadata.

Returns:

  • (Hash[String, Object])


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

def 
  @metadata
end

#modeTransactionTokenMode

Transaction Token Mode schema.



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

def mode
  @mode
end

#payment_typeString (readonly)

Payment method type. Always qr_merchant for this variant.

Returns:

  • (String)


64
65
66
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 64

def payment_type
  @payment_type
end

#store_idUUID | String

Store identifier.

Returns:

  • (UUID | String)


20
21
22
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 20

def store_id
  @store_id
end

#typeTransactionTokenType

Transaction Token Type schema.



36
37
38
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 36

def type
  @type
end

#updated_onDateTime

Timestamp when the resource was last updated.

Returns:

  • (DateTime)


56
57
58
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 56

def updated_on
  @updated_on
end

#usage_limitString

Usage limit applied to the token.

Returns:

  • (String)


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

def usage_limit
  @usage_limit
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 143

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  data = TokenResponseQrMerchantData.from_hash(hash['data']) if hash['data']
  id = hash.key?('id') ? hash['id'] : SKIP
  store_id = hash.key?('store_id') ? hash['store_id'] : SKIP
  email = hash.key?('email') ? hash['email'] : SKIP
  active = hash.key?('active') ? hash['active'] : SKIP
  mode = hash.key?('mode') ? hash['mode'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  usage_limit = hash.key?('usage_limit') ? hash['usage_limit'] : SKIP
  confirmed = hash.key?('confirmed') ? hash['confirmed'] : SKIP
   = hash.key?('metadata') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:TransactionTokenMetadataAdditionalProperties), hash['metadata']
  ) : 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
  last_used_on = if hash.key?('last_used_on')
                   (DateTimeHelper.from_rfc3339(hash['last_used_on']) if hash['last_used_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.
  QrMerchantTransactionToken.new(data: data,
                                 id: id,
                                 store_id: store_id,
                                 email: email,
                                 active: active,
                                 mode: mode,
                                 type: type,
                                 usage_limit: usage_limit,
                                 confirmed: confirmed,
                                 metadata: ,
                                 created_on: created_on,
                                 updated_on: updated_on,
                                 last_used_on: last_used_on,
                                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['store_id'] = 'store_id'
  @_hash['email'] = 'email'
  @_hash['active'] = 'active'
  @_hash['mode'] = 'mode'
  @_hash['type'] = 'type'
  @_hash['usage_limit'] = 'usage_limit'
  @_hash['confirmed'] = 'confirmed'
  @_hash['metadata'] = 'metadata'
  @_hash['created_on'] = 'created_on'
  @_hash['updated_on'] = 'updated_on'
  @_hash['last_used_on'] = 'last_used_on'
  @_hash['payment_type'] = 'payment_type'
  @_hash['data'] = 'data'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
112
113
114
115
116
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 109

def self.nullables
  %w[
    email
    usage_limit
    confirmed
    last_used_on
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    store_id
    email
    active
    mode
    type
    usage_limit
    confirmed
    metadata
    created_on
    updated_on
    last_used_on
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 213

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.payment_type,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.data,
                              ->(val) { TokenResponseQrMerchantData.validate(val) },
                              is_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['payment_type'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['data'],
                            ->(val) { TokenResponseQrMerchantData.validate(val) },
                            is_model_hash: true)
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



246
247
248
249
250
251
252
253
254
255
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 246

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, store_id: #{@store_id.inspect}, email:"\
  " #{@email.inspect}, active: #{@active.inspect}, mode: #{@mode.inspect}, type:"\
  " #{@type.inspect}, usage_limit: #{@usage_limit.inspect}, confirmed: #{@confirmed.inspect},"\
  " metadata: #{@metadata.inspect}, created_on: #{@created_on.inspect}, updated_on:"\
  " #{@updated_on.inspect}, last_used_on: #{@last_used_on.inspect}, payment_type:"\
  " #{@payment_type.inspect}, data: #{@data.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_created_onObject



199
200
201
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 199

def to_custom_created_on
  DateTimeHelper.to_rfc3339(created_on)
end

#to_custom_last_used_onObject



207
208
209
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 207

def to_custom_last_used_on
  DateTimeHelper.to_rfc3339(last_used_on)
end

#to_custom_updated_onObject



203
204
205
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 203

def to_custom_updated_on
  DateTimeHelper.to_rfc3339(updated_on)
end

#to_sObject

Provides a human-readable string representation of the object.



236
237
238
239
240
241
242
243
# File 'lib/univapay_client_sdk/models/qr_merchant_transaction_token.rb', line 236

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, store_id: #{@store_id}, email: #{@email}, active: #{@active},"\
  " mode: #{@mode}, type: #{@type}, usage_limit: #{@usage_limit}, confirmed: #{@confirmed},"\
  " metadata: #{@metadata}, created_on: #{@created_on}, updated_on: #{@updated_on},"\
  " last_used_on: #{@last_used_on}, payment_type: #{@payment_type}, data: #{@data},"\
  " additional_properties: #{@additional_properties}>"
end