-
Notifications
You must be signed in to change notification settings - Fork 1
/
webhook.ex
55 lines (48 loc) · 1.19 KB
/
webhook.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
defmodule ActiveCampaign.Webhook do
@moduledoc """
Documentation for `ActiveCampaign.Webhook`.
"""
alias ActiveCampaign.Http
@doc """
Create a webhook
"""
@spec create(map()) :: {:ok, map()} | {:error, any()}
def create(webhook) do
Http.post("webhooks", %{webhook: webhook})
end
@doc """
Retrieve a webhook
"""
@spec get(integer()) :: {:ok, map()} | {:error, any()}
def get(id) do
Http.get("webhooks/#{id}")
end
@doc """
Update a webhook
"""
@spec update(integer(), map()) :: {:ok, map()} | {:error, any()}
def update(id, webhook) do
Http.put("webhooks/#{id}", %{webhook: webhook})
end
@doc """
Delete a webhook
"""
@spec delete(integer()) :: {:ok, map()} | {:error, any()}
def delete(id) do
Http.delete("webhooks/#{id}")
end
@doc """
List all webhooks
"""
@spec list(map()) :: {:ok, map()} | {:error, any()}
def list(query_params \\ %{}) do
Http.get("webhooks?" <> Http.encode_query(query_params))
end
@doc """
List all webhook events
"""
@spec list_events(map()) :: {:ok, map()} | {:error, any()}
def list_events(query_params \\ %{}) do
Http.get("webhook/events?" <> Http.encode_query(query_params))
end
end