Class: Basecamp::Services::WebhooksService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/basecamp/generated/services/webhooks_service.rb

Overview

Service for Webhooks operations

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Basecamp::Services::BaseService

Instance Method Details

#create(bucket_id:, payload_url:, types:, active: nil) ⇒ Hash

Create a new webhook for a project

Parameters:

  • bucket_id (Integer)

    bucket id ID

  • payload_url (String)

    payload url

  • types (Array)

    types

  • active (Boolean, nil) (defaults to: nil)

    active

Returns:

  • (Hash)

    response data



26
27
28
29
30
# File 'lib/basecamp/generated/services/webhooks_service.rb', line 26

def create(bucket_id:, payload_url:, types:, active: nil)
  with_operation(service: "webhooks", operation: "create", is_mutation: true, project_id: bucket_id) do
    http_post("/buckets/#{bucket_id}/webhooks.json", body: compact_params(payload_url: payload_url, types: types, active: active)).json
  end
end

#delete(webhook_id:) ⇒ void

This method returns an undefined value.

Delete a webhook

Parameters:

  • webhook_id (Integer)

    webhook id ID



56
57
58
59
60
61
# File 'lib/basecamp/generated/services/webhooks_service.rb', line 56

def delete(webhook_id:)
  with_operation(service: "webhooks", operation: "delete", is_mutation: true, resource_id: webhook_id) do
    http_delete("/webhooks/#{webhook_id}")
    nil
  end
end

#get(webhook_id:) ⇒ Hash

Get a single webhook by id

Parameters:

  • webhook_id (Integer)

    webhook id ID

Returns:

  • (Hash)

    response data



35
36
37
38
39
# File 'lib/basecamp/generated/services/webhooks_service.rb', line 35

def get(webhook_id:)
  with_operation(service: "webhooks", operation: "get", is_mutation: false, resource_id: webhook_id) do
    http_get("/webhooks/#{webhook_id}", operation: "GetWebhook").json
  end
end

#list(bucket_id:, max_items: nil) ⇒ ListEnumerator<Hash>

List all webhooks for a project

Parameters:

  • bucket_id (Integer)

    bucket id ID

  • max_items (Integer, nil) (defaults to: nil)

    cap on items yielded across pages; nil or non-positive means no cap

Returns:

  • (ListEnumerator<Hash>)

    lazily paginated results (#meta carries pagination metadata)



14
15
16
17
18
# File 'lib/basecamp/generated/services/webhooks_service.rb', line 14

def list(bucket_id:, max_items: nil)
  wrap_paginated(service: "webhooks", operation: "list", is_mutation: false, project_id: bucket_id) do
    paginate("/buckets/#{bucket_id}/webhooks.json", operation: "ListWebhooks", max_items: max_items)
  end
end

#update(webhook_id:, payload_url: nil, types: nil, active: nil) ⇒ Hash

Update an existing webhook

Parameters:

  • webhook_id (Integer)

    webhook id ID

  • payload_url (String, nil) (defaults to: nil)

    payload url

  • types (Array, nil) (defaults to: nil)

    types

  • active (Boolean, nil) (defaults to: nil)

    active

Returns:

  • (Hash)

    response data



47
48
49
50
51
# File 'lib/basecamp/generated/services/webhooks_service.rb', line 47

def update(webhook_id:, payload_url: nil, types: nil, active: nil)
  with_operation(service: "webhooks", operation: "update", is_mutation: true, resource_id: webhook_id) do
    http_put("/webhooks/#{webhook_id}", body: compact_params(payload_url: payload_url, types: types, active: active)).json
  end
end