# 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.DirectMessages do @moduledoc "Auto-generated client for direct messages operations" @doc """ Get DM events GET /2/dm_events Retrieves a list of recent direct message events across all conversations. """ @spec get_events(Xdk.t(), opts :: keyword()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def get_events(client, opts \\ []) do query = [ {"max_results", Keyword.get(opts, :max_results)}, {"pagination_token", Keyword.get(opts, :pagination_token)}, {"event_types", Keyword.get(opts, :event_types)}, {"dm_event.fields", Keyword.get(opts, :dm_event_fields)}, {"expansions", Keyword.get(opts, :expansions)}, {"media.fields", Keyword.get(opts, :media_fields)}, {"user.fields", Keyword.get(opts, :user_fields)}, {"tweet.fields", Keyword.get(opts, :tweet_fields)} ] |> Xdk.Query.build() Xdk.request(client, :get, "/2/dm_events", query: query) end @doc """ Create DM message by participant ID POST /2/dm_conversations/with/{participant_id}/messages Sends a new direct message to a specific participant by their ID. """ @spec create_by_participant_id(Xdk.t(), participant_id :: String.t(), body :: map()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def create_by_participant_id(client, participant_id, body) do Xdk.request(client, :post, "/2/dm_conversations/with/{participant_id}/messages", params: %{ "participant_id" => participant_id }, json: body ) end @doc """ Get DM event by ID GET /2/dm_events/{event_id} Retrieves details of a specific direct message event by its ID. """ @spec get_events_by_id(Xdk.t(), event_id :: String.t(), opts :: keyword()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def get_events_by_id(client, event_id, opts \\ []) do query = [ {"dm_event.fields", Keyword.get(opts, :dm_event_fields)}, {"expansions", Keyword.get(opts, :expansions)}, {"media.fields", Keyword.get(opts, :media_fields)}, {"user.fields", Keyword.get(opts, :user_fields)}, {"tweet.fields", Keyword.get(opts, :tweet_fields)} ] |> Xdk.Query.build() Xdk.request(client, :get, "/2/dm_events/{event_id}", params: %{ "event_id" => event_id }, query: query ) end @doc """ Delete DM event DELETE /2/dm_events/{event_id} Deletes a specific direct message event by its ID, if owned by the authenticated user. """ @spec delete_events(Xdk.t(), event_id :: String.t()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def delete_events(client, event_id) do Xdk.request(client, :delete, "/2/dm_events/{event_id}", params: %{ "event_id" => event_id } ) end @doc """ Create DM message by conversation ID POST /2/dm_conversations/{dm_conversation_id}/messages Sends a new direct message to a specific conversation by its ID. """ @spec create_by_conversation_id(Xdk.t(), dm_conversation_id :: String.t(), body :: map()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def create_by_conversation_id(client, dm_conversation_id, body) do Xdk.request(client, :post, "/2/dm_conversations/{dm_conversation_id}/messages", params: %{ "dm_conversation_id" => dm_conversation_id }, json: body ) end @doc """ Get DM events for a DM conversation GET /2/dm_conversations/{id}/dm_events Retrieves direct message events for a specific conversation. """ @spec get_events_by_conversation_id(Xdk.t(), id :: String.t(), opts :: keyword()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def get_events_by_conversation_id(client, id, opts \\ []) do query = [ {"max_results", Keyword.get(opts, :max_results)}, {"pagination_token", Keyword.get(opts, :pagination_token)}, {"event_types", Keyword.get(opts, :event_types)}, {"dm_event.fields", Keyword.get(opts, :dm_event_fields)}, {"expansions", Keyword.get(opts, :expansions)}, {"media.fields", Keyword.get(opts, :media_fields)}, {"user.fields", Keyword.get(opts, :user_fields)}, {"tweet.fields", Keyword.get(opts, :tweet_fields)} ] |> Xdk.Query.build() Xdk.request(client, :get, "/2/dm_conversations/{id}/dm_events", params: %{ "id" => id }, query: query ) end @doc """ Create DM conversation POST /2/dm_conversations Initiates a new direct message conversation with specified participants. """ @spec create_conversation(Xdk.t(), body :: map()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def create_conversation(client, body) do Xdk.request(client, :post, "/2/dm_conversations", json: body) end @doc """ Get DM events for a DM conversation GET /2/dm_conversations/with/{participant_id}/dm_events Retrieves direct message events for a specific conversation. """ @spec get_events_by_participant_id(Xdk.t(), participant_id :: String.t(), opts :: keyword()) :: {:ok, map()} | {:error, Xdk.Errors.error()} def get_events_by_participant_id(client, participant_id, opts \\ []) do query = [ {"max_results", Keyword.get(opts, :max_results)}, {"pagination_token", Keyword.get(opts, :pagination_token)}, {"event_types", Keyword.get(opts, :event_types)}, {"dm_event.fields", Keyword.get(opts, :dm_event_fields)}, {"expansions", Keyword.get(opts, :expansions)}, {"media.fields", Keyword.get(opts, :media_fields)}, {"user.fields", Keyword.get(opts, :user_fields)}, {"tweet.fields", Keyword.get(opts, :tweet_fields)} ] |> Xdk.Query.build() Xdk.request(client, :get, "/2/dm_conversations/with/{participant_id}/dm_events", params: %{ "participant_id" => participant_id }, query: query ) end end