Class: Philiprehberger::WebhookBuilder::Delivery

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/webhook_builder/delivery.rb

Overview

Represents the result of a webhook delivery attempt.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success:, response_code:, attempts:, duration:, response_body: nil, error: nil) ⇒ Delivery

Returns a new instance of Delivery.

Parameters:

  • success (Boolean)
  • response_code (Integer, nil)
  • attempts (Integer)
  • duration (Float)
  • response_body (String, nil) (defaults to: nil)
  • error (String, nil) (defaults to: nil)


31
32
33
34
35
36
37
38
# File 'lib/philiprehberger/webhook_builder/delivery.rb', line 31

def initialize(success:, response_code:, attempts:, duration:, response_body: nil, error: nil)
  @success = success
  @response_code = response_code
  @attempts = attempts
  @duration = duration
  @response_body = response_body
  @error = error
end

Instance Attribute Details

#attemptsInteger (readonly)

Returns the number of delivery attempts made.

Returns:

  • (Integer)

    the number of delivery attempts made



14
15
16
# File 'lib/philiprehberger/webhook_builder/delivery.rb', line 14

def attempts
  @attempts
end

#durationFloat (readonly)

Returns the total duration in seconds across all attempts.

Returns:

  • (Float)

    the total duration in seconds across all attempts



17
18
19
# File 'lib/philiprehberger/webhook_builder/delivery.rb', line 17

def duration
  @duration
end

#errorString? (readonly)

Returns the error message if delivery failed.

Returns:

  • (String, nil)

    the error message if delivery failed



23
24
25
# File 'lib/philiprehberger/webhook_builder/delivery.rb', line 23

def error
  @error
end

#response_bodyString? (readonly)

Returns the response body.

Returns:

  • (String, nil)

    the response body



20
21
22
# File 'lib/philiprehberger/webhook_builder/delivery.rb', line 20

def response_body
  @response_body
end

#response_codeInteger? (readonly)

Returns the HTTP response code.

Returns:

  • (Integer, nil)

    the HTTP response code



11
12
13
# File 'lib/philiprehberger/webhook_builder/delivery.rb', line 11

def response_code
  @response_code
end

#successBoolean (readonly)

Returns whether the delivery succeeded (2xx response).

Returns:

  • (Boolean)

    whether the delivery succeeded (2xx response)



8
9
10
# File 'lib/philiprehberger/webhook_builder/delivery.rb', line 8

def success
  @success
end

Instance Method Details

#success?Boolean

Whether the delivery was successful.

Returns:

  • (Boolean)


43
44
45
# File 'lib/philiprehberger/webhook_builder/delivery.rb', line 43

def success?
  @success
end