Class: Sendly::WebhookDelivery
- Inherits:
-
Object
- Object
- Sendly::WebhookDelivery
- 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
-
#attempt_number ⇒ Object
readonly
Returns the value of attribute attempt_number.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#delivered_at ⇒ Object
readonly
Returns the value of attribute delivered_at.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#event_id ⇒ Object
readonly
Returns the value of attribute event_id.
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#max_attempts ⇒ Object
readonly
Returns the value of attribute max_attempts.
-
#next_retry_at ⇒ Object
readonly
Returns the value of attribute next_retry_at.
-
#response_status_code ⇒ Object
readonly
Returns the value of attribute response_status_code.
-
#response_time_ms ⇒ Object
readonly
Returns the value of attribute response_time_ms.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#webhook_id ⇒ Object
readonly
Returns the value of attribute webhook_id.
Instance Method Summary collapse
- #delivered? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(data) ⇒ WebhookDelivery
constructor
A new instance of WebhookDelivery.
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_number ⇒ Object (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_at ⇒ Object (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_at ⇒ Object (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_code ⇒ Object (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_message ⇒ Object (readonly)
Returns the value of attribute error_message.
314 315 316 |
# File 'lib/sendly/types.rb', line 314 def @error_message end |
#event_id ⇒ Object (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_type ⇒ Object (readonly)
Returns the value of attribute event_type.
314 315 316 |
# File 'lib/sendly/types.rb', line 314 def event_type @event_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
314 315 316 |
# File 'lib/sendly/types.rb', line 314 def id @id end |
#max_attempts ⇒ Object (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_at ⇒ Object (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_code ⇒ Object (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_ms ⇒ Object (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 |
#status ⇒ Object (readonly)
Returns the value of attribute status.
314 315 316 |
# File 'lib/sendly/types.rb', line 314 def status @status end |
#webhook_id ⇒ Object (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
338 339 340 |
# File 'lib/sendly/types.rb', line 338 def delivered? status == "delivered" end |
#failed? ⇒ Boolean
342 343 344 |
# File 'lib/sendly/types.rb', line 342 def failed? status == "failed" end |