Current section
Files
Jump to
Current section
Files
lib/xdk/spaces.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.Spaces do
@moduledoc "Auto-generated client for spaces operations"
@doc """
Search Spaces
GET /2/spaces/search
Retrieves a list of Spaces 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)},
{"state", Keyword.get(opts, :state)},
{"max_results", Keyword.get(opts, :max_results)},
{"space.fields", Keyword.get(opts, :space_fields)},
{"expansions", Keyword.get(opts, :expansions)},
{"user.fields", Keyword.get(opts, :user_fields)},
{"topic.fields", Keyword.get(opts, :topic_fields)}
]
|> Xdk.Query.build()
Xdk.request(client, :get, "/2/spaces/search", query: query)
end
@doc """
Get Spaces by creator IDs
GET /2/spaces/by/creator_ids
Retrieves details of Spaces created by specified User IDs.
"""
@spec get_by_creator_ids(Xdk.t(), opts :: keyword()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def get_by_creator_ids(client, opts \\ []) do
query =
[
{"user_ids", Keyword.get(opts, :user_ids)},
{"space.fields", Keyword.get(opts, :space_fields)},
{"expansions", Keyword.get(opts, :expansions)},
{"user.fields", Keyword.get(opts, :user_fields)},
{"topic.fields", Keyword.get(opts, :topic_fields)}
]
|> Xdk.Query.build()
Xdk.request(client, :get, "/2/spaces/by/creator_ids", query: query)
end
@doc """
Get space by ID
GET /2/spaces/{id}
Retrieves details of a specific space 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 =
[
{"space.fields", Keyword.get(opts, :space_fields)},
{"expansions", Keyword.get(opts, :expansions)},
{"user.fields", Keyword.get(opts, :user_fields)},
{"topic.fields", Keyword.get(opts, :topic_fields)}
]
|> Xdk.Query.build()
Xdk.request(client, :get, "/2/spaces/{id}",
params: %{
"id" => id
},
query: query
)
end
@doc """
Get Space ticket buyers
GET /2/spaces/{id}/buyers
Retrieves a list of Users who purchased tickets to a specific Space by its ID.
"""
@spec get_buyers(Xdk.t(), id :: String.t(), opts :: keyword()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def get_buyers(client, id, opts \\ []) do
query =
[
{"pagination_token", Keyword.get(opts, :pagination_token)},
{"max_results", Keyword.get(opts, :max_results)},
{"user.fields", Keyword.get(opts, :user_fields)},
{"expansions", Keyword.get(opts, :expansions)},
{"tweet.fields", Keyword.get(opts, :tweet_fields)}
]
|> Xdk.Query.build()
Xdk.request(client, :get, "/2/spaces/{id}/buyers",
params: %{
"id" => id
},
query: query
)
end
@doc """
Get Space Posts
GET /2/spaces/{id}/tweets
Retrieves a list of Posts shared in a specific Space by its ID.
"""
@spec get_posts(Xdk.t(), id :: String.t(), opts :: keyword()) ::
{:ok, map()} | {:error, Xdk.Errors.error()}
def get_posts(client, id, opts \\ []) do
query =
[
{"max_results", Keyword.get(opts, :max_results)},
{"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, :get, "/2/spaces/{id}/tweets",
params: %{
"id" => id
},
query: query
)
end
@doc """
Get Spaces by IDs
GET /2/spaces
Retrieves details of multiple Spaces by their IDs.
"""
@spec get_by_ids(Xdk.t(), opts :: keyword()) :: {:ok, map()} | {:error, Xdk.Errors.error()}
def get_by_ids(client, opts \\ []) do
query =
[
{"ids", Keyword.get(opts, :ids)},
{"space.fields", Keyword.get(opts, :space_fields)},
{"expansions", Keyword.get(opts, :expansions)},
{"user.fields", Keyword.get(opts, :user_fields)},
{"topic.fields", Keyword.get(opts, :topic_fields)}
]
|> Xdk.Query.build()
Xdk.request(client, :get, "/2/spaces", query: query)
end
end