Class: UnivapayClientSdk::TokenWebhookEvent

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

Overview

Webhook envelope for transaction token lifecycle events. Fired as token_created when a token is created, token_updated on metadata changes, token_three_d_s_updated on 3-D Secure data changes, token_cvv_auth_updated on CVV authorization changes, token_cvv_auth_check_updated on CVV auth check changes, token_replaced when a token is replaced by a new one (e.g., after a card update), and recurring_token_deleted when a recurring token is deleted. The data field contains the full TransactionToken object at the time of the event.

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:, event:, created_on:, data: SKIP, additional_properties: nil) ⇒ TokenWebhookEvent

Returns a new instance of TokenWebhookEvent.



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 63

def initialize(id:, event:, created_on:, data: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @event = event
  @data = data unless data == SKIP
  @created_on = created_on
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_onDateTime

Timestamp when the event was fired.

Returns:

  • (DateTime)


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

def created_on
  @created_on
end

#dataObject

Stored transaction token resource. payment_type discriminates which variant applies — and therefore the concrete shape of data — per the mapping above.

Returns:

  • (Object)


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

def data
  @data
end

#eventTokenEvent

Event type discriminator — token_created, token_updated, token_three_d_s_updated, token_cvv_auth_updated, token_cvv_auth_check_updated, token_replaced, or recurring_token_deleted.

Returns:



29
30
31
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 29

def event
  @event
end

#idUUID | String

Unique ID of this webhook delivery.

Returns:

  • (UUID | String)


22
23
24
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 22

def id
  @id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 76

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  event = hash.key?('event') ? hash['event'] : nil
  created_on = if hash.key?('created_on')
                 (DateTimeHelper.from_rfc3339(hash['created_on']) if hash['created_on'])
               end
  data = hash.key?('data') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:TransactionToken2), hash['data']
  ) : 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.
  TokenWebhookEvent.new(id: id,
                        event: event,
                        created_on: created_on,
                        data: data,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['event'] = 'event'
  @_hash['data'] = 'data'
  @_hash['created_on'] = 'created_on'
  @_hash
end

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



52
53
54
55
56
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 52

def self.optionals
  %w[
    data
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 110

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.event,
                              ->(val) { TokenEvent.validate(val) }) and
        APIHelper.valid_type?(value.created_on,
                              ->(val) { val.instance_of? DateTime })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['event'],
                            ->(val) { TokenEvent.validate(val) }) and
      APIHelper.valid_type?(value['created_on'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



142
143
144
145
146
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 142

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, event: #{@event.inspect}, data: #{@data.inspect},"\
  " created_on: #{@created_on.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_onObject



104
105
106
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 104

def to_custom_created_on
  DateTimeHelper.to_rfc3339(created_on)
end

#to_sObject

Provides a human-readable string representation of the object.



135
136
137
138
139
# File 'lib/univapay_client_sdk/models/token_webhook_event.rb', line 135

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, event: #{@event}, data: #{@data}, created_on: #{@created_on},"\
  " additional_properties: #{@additional_properties}>"
end