Class: Nahook::Resources::Subscriptions
- Inherits:
-
Object
- Object
- Nahook::Resources::Subscriptions
- Defined in:
- lib/nahook/resources/subscriptions.rb
Overview
Resource for managing endpoint subscriptions via the Management API.
Subscriptions link event types to endpoints, controlling which events are delivered to which endpoint.
Instance Method Summary collapse
-
#create(workspace_id, endpoint_id, event_type_ids:) ⇒ Hash
Subscribe an endpoint to one or more event types.
-
#delete(workspace_id, endpoint_id, event_type_id) ⇒ nil
Delete a subscription.
-
#initialize(http) ⇒ Subscriptions
constructor
private
A new instance of Subscriptions.
-
#list(workspace_id, endpoint_id) ⇒ Hash
List subscriptions for an endpoint.
Constructor Details
#initialize(http) ⇒ Subscriptions
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 Subscriptions.
19 20 21 |
# File 'lib/nahook/resources/subscriptions.rb', line 19 def initialize(http) @http = http end |
Instance Method Details
#create(workspace_id, endpoint_id, event_type_ids:) ⇒ Hash
Subscribe an endpoint to one or more event types.
42 43 44 45 46 47 48 |
# File 'lib/nahook/resources/subscriptions.rb', line 42 def create(workspace_id, endpoint_id, event_type_ids:) @http.request( method: :post, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints/#{e(endpoint_id)}/subscriptions", body: { "eventTypeIds" => Array(event_type_ids) } ) end |
#delete(workspace_id, endpoint_id, event_type_id) ⇒ nil
Delete a subscription.
56 57 58 59 60 61 |
# File 'lib/nahook/resources/subscriptions.rb', line 56 def delete(workspace_id, endpoint_id, event_type_id) @http.request( method: :delete, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints/#{e(endpoint_id)}/subscriptions/#{e(event_type_id)}" ) end |
#list(workspace_id, endpoint_id) ⇒ Hash
List subscriptions for an endpoint.
28 29 30 31 32 33 34 |
# File 'lib/nahook/resources/subscriptions.rb', line 28 def list(workspace_id, endpoint_id) data = @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints/#{e(endpoint_id)}/subscriptions" ) { "data" => data } end |