Class: Nahook::Resources::Deliveries
- Inherits:
-
Object
- Object
- Nahook::Resources::Deliveries
- Defined in:
- lib/nahook/resources/deliveries.rb
Overview
Read access to a workspace’s webhook deliveries via the Management API.
All methods are paginated or single-resource reads – this resource has no create/update/delete operations. Deliveries are produced by the ingestion path and consumed by the worker; the Management API exposes only their observable state.
Instance Method Summary collapse
-
#get(workspace_id, delivery_id, include_payload: false) ⇒ Hash
Get a single delivery’s metadata, optionally including the payload envelope.
-
#get_attempts(workspace_id, delivery_id) ⇒ Array<Hash>
List delivery attempts for a single delivery, in chronological order (oldest first).
-
#initialize(http) ⇒ Deliveries
constructor
private
A new instance of Deliveries.
-
#list(workspace_id, endpoint_id, limit: nil, cursor: nil, status: nil) ⇒ PaginatedResult
List deliveries for an endpoint, newest-first, with opaque cursor pagination.
Constructor Details
#initialize(http) ⇒ Deliveries
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Deliveries.
42 43 44 |
# File 'lib/nahook/resources/deliveries.rb', line 42 def initialize(http) @http = http end |
Instance Method Details
#get(workspace_id, delivery_id, include_payload: false) ⇒ Hash
Get a single delivery’s metadata, optionally including the payload envelope.
When include_payload is true, the response includes a “payload” envelope whose “status” is one of: “available”, “forbidden”, “processing”, “not_found”, “error”. The endpoint stays 200 for all 5 – the envelope status carries access-level reality. This method does NOT raise on “forbidden”/“processing”/“not_found”/“error”.
81 82 83 84 85 86 87 88 |
# File 'lib/nahook/resources/deliveries.rb', line 81 def get(workspace_id, delivery_id, include_payload: false) query = include_payload ? { "include" => "payload" } : nil @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/deliveries/#{e(delivery_id)}", query: query ) end |
#get_attempts(workspace_id, delivery_id) ⇒ Array<Hash>
List delivery attempts for a single delivery, in chronological order (oldest first).
The attempt “status” field is an opaque string (“failed”, “success”, etc.) – treat it as a string, not an enum.
99 100 101 102 103 104 |
# File 'lib/nahook/resources/deliveries.rb', line 99 def get_attempts(workspace_id, delivery_id) @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/deliveries/#{e(delivery_id)}/attempts" ) end |
#list(workspace_id, endpoint_id, limit: nil, cursor: nil, status: nil) ⇒ PaginatedResult
List deliveries for an endpoint, newest-first, with opaque cursor pagination.
58 59 60 61 62 63 64 65 |
# File 'lib/nahook/resources/deliveries.rb', line 58 def list(workspace_id, endpoint_id, limit: nil, cursor: nil, status: nil) raw = @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints/#{e(endpoint_id)}/deliveries", query: { "limit" => limit, "cursor" => cursor, "status" => status } ) PaginatedResult.new(raw["deliveries"] || [], raw["nextCursor"]) end |