Current section
Files
Jump to
Current section
Files
lib/xdk/account_activity.ex
# AUTO-GENERATED FILE - DO NOT EDIT
# This file was automatically generated by the XDK build tool.
# Any manual changes will be overwritten on the next generation.
defmodule Xdk.AccountActivity do
@moduledoc "Auto-generated client for account activity operations"
@doc """
Get subscriptions
GET /2/account_activity/webhooks/{webhook_id}/subscriptions/all/list
Retrieves a list of all active subscriptions for a given webhook.
"""
@spec get_subscriptions(Xdk.t(), webhook_id :: String.t()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def get_subscriptions(client, webhook_id) do
Xdk.request(client, :get, "/2/account_activity/webhooks/{webhook_id}/subscriptions/all/list",
params: %{
"webhook_id" => webhook_id
}
)
end
@doc """
Delete subscription
DELETE /2/account_activity/webhooks/{webhook_id}/subscriptions/{user_id}/all
Deletes an Account Activity subscription for the given webhook and user ID.
"""
@spec delete_subscription(Xdk.t(), webhook_id :: String.t(), user_id :: String.t()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def delete_subscription(client, webhook_id, user_id) do
Xdk.request(
client,
:delete,
"/2/account_activity/webhooks/{webhook_id}/subscriptions/{user_id}/all",
params: %{
"webhook_id" => webhook_id,
"user_id" => user_id
}
)
end
@doc """
Create replay job
POST /2/account_activity/replay/webhooks/{webhook_id}/subscriptions/all
Creates a replay job to retrieve activities from up to the past 5 days for all subscriptions associated with a given webhook.
"""
@spec create_replay_job(Xdk.t(), webhook_id :: String.t(), opts :: keyword()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def create_replay_job(client, webhook_id, opts \\ []) do
query =
[
{"from_date", Keyword.get(opts, :from_date)},
{"to_date", Keyword.get(opts, :to_date)}
]
|> Xdk.Query.build()
Xdk.request(
client,
:post,
"/2/account_activity/replay/webhooks/{webhook_id}/subscriptions/all",
params: %{
"webhook_id" => webhook_id
},
query: query
)
end
@doc """
Validate subscription
GET /2/account_activity/webhooks/{webhook_id}/subscriptions/all
Checks a user’s Account Activity subscription for a given webhook.
"""
@spec validate_subscription(Xdk.t(), webhook_id :: String.t()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def validate_subscription(client, webhook_id) do
Xdk.request(client, :get, "/2/account_activity/webhooks/{webhook_id}/subscriptions/all",
params: %{
"webhook_id" => webhook_id
}
)
end
@doc """
Create subscription
POST /2/account_activity/webhooks/{webhook_id}/subscriptions/all
Creates an Account Activity subscription for the user and the given webhook.
"""
@spec create_subscription(Xdk.t(), webhook_id :: String.t(), body :: map()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def create_subscription(client, webhook_id, body) do
Xdk.request(client, :post, "/2/account_activity/webhooks/{webhook_id}/subscriptions/all",
params: %{
"webhook_id" => webhook_id
},
json: body
)
end
@doc """
Get subscription count
GET /2/account_activity/subscriptions/count
Retrieves a count of currently active Account Activity subscriptions.
"""
@spec get_subscription_count(Xdk.t()) :: {:ok, map()} | {:error, Xdk.Errors.error()}
def get_subscription_count(client) do
Xdk.request(client, :get, "/2/account_activity/subscriptions/count")
end
end