Class: Sendly::WebhookDelivery

Inherits:
Object
  • Object
show all
Defined in:
lib/sendly/types.rb

Overview

Represents a webhook delivery attempt

Constant Summary collapse

STATUSES =

Delivery status constants

%w[pending delivered failed cancelled].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ WebhookDelivery

Returns a new instance of WebhookDelivery.



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/sendly/types.rb', line 321

def initialize(data)
  @id = data["id"]
  @webhook_id = data["webhook_id"] || data["webhookId"]
  @event_id = data["event_id"] || data["eventId"]
  @event_type = data["event_type"] || data["eventType"]
  @attempt_number = data["attempt_number"] || data["attemptNumber"] || 1
  @max_attempts = data["max_attempts"] || data["maxAttempts"] || 6
  @status = data["status"]
  @response_status_code = data["response_status_code"] || data["responseStatusCode"]
  @response_time_ms = data["response_time_ms"] || data["responseTimeMs"]
  @error_message = data["error_message"] || data["errorMessage"]
  @error_code = data["error_code"] || data["errorCode"]
  @next_retry_at = parse_time(data["next_retry_at"] || data["nextRetryAt"])
  @created_at = parse_time(data["created_at"] || data["createdAt"])
  @delivered_at = parse_time(data["delivered_at"] || data["deliveredAt"])
end

Instance Attribute Details

#attempt_numberObject (readonly)

Returns the value of attribute attempt_number.



314
315
316
# File 'lib/sendly/types.rb', line 314

def attempt_number
  @attempt_number
end

#created_atObject (readonly)

Returns the value of attribute created_at.



314
315
316
# File 'lib/sendly/types.rb', line 314

def created_at
  @created_at
end

#delivered_atObject (readonly)

Returns the value of attribute delivered_at.



314
315
316
# File 'lib/sendly/types.rb', line 314

def delivered_at
  @delivered_at
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



314
315
316
# File 'lib/sendly/types.rb', line 314

def error_code
  @error_code
end

#error_messageObject (readonly)

Returns the value of attribute error_message.



314
315
316
# File 'lib/sendly/types.rb', line 314

def error_message
  @error_message
end

#event_idObject (readonly)

Returns the value of attribute event_id.



314
315
316
# File 'lib/sendly/types.rb', line 314

def event_id
  @event_id
end

#event_typeObject (readonly)

Returns the value of attribute event_type.



314
315
316
# File 'lib/sendly/types.rb', line 314

def event_type
  @event_type
end

#idObject (readonly)

Returns the value of attribute id.



314
315
316
# File 'lib/sendly/types.rb', line 314

def id
  @id
end

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts.



314
315
316
# File 'lib/sendly/types.rb', line 314

def max_attempts
  @max_attempts
end

#next_retry_atObject (readonly)

Returns the value of attribute next_retry_at.



314
315
316
# File 'lib/sendly/types.rb', line 314

def next_retry_at
  @next_retry_at
end

#response_status_codeObject (readonly)

Returns the value of attribute response_status_code.



314
315
316
# File 'lib/sendly/types.rb', line 314

def response_status_code
  @response_status_code
end

#response_time_msObject (readonly)

Returns the value of attribute response_time_ms.



314
315
316
# File 'lib/sendly/types.rb', line 314

def response_time_ms
  @response_time_ms
end

#statusObject (readonly)

Returns the value of attribute status.



314
315
316
# File 'lib/sendly/types.rb', line 314

def status
  @status
end

#webhook_idObject (readonly)

Returns the value of attribute webhook_id.



314
315
316
# File 'lib/sendly/types.rb', line 314

def webhook_id
  @webhook_id
end

Instance Method Details

#delivered?Boolean

Returns:

  • (Boolean)


338
339
340
# File 'lib/sendly/types.rb', line 338

def delivered?
  status == "delivered"
end

#failed?Boolean

Returns:

  • (Boolean)


342
343
344
# File 'lib/sendly/types.rb', line 342

def failed?
  status == "failed"
end