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



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

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



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

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



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

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

#list(bucket_id:) ⇒ Enumerator<Hash>

List all webhooks for a project

Parameters:

  • bucket_id (Integer)

    bucket id ID

Returns:

  • (Enumerator<Hash>)

    paginated results



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

def list(bucket_id:)
  wrap_paginated(service: "webhooks", operation: "list", is_mutation: false, project_id: bucket_id) do
    paginate("/buckets/#{bucket_id}/webhooks.json")
  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



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

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