Module: Pixela::Client::WebhookMethods

Included in:
Pixela::Client
Defined in:
lib/pixela/client/webhook_methods.rb

Instance Method Summary collapse

Instance Method Details

#create_webhook(graph_id:, type:) ⇒ Pixela::Response

Create a new Webhook.

Examples:

client.create_webhook(graph_id: "test-graph", type: "increment")

Raises:

See Also:


15
16
17
18
19
20
21
22
23
24
# File 'lib/pixela/client/webhook_methods.rb', line 15

def create_webhook(graph_id:, type:)
  params = {
    graphID: graph_id,
    type:    type,
  }

  with_error_handling do
    connection.post("users/#{username}/webhooks", params).body
  end
end

#delete_webhook(webhook_hash:) ⇒ Pixela::Response

Delete the registered Webhook.

Examples:

client.delete_webhook(webhook_hash: "<webhookHash>")

Raises:

See Also:


72
73
74
75
76
# File 'lib/pixela/client/webhook_methods.rb', line 72

def delete_webhook(webhook_hash:)
  with_error_handling do
    connection.delete("users/#{username}/webhooks/#{webhook_hash}").body
  end
end

#get_webhooksArray<Hashie::Mash>

Get all predefined webhooks definitions.

Examples:

client.get_webhooks

Raises:

See Also:


36
37
38
39
40
# File 'lib/pixela/client/webhook_methods.rb', line 36

def get_webhooks
  with_error_handling do
    connection.get("users/#{username}/webhooks").body.webhooks
  end
end

#invoke_webhook(webhook_hash:) ⇒ Pixela::Response

Invoke the webhook registered in advance.

Examples:

client.invoke_webhook(webhook_hash: "<webhookHash>")

Raises:

See Also:


54
55
56
57
58
# File 'lib/pixela/client/webhook_methods.rb', line 54

def invoke_webhook(webhook_hash:)
  with_error_handling do
    connection(default_headers).post("users/#{username}/webhooks/#{webhook_hash}").body
  end
end