Packages

Auto-generated Elixir client for the X (Twitter) API v2

Current section

Files

Jump to
xdk_elixir lib xdk communities.ex
Raw

lib/xdk/communities.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.Communities do
@moduledoc "Auto-generated client for communities operations"
@doc """
Get Community by ID
GET /2/communities/{id}
Retrieves details of a specific Community by its ID.
"""
@spec get_by_id(Xdk.t(), id :: String.t(), opts :: keyword()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def get_by_id(client, id, opts \\ []) do
query =
[
{"community.fields", Keyword.get(opts, :community_fields)}
]
|> Xdk.Query.build()
Xdk.request(client, :get, "/2/communities/{id}",
params: %{
"id" => id
},
query: query
)
end
@doc """
Search Communities
GET /2/communities/search
Retrieves a list of Communities matching the specified search query.
"""
@spec search(Xdk.t(), opts :: keyword()) :: {:ok, map()} | {:error, Xdk.Errors.error()}
def search(client, opts \\ []) do
query =
[
{"query", Keyword.get(opts, :query)},
{"max_results", Keyword.get(opts, :max_results)},
{"next_token", Keyword.get(opts, :next_token)},
{"pagination_token", Keyword.get(opts, :pagination_token)},
{"community.fields", Keyword.get(opts, :community_fields)}
]
|> Xdk.Query.build()
Xdk.request(client, :get, "/2/communities/search", query: query)
end
end