Class: Spree::Api::V3::Admin::WebhookEndpointsController
- Inherits:
-
ResourceController
- Object
- ActionController::API
- BaseController
- ResourceController
- ResourceController
- Spree::Api::V3::Admin::WebhookEndpointsController
- Defined in:
- app/controllers/spree/api/v3/admin/webhook_endpoints_controller.rb
Overview
Admin API for outbound webhook endpoints — CRUD plus the three endpoint-scoped actions the legacy admin had (send_test, enable, disable).
Constant Summary
Constants included from ScopedAuthorization
ScopedAuthorization::READ_ACTIONS
Constants inherited from BaseController
BaseController::RATE_LIMIT_RESPONSE
Constants included from Idempotent
Idempotent::IDEMPOTENCY_HEADER, Idempotent::IDEMPOTENCY_TTL, Idempotent::MAX_KEY_LENGTH, Idempotent::MUTATING_METHODS
Constants included from ErrorHandler
Constants included from JwtAuthentication
JwtAuthentication::JWT_AUDIENCE_ADMIN, JwtAuthentication::JWT_AUDIENCE_STORE, JwtAuthentication::JWT_ISSUER, JwtAuthentication::USER_TYPE_ADMIN, JwtAuthentication::USER_TYPE_CUSTOMER
Instance Method Summary collapse
-
#disable ⇒ Hash
PATCH /api/v3/admin/webhook_endpoints/:id/disable.
-
#enable ⇒ Hash
PATCH /api/v3/admin/webhook_endpoints/:id/enable.
-
#send_test ⇒ Hash
POST /api/v3/admin/webhook_endpoints/:id/send_test.
Methods inherited from ResourceController
#create, #destroy, #index, #show, #update
Methods included from Spree::Api::V3::ApiKeyAuthentication
#authenticate_api_key!, #authenticate_secret_key!
Methods included from JwtAuthentication
#authenticate_user, #require_authentication!
Instance Method Details
#disable ⇒ Hash
PATCH /api/v3/admin/webhook_endpoints/:id/disable
Manual disable — separate from the auto-disable threshold so the caller can pause an endpoint without waiting for failures.
46 47 48 49 50 51 52 |
# File 'app/controllers/spree/api/v3/admin/webhook_endpoints_controller.rb', line 46 def disable @resource = find_resource (:update, @resource) @resource.disable!(reason: params[:reason].presence || 'Manually disabled', notify: false) render json: serialize_resource(@resource) end |
#enable ⇒ Hash
PATCH /api/v3/admin/webhook_endpoints/:id/enable
Re-enables an endpoint that was auto-disabled after repeated failures.
30 31 32 33 34 35 36 |
# File 'app/controllers/spree/api/v3/admin/webhook_endpoints_controller.rb', line 30 def enable @resource = find_resource (:update, @resource) @resource.enable! render json: serialize_resource(@resource) end |
#send_test ⇒ Hash
POST /api/v3/admin/webhook_endpoints/:id/send_test
Fires a synthetic ‘webhook.test` delivery so admins can verify the endpoint is reachable + their signature-verification code works.
17 18 19 20 21 22 23 |
# File 'app/controllers/spree/api/v3/admin/webhook_endpoints_controller.rb', line 17 def send_test @resource = find_resource (:update, @resource) delivery = @resource.send_test! render json: Spree.api.admin_webhook_delivery_serializer.new(delivery).to_h, status: :created end |