Class: Nahook::Resources::EventTypes
- Inherits:
-
Object
- Object
- Nahook::Resources::EventTypes
- Defined in:
- lib/nahook/resources/event_types.rb
Overview
Resource for managing event types via the Management API.
Instance Method Summary collapse
-
#create(workspace_id, name:, description: nil) ⇒ Hash
Create a new event type.
-
#delete(workspace_id, id) ⇒ nil
Delete an event type.
-
#get(workspace_id, id) ⇒ Hash
Get a single event type by ID.
-
#initialize(http) ⇒ EventTypes
constructor
private
A new instance of EventTypes.
-
#list(workspace_id) ⇒ Hash
List all event types in a workspace.
-
#update(workspace_id, id, description: nil) ⇒ Hash
Update an existing event type.
Constructor Details
#initialize(http) ⇒ EventTypes
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 EventTypes.
16 17 18 |
# File 'lib/nahook/resources/event_types.rb', line 16 def initialize(http) @http = http end |
Instance Method Details
#create(workspace_id, name:, description: nil) ⇒ Hash
Create a new event type.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nahook/resources/event_types.rb', line 38 def create(workspace_id, name:, description: nil) body = { "name" => name } body["description"] = description if description @http.request( method: :post, path: "/management/v1/workspaces/#{e(workspace_id)}/event-types", body: body ) end |
#delete(workspace_id, id) ⇒ nil
Delete an event type.
83 84 85 86 87 88 |
# File 'lib/nahook/resources/event_types.rb', line 83 def delete(workspace_id, id) @http.request( method: :delete, path: "/management/v1/workspaces/#{e(workspace_id)}/event-types/#{e(id)}" ) end |
#get(workspace_id, id) ⇒ Hash
Get a single event type by ID.
54 55 56 57 58 59 |
# File 'lib/nahook/resources/event_types.rb', line 54 def get(workspace_id, id) @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/event-types/#{e(id)}" ) end |
#list(workspace_id) ⇒ Hash
List all event types in a workspace.
24 25 26 27 28 29 30 |
# File 'lib/nahook/resources/event_types.rb', line 24 def list(workspace_id) data = @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/event-types" ) { "data" => data } end |
#update(workspace_id, id, description: nil) ⇒ Hash
Update an existing event type.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/nahook/resources/event_types.rb', line 67 def update(workspace_id, id, description: nil) body = {} body["description"] = description unless description.nil? @http.request( method: :patch, path: "/management/v1/workspaces/#{e(workspace_id)}/event-types/#{e(id)}", body: body ) end |