Module: Pixela::Client::WebhookMethods
- Included in:
- Pixela::Client
- Defined in:
- lib/pixela/client/webhook_methods.rb
Instance Method Summary collapse
-
#create_webhook(graph_id:, type:) ⇒ Pixela::Response
Create a new Webhook.
-
#delete_webhook(webhook_hash:) ⇒ Pixela::Response
Delete the registered Webhook.
-
#get_webhooks ⇒ Array<Hashie::Mash>
Get all predefined webhooks definitions.
-
#invoke_webhook(webhook_hash:) ⇒ Pixela::Response
Invoke the webhook registered in advance.
Instance Method Details
#create_webhook(graph_id:, type:) ⇒ Pixela::Response
Create a new Webhook.
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.
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_webhooks ⇒ Array<Hashie::Mash>
Get all predefined webhooks definitions.
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.
54 55 56 57 58 |
# File 'lib/pixela/client/webhook_methods.rb', line 54 def invoke_webhook(webhook_hash:) with_error_handling do connection(request_headers: default_headers).post("users/#{username}/webhooks/#{webhook_hash}").body end end |