# 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.Webhooks do @moduledoc "Auto-generated client for webhooks operations" @doc """ Create replay job for webhook POST /2/webhooks/replay Creates a replay job to retrieve events from up to the past 24 hours for all events delivered or attempted to be delivered to the webhook. """ @spec create_webhook_replay_job(Xdk.t(), body :: map()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def create_webhook_replay_job(client, body) do Xdk.request(client, :post, "/2/webhooks/replay", json: body) end @doc """ Create stream link POST /2/tweets/search/webhooks/{webhook_id} Creates a link to deliver FilteredStream events to the given webhook. """ @spec create_stream_link(Xdk.t(), webhook_id :: String.t(), opts :: keyword()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def create_stream_link(client, webhook_id, opts \\ []) do query = [ {"tweet.fields", Keyword.get(opts, :tweet_fields)}, {"expansions", Keyword.get(opts, :expansions)}, {"media.fields", Keyword.get(opts, :media_fields)}, {"poll.fields", Keyword.get(opts, :poll_fields)}, {"user.fields", Keyword.get(opts, :user_fields)}, {"place.fields", Keyword.get(opts, :place_fields)} ] |> Xdk.Query.build() Xdk.request(client, :post, "/2/tweets/search/webhooks/{webhook_id}", params: %{ "webhook_id" => webhook_id }, query: query ) end @doc """ Delete stream link DELETE /2/tweets/search/webhooks/{webhook_id} Deletes a link from FilteredStream events to the given webhook. """ @spec delete_stream_link(Xdk.t(), webhook_id :: String.t()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def delete_stream_link(client, webhook_id) do Xdk.request(client, :delete, "/2/tweets/search/webhooks/{webhook_id}", params: %{ "webhook_id" => webhook_id } ) end @doc """ Validate webhook PUT /2/webhooks/{webhook_id} Triggers a CRC check for a given webhook. """ @spec validate(Xdk.t(), webhook_id :: String.t()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def validate(client, webhook_id) do Xdk.request(client, :put, "/2/webhooks/{webhook_id}", params: %{ "webhook_id" => webhook_id } ) end @doc """ Delete webhook DELETE /2/webhooks/{webhook_id} Deletes an existing webhook configuration. """ @spec delete(Xdk.t(), webhook_id :: String.t()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def delete(client, webhook_id) do Xdk.request(client, :delete, "/2/webhooks/{webhook_id}", params: %{ "webhook_id" => webhook_id } ) end @doc """ Get stream links GET /2/tweets/search/webhooks Get a list of webhook links associated with a filtered stream ruleset. """ @spec get_stream_links(Xdk.t()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def get_stream_links(client) do Xdk.request(client, :get, "/2/tweets/search/webhooks") end @doc """ Get webhook GET /2/webhooks Get a list of webhook configs associated with a client app. """ @spec get(Xdk.t(), opts :: keyword()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def get(client, opts \\ []) do query = [ {"webhook_config.fields", Keyword.get(opts, :webhook_config_fields)} ] |> Xdk.Query.build() Xdk.request(client, :get, "/2/webhooks", query: query) end @doc """ Create webhook POST /2/webhooks Creates a new webhook configuration. """ @spec create(Xdk.t(), body :: map()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def create(client, body) do Xdk.request(client, :post, "/2/webhooks", json: body) end end