Class: Nahook::Resources::Endpoints
- Inherits:
-
Object
- Object
- Nahook::Resources::Endpoints
- Defined in:
- lib/nahook/resources/endpoints.rb
Overview
Resource for managing webhook endpoints via the Management API.
Instance Method Summary collapse
-
#create(workspace_id, url:, type: nil, description: nil, metadata: nil, config: nil, auth_username: nil, auth_password: nil) ⇒ Hash
Create a new endpoint.
-
#delete(workspace_id, id) ⇒ nil
Delete an endpoint.
-
#get(workspace_id, id) ⇒ Hash
Get a single endpoint by ID.
-
#initialize(http) ⇒ Endpoints
constructor
private
A new instance of Endpoints.
-
#list(workspace_id) ⇒ Hash
List all endpoints in a workspace.
-
#update(workspace_id, id, url: nil, description: nil, metadata: nil, is_active: nil) ⇒ Hash
Update an existing endpoint.
Constructor Details
#initialize(http) ⇒ Endpoints
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 Endpoints.
16 17 18 |
# File 'lib/nahook/resources/endpoints.rb', line 16 def initialize(http) @http = http end |
Instance Method Details
#create(workspace_id, url:, type: nil, description: nil, metadata: nil, config: nil, auth_username: nil, auth_password: nil) ⇒ Hash
Create a new endpoint.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nahook/resources/endpoints.rb', line 43 def create(workspace_id, url:, type: nil, description: nil, metadata: nil, config: nil, auth_username: nil, auth_password: nil) body = { "url" => url } body["type"] = type if type body["description"] = description if description body["metadata"] = if body["config"] = config if config body["authUsername"] = auth_username if auth_username body["authPassword"] = auth_password if auth_password @http.request( method: :post, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints", body: body ) end |
#delete(workspace_id, id) ⇒ nil
Delete an endpoint.
100 101 102 103 104 105 |
# File 'lib/nahook/resources/endpoints.rb', line 100 def delete(workspace_id, id) @http.request( method: :delete, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints/#{e(id)}" ) end |
#get(workspace_id, id) ⇒ Hash
Get a single endpoint by ID.
65 66 67 68 69 70 |
# File 'lib/nahook/resources/endpoints.rb', line 65 def get(workspace_id, id) @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints/#{e(id)}" ) end |
#list(workspace_id) ⇒ Hash
List all endpoints in a workspace.
24 25 26 27 28 29 30 |
# File 'lib/nahook/resources/endpoints.rb', line 24 def list(workspace_id) data = @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints" ) { "data" => data } end |
#update(workspace_id, id, url: nil, description: nil, metadata: nil, is_active: nil) ⇒ Hash
Update an existing endpoint.
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/nahook/resources/endpoints.rb', line 81 def update(workspace_id, id, url: nil, description: nil, metadata: nil, is_active: nil) body = {} body["url"] = url unless url.nil? body["description"] = description unless description.nil? body["metadata"] = unless .nil? body["isActive"] = is_active unless is_active.nil? @http.request( method: :patch, path: "/management/v1/workspaces/#{e(workspace_id)}/endpoints/#{e(id)}", body: body ) end |