Current section
Files
Jump to
Current section
Files
lib/teac/api/bits/cheermotes.ex
defmodule Teac.Api.Bits.Cheermotes do
alias Teac.Api
@schema NimbleOptions.new!(broadcaster_id: [type: :integer])
@doc """
Gets a list of Cheermotes that users can use to cheer Bits in any Bits-enabled channel's chat room.
## Authorization
Requires an app access token or user access token.
## Options
* `:broadcaster_id` - optional. The ID of the broadcaster whose Cheermotes to include. If not specified, only global Cheermotes are returned.
"""
@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} ->
params =
case opts[:broadcaster_id] do
nil -> []
id -> [broadcaster_id: to_string(id)]
end
[
base_url: Api.uri("bits/cheermotes"),
params: params,
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