Class: Zernio::WebhookLog

Inherits:
ApiModelBase show all
Defined in:
lib/zernio-sdk/models/webhook_log.rb

Overview

A single webhook delivery attempt recorded by Zernio (30-day retention).

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ WebhookLog

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



141
142
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/zernio-sdk/models/webhook_log.rb', line 141

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::WebhookLog` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::WebhookLog`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'user_id')
    self.user_id = attributes[:'user_id']
  end

  if attributes.key?(:'webhook_id')
    self.webhook_id = attributes[:'webhook_id']
  end

  if attributes.key?(:'webhook_name')
    self.webhook_name = attributes[:'webhook_name']
  end

  if attributes.key?(:'event_id')
    self.event_id = attributes[:'event_id']
  end

  if attributes.key?(:'event')
    self.event = attributes[:'event']
  end

  if attributes.key?(:'url')
    self.url = attributes[:'url']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  end

  if attributes.key?(:'status_code')
    self.status_code = attributes[:'status_code']
  end

  if attributes.key?(:'request_payload')
    if (value = attributes[:'request_payload']).is_a?(Hash)
      self.request_payload = value
    end
  end

  if attributes.key?(:'response_body')
    self.response_body = attributes[:'response_body']
  end

  if attributes.key?(:'error_message')
    self.error_message = attributes[:'error_message']
  end

  if attributes.key?(:'attempt_number')
    self.attempt_number = attributes[:'attempt_number']
  end

  if attributes.key?(:'response_time')
    self.response_time = attributes[:'response_time']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end
end

Instance Attribute Details

#attempt_numberObject

Delivery attempt number (increments on retries)



53
54
55
# File 'lib/zernio-sdk/models/webhook_log.rb', line 53

def attempt_number
  @attempt_number
end

#created_atObject

Timestamp the delivery was attempted



59
60
61
# File 'lib/zernio-sdk/models/webhook_log.rb', line 59

def created_at
  @created_at
end

#error_messageObject

Error message when delivery failed



50
51
52
# File 'lib/zernio-sdk/models/webhook_log.rb', line 50

def error_message
  @error_message
end

#eventObject

Event type that triggered the delivery (e.g. post.published)



32
33
34
# File 'lib/zernio-sdk/models/webhook_log.rb', line 32

def event
  @event
end

#event_idObject

Stable webhook event ID (correlates to the delivered payload)



29
30
31
# File 'lib/zernio-sdk/models/webhook_log.rb', line 29

def event_id
  @event_id
end

#request_payloadObject

The JSON payload sent to the destination endpoint



44
45
46
# File 'lib/zernio-sdk/models/webhook_log.rb', line 44

def request_payload
  @request_payload
end

#response_bodyObject

Response body returned by the destination endpoint



47
48
49
# File 'lib/zernio-sdk/models/webhook_log.rb', line 47

def response_body
  @response_body
end

#response_timeObject

Time taken by the destination endpoint to respond, in milliseconds



56
57
58
# File 'lib/zernio-sdk/models/webhook_log.rb', line 56

def response_time
  @response_time
end

#statusObject

Delivery outcome



38
39
40
# File 'lib/zernio-sdk/models/webhook_log.rb', line 38

def status
  @status
end

#status_codeObject

HTTP status code returned by the destination endpoint



41
42
43
# File 'lib/zernio-sdk/models/webhook_log.rb', line 41

def status_code
  @status_code
end

#urlObject

Destination URL the webhook was delivered to



35
36
37
# File 'lib/zernio-sdk/models/webhook_log.rb', line 35

def url
  @url
end

#user_idObject

ID of the account owner the webhook belongs to



20
21
22
# File 'lib/zernio-sdk/models/webhook_log.rb', line 20

def user_id
  @user_id
end

#webhook_idObject

ID of the webhook configuration that produced this delivery



23
24
25
# File 'lib/zernio-sdk/models/webhook_log.rb', line 23

def webhook_id
  @webhook_id
end

#webhook_nameObject

Name of the webhook configuration at delivery time



26
27
28
# File 'lib/zernio-sdk/models/webhook_log.rb', line 26

def webhook_name
  @webhook_name
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



104
105
106
# File 'lib/zernio-sdk/models/webhook_log.rb', line 104

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



109
110
111
# File 'lib/zernio-sdk/models/webhook_log.rb', line 109

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/zernio-sdk/models/webhook_log.rb', line 84

def self.attribute_map
  {
    :'user_id' => :'userId',
    :'webhook_id' => :'webhookId',
    :'webhook_name' => :'webhookName',
    :'event_id' => :'eventId',
    :'event' => :'event',
    :'url' => :'url',
    :'status' => :'status',
    :'status_code' => :'statusCode',
    :'request_payload' => :'requestPayload',
    :'response_body' => :'responseBody',
    :'error_message' => :'errorMessage',
    :'attempt_number' => :'attemptNumber',
    :'response_time' => :'responseTime',
    :'created_at' => :'createdAt'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/zernio-sdk/models/webhook_log.rb', line 277

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



134
135
136
137
# File 'lib/zernio-sdk/models/webhook_log.rb', line 134

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/zernio-sdk/models/webhook_log.rb', line 114

def self.openapi_types
  {
    :'user_id' => :'String',
    :'webhook_id' => :'String',
    :'webhook_name' => :'String',
    :'event_id' => :'String',
    :'event' => :'String',
    :'url' => :'String',
    :'status' => :'String',
    :'status_code' => :'Integer',
    :'request_payload' => :'Hash<String, Object>',
    :'response_body' => :'String',
    :'error_message' => :'String',
    :'attempt_number' => :'Integer',
    :'response_time' => :'Integer',
    :'created_at' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/zernio-sdk/models/webhook_log.rb', line 243

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      user_id == o.user_id &&
      webhook_id == o.webhook_id &&
      webhook_name == o.webhook_name &&
      event_id == o.event_id &&
      event == o.event &&
      url == o.url &&
      status == o.status &&
      status_code == o.status_code &&
      request_payload == o.request_payload &&
      response_body == o.response_body &&
      error_message == o.error_message &&
      attempt_number == o.attempt_number &&
      response_time == o.response_time &&
      created_at == o.created_at
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


264
265
266
# File 'lib/zernio-sdk/models/webhook_log.rb', line 264

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



270
271
272
# File 'lib/zernio-sdk/models/webhook_log.rb', line 270

def hash
  [user_id, webhook_id, webhook_name, event_id, event, url, status, status_code, request_payload, response_body, error_message, attempt_number, response_time, created_at].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



216
217
218
219
220
# File 'lib/zernio-sdk/models/webhook_log.rb', line 216

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/zernio-sdk/models/webhook_log.rb', line 299

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



224
225
226
227
228
229
# File 'lib/zernio-sdk/models/webhook_log.rb', line 224

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  status_validator = EnumAttributeValidator.new('String', ["success", "failed"])
  return false unless status_validator.valid?(@status)
  true
end