Current section
Files
Jump to
Current section
Files
lib/thinkific/api/webhooks.ex
# NOTE: This class is auto generated by the swagger code generator program.
# https://github.com/swagger-api/swagger-codegen.git
# Do not edit the class manually.
defmodule Thinkific.Api.Webhooks do
@moduledoc """
API calls for all endpoints tagged `Webhooks`.
"""
alias Thinkific.Connection
import Thinkific.RequestBuilder
@doc """
Create Webhook
This endpoint creates a new Webhook
## Parameters
- connection (Thinkific.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :body (WebhookRequest): Webhook request type
## Returns
{:ok, %Thinkific.Model.WebhookResponse{}} on success
{:error, info} on failure
"""
@spec create_webhook(Tesla.Env.client, keyword()) :: {:ok, Thinkific.Model.WebhookResponse.t} | {:error, Tesla.Env.t}
def create_webhook(connection, opts \\ []) do
optional_params = %{
:"body" => :body
}
%{}
|> method(:post)
|> url("/webhooks")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.WebhookResponse{})
end
@doc """
deleteWebhookByID
This endpoint deletes the Webhook identified by the provided id.
## Parameters
- connection (Thinkific.Connection): Connection to server
- id (String.t): ID of the Webhook in the form of an string.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %{}} on success
{:error, info} on failure
"""
@spec delete_webhook_by_id(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
def delete_webhook_by_id(connection, id, _opts \\ []) do
%{}
|> method(:delete)
|> url("/webhooks/#{id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(false)
end
@doc """
getWebhookByID
This endpoint returns the Webhook identified by the provided id.
## Parameters
- connection (Thinkific.Connection): Connection to server
- id (String.t): ID of the Webhook in the form of an string.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Thinkific.Model.WebhookResponse{}} on success
{:error, info} on failure
"""
@spec get_webhook_by_id(Tesla.Env.client, String.t, keyword()) :: {:ok, Thinkific.Model.WebhookResponse.t} | {:error, Tesla.Env.t}
def get_webhook_by_id(connection, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/webhooks/#{id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.WebhookResponse{})
end
@doc """
Get Webhooks
This endpoint returns a list of Webhooks.
## Parameters
- connection (Thinkific.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :page (float()): The page within the collection to fetch
- :limit (float()): The number of items to be returned
## Returns
{:ok, %Thinkific.Model.GetWebhooksResponse{}} on success
{:error, info} on failure
"""
@spec get_webhooks(Tesla.Env.client, keyword()) :: {:ok, Thinkific.Model.GetWebhooksResponse.t} | {:error, Tesla.Env.t}
def get_webhooks(connection, opts \\ []) do
optional_params = %{
:"page" => :query,
:"limit" => :query
}
%{}
|> method(:get)
|> url("/webhooks")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.GetWebhooksResponse{})
end
@doc """
updateWebhookByID
This endpoint updates the Webhook identified by the provided id.
## Parameters
- connection (Thinkific.Connection): Connection to server
- id (String.t): ID of the Webhook in the form of an string.
- body (WebhookRequest): Webhook request attributes
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Thinkific.Model.WebhookResponse{}} on success
{:error, info} on failure
"""
@spec update_webhook_by_id(Tesla.Env.client, String.t, Thinkific.Model.WebhookRequest.t, keyword()) :: {:ok, Thinkific.Model.WebhookResponse.t} | {:error, Tesla.Env.t}
def update_webhook_by_id(connection, id, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/webhooks/#{id}")
|> add_param(:body, :"body", body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Thinkific.Model.WebhookResponse{})
end
end