Class: UnivapayClientSdk::Cancel

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

Overview

Represents a cancellation request for a charge.

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, charge_id: SKIP, store_id: SKIP, status: SKIP, error: SKIP, metadata: SKIP, mode: SKIP, created_on: SKIP, updated_on: SKIP, additional_properties: nil) ⇒ Cancel

Returns a new instance of Cancel.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/univapay_client_sdk/models/cancel.rb', line 86

def initialize(id: SKIP, charge_id: SKIP, store_id: SKIP, status: SKIP,
               error: SKIP, metadata: SKIP, mode: 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
  @charge_id = charge_id unless charge_id == SKIP
  @store_id = store_id unless store_id == SKIP
  @status = status unless status == SKIP
  @error = error unless error == SKIP
  @metadata =  unless  == SKIP
  @mode = mode unless mode == 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

#charge_idUUID | String

ID of the charge this cancel is associated with.

Returns:

  • (UUID | String)


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

def charge_id
  @charge_id
end

#created_onDateTime

Timestamp when the cancel was created.

Returns:

  • (DateTime)


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

def created_on
  @created_on
end

#errorPaymentError

Payment error details, or null if successful.

Returns:



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

def error
  @error
end

#idUUID | String

Unique identifier for the cancel.

Returns:

  • (UUID | String)


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

def id
  @id
end

#metadataGenericMetadata

A free-form dictionary for custom metadata.

Returns:



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

def 
  @metadata
end

#modeChargeMode

Charge Mode schema.

Returns:



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

def mode
  @mode
end

#statusCancelStatus

Current status of the cancel operation.

Returns:



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

def status
  @status
end

#store_idUUID | String

ID of the store.

Returns:

  • (UUID | String)


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

def store_id
  @store_id
end

#updated_onDateTime

Timestamp when the cancel was last updated.

Returns:

  • (DateTime)


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

def updated_on
  @updated_on
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



105
106
107
108
109
110
111
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
# File 'lib/univapay_client_sdk/models/cancel.rb', line 105

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  charge_id = hash.key?('charge_id') ? hash['charge_id'] : SKIP
  store_id = hash.key?('store_id') ? hash['store_id'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  error = PaymentError.from_hash(hash['error']) if hash['error']
   = GenericMetadata.from_hash(hash['metadata']) if hash['metadata']
  mode = hash.key?('mode') ? hash['mode'] : 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.
  Cancel.new(id: id,
             charge_id: charge_id,
             store_id: store_id,
             status: status,
             error: error,
             metadata: ,
             mode: mode,
             created_on: created_on,
             updated_on: updated_on,
             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/univapay_client_sdk/models/cancel.rb', line 50

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['charge_id'] = 'charge_id'
  @_hash['store_id'] = 'store_id'
  @_hash['status'] = 'status'
  @_hash['error'] = 'error'
  @_hash['metadata'] = 'metadata'
  @_hash['mode'] = 'mode'
  @_hash['created_on'] = 'created_on'
  @_hash['updated_on'] = 'updated_on'
  @_hash
end

.nullablesObject

An array for nullable fields



80
81
82
83
84
# File 'lib/univapay_client_sdk/models/cancel.rb', line 80

def self.nullables
  %w[
    error
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    charge_id
    store_id
    status
    error
    metadata
    mode
    created_on
    updated_on
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Cancel | Hash)

    value against the validation is performed.



157
158
159
160
161
162
163
# File 'lib/univapay_client_sdk/models/cancel.rb', line 157

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.



175
176
177
178
179
180
181
# File 'lib/univapay_client_sdk/models/cancel.rb', line 175

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, charge_id: #{@charge_id.inspect}, store_id:"\
  " #{@store_id.inspect}, status: #{@status.inspect}, error: #{@error.inspect}, metadata:"\
  " #{@metadata.inspect}, mode: #{@mode.inspect}, created_on: #{@created_on.inspect},"\
  " updated_on: #{@updated_on.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_onObject



147
148
149
# File 'lib/univapay_client_sdk/models/cancel.rb', line 147

def to_custom_created_on
  DateTimeHelper.to_rfc3339(created_on)
end

#to_custom_updated_onObject



151
152
153
# File 'lib/univapay_client_sdk/models/cancel.rb', line 151

def to_custom_updated_on
  DateTimeHelper.to_rfc3339(updated_on)
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, charge_id: #{@charge_id}, store_id: #{@store_id}, status:"\
  " #{@status}, error: #{@error}, metadata: #{@metadata}, mode: #{@mode}, created_on:"\
  " #{@created_on}, updated_on: #{@updated_on}, additional_properties:"\
  " #{@additional_properties}>"
end