Class: Nylas::Webhooks

Inherits:
Resource show all
Includes:
ApiOperations::Delete, ApiOperations::Get, ApiOperations::Post, ApiOperations::Put
Defined in:
lib/nylas/resources/webhooks.rb

Overview

Nylas Webhooks API

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Nylas::Resource

Instance Method Details

#create(request_body:) ⇒ Array(Hash, String)

Create a webhook.

Parameters:

  • request_body (Hash)

    The values to create the webhook with.

Returns:

  • (Array(Hash, String))

    The created webhook and API Request ID.



54
55
56
57
58
59
# File 'lib/nylas/resources/webhooks.rb', line 54

def create(request_body:)
  post(
    path: "#{api_uri}/v3/webhooks",
    request_body: request_body
  )
end

#destroy(webhook_id:) ⇒ Array(TrueClass, String)

Delete a webhook.

Parameters:

  • webhook_id (String)

    The id of the webhook to delete.

Returns:

  • (Array(TrueClass, String))

    True and the API Request ID for the delete operation.



77
78
79
80
81
82
83
# File 'lib/nylas/resources/webhooks.rb', line 77

def destroy(webhook_id:)
  _, request_id = delete(
    path: "#{api_uri}/v3/webhooks/#{webhook_id}"
  )

  [true, request_id]
end

#find(webhook_id:) ⇒ Array(Hash, String)

Return a webhook.

Parameters:

  • webhook_id (String)

    The id of the webhook to return.

Returns:

  • (Array(Hash, String))

    The webhook and API request ID.



44
45
46
47
48
# File 'lib/nylas/resources/webhooks.rb', line 44

def find(webhook_id:)
  get(
    path: "#{api_uri}/v3/webhooks/#{webhook_id}"
  )
end

#listArray(Array(Hash), String)

Return all webhooks.

Returns:

  • (Array(Array(Hash), String))

    The list of webhooks and API Request ID.



34
35
36
37
38
# File 'lib/nylas/resources/webhooks.rb', line 34

def list
  get(
    path: "#{api_uri}/v3/webhooks"
  )
end

#update(webhook_id:, request_body:) ⇒ Array(Hash, String)

Update a webhook.

Parameters:

  • webhook_id (String)

    The id of the webhook to update.

  • request_body (Hash)

    The values to update the webhook with

Returns:

  • (Array(Hash, String))

    The updated webhook and API Request ID.



66
67
68
69
70
71
# File 'lib/nylas/resources/webhooks.rb', line 66

def update(webhook_id:, request_body:)
  put(
    path: "#{api_uri}/v3/webhooks/#{webhook_id}",
    request_body: request_body
  )
end