Class: UnivapayClientSdk::WebhookEvent

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

Overview

Represents a single delivery attempt of a webhook event, including the payload sent and the delivery outcome.

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, webhook_id: SKIP, event: SKIP, data: SKIP, successful: SKIP, fired_on: SKIP, error_message: SKIP, created_on: SKIP, additional_properties: nil) ⇒ WebhookEvent

Returns a new instance of WebhookEvent.



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

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

  @id = id unless id == SKIP
  @webhook_id = webhook_id unless webhook_id == SKIP
  @event = event unless event == SKIP
  @data = data unless data == SKIP
  @successful = successful unless successful == SKIP
  @fired_on = fired_on unless fired_on == SKIP
  @error_message = error_message unless error_message == SKIP
  @created_on = created_on unless created_on == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_onDateTime

Timestamp when the event was created.

Returns:

  • (DateTime)


46
47
48
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 46

def created_on
  @created_on
end

#dataObject

Domain object payload for webhook deliveries. The actual structure depends on the event type — see each webhook callback schema for the specific payload shape.

Returns:

  • (Object)


30
31
32
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 30

def data
  @data
end

#error_messageString

Error message if delivery failed.

Returns:

  • (String)


42
43
44
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 42

def error_message
  @error_message
end

#eventWebhookTrigger

Event type that triggers a webhook notification.

Returns:



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

def event
  @event
end

#fired_onDateTime

Timestamp when the webhook was dispatched.

Returns:

  • (DateTime)


38
39
40
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 38

def fired_on
  @fired_on
end

#idUUID | String

Unique identifier for the webhook event.

Returns:

  • (UUID | String)


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

def id
  @id
end

#successfulTrueClass | FalseClass

Whether the webhook delivery was acknowledged (HTTP 2xx).

Returns:

  • (TrueClass | FalseClass)


34
35
36
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 34

def successful
  @successful
end

#webhook_idUUID | String

ID of the parent webhook.

Returns:

  • (UUID | String)


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

def webhook_id
  @webhook_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



101
102
103
104
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
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 101

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  webhook_id = hash.key?('webhook_id') ? hash['webhook_id'] : SKIP
  event = hash.key?('event') ? hash['event'] : SKIP
  data = hash.key?('data') ? hash['data'] : SKIP
  successful = hash.key?('successful') ? hash['successful'] : SKIP
  fired_on = if hash.key?('fired_on')
               (DateTimeHelper.from_rfc3339(hash['fired_on']) if hash['fired_on'])
             else
               SKIP
             end
  error_message = hash.key?('error_message') ? hash['error_message'] : SKIP
  created_on = if hash.key?('created_on')
                 (DateTimeHelper.from_rfc3339(hash['created_on']) if hash['created_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.
  WebhookEvent.new(id: id,
                   webhook_id: webhook_id,
                   event: event,
                   data: data,
                   successful: successful,
                   fired_on: fired_on,
                   error_message: error_message,
                   created_on: created_on,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



77
78
79
80
81
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 77

def self.nullables
  %w[
    error_message
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    webhook_id
    event
    data
    successful
    fired_on
    error_message
    created_on
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

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

#to_custom_created_onObject



145
146
147
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 145

def to_custom_created_on
  DateTimeHelper.to_rfc3339(created_on)
end

#to_custom_fired_onObject



141
142
143
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 141

def to_custom_fired_on
  DateTimeHelper.to_rfc3339(fired_on)
end

#to_sObject

Provides a human-readable string representation of the object.



150
151
152
153
154
155
# File 'lib/univapay_client_sdk/models/webhook_event.rb', line 150

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