Current section
Files
Jump to
Current section
Files
lib/teac/api/chat/badges.ex
defmodule Teac.Api.Chat.Badges do
alias Teac.Api
@schema NimbleOptions.new!(broadcaster_id: [type: :string, required: true])
@doc """
Gets a list of custom chat badges that can be used in the specified channel's chat room.
## Authorization
Requires an app access token or user access token.
## Options
* `:broadcaster_id` - required. The ID of the broadcaster whose chat badges to get.
"""
@spec get(Teac.Client.t(), keyword()) :: {:ok, list(map())} | {:error, Teac.Error.t()}
def get(%Teac.Client{} = client, opts \\ []) do
case NimbleOptions.validate(opts, @schema) do
{:ok, opts} ->
[
base_url: Api.uri("chat/badges"),
params: [broadcaster_id: opts[:broadcaster_id]],
headers: Api.headers(client)
]
|> Keyword.merge(Application.get_env(:teac, :api_req_options, []))
|> Req.get!()
|> Api.handle_response()
{:error, %NimbleOptions.ValidationError{} = err} ->
{:error, err.message}
end
end
end