Class: Spree::WebhookDelivery
- Inherits:
-
Object
- Object
- Spree::WebhookDelivery
- Defined in:
- app/models/spree/webhook_delivery.rb
Constant Summary collapse
- ERROR_TYPES =
%w[timeout connection_error].freeze
Instance Method Summary collapse
-
#complete!(response_code: nil, execution_time:, error_type: nil, request_errors: nil, response_body: nil) ⇒ Object
Mark delivery as completed with HTTP response.
-
#failed? ⇒ Boolean
Check if the delivery failed.
-
#pending? ⇒ Boolean
Check if the delivery is pending.
-
#successful? ⇒ Boolean
Check if the delivery was successful.
Instance Method Details
#complete!(response_code: nil, execution_time:, error_type: nil, request_errors: nil, response_body: nil) ⇒ Object
Mark delivery as completed with HTTP response
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/spree/webhook_delivery.rb', line 48 def complete!(response_code: nil, execution_time:, error_type: nil, request_errors: nil, response_body: nil) update!( response_code: response_code, execution_time: execution_time, error_type: error_type, request_errors: request_errors, response_body: response_body, success: response_code.present? && response_code.to_s.start_with?('2'), delivered_at: Time.current ) end |
#failed? ⇒ Boolean
Check if the delivery failed
32 33 34 |
# File 'app/models/spree/webhook_delivery.rb', line 32 def failed? success == false end |
#pending? ⇒ Boolean
Check if the delivery is pending
39 40 41 |
# File 'app/models/spree/webhook_delivery.rb', line 39 def pending? delivered_at.nil? end |
#successful? ⇒ Boolean
Check if the delivery was successful
25 26 27 |
# File 'app/models/spree/webhook_delivery.rb', line 25 def successful? success == true end |