Current section
Files
Jump to
Current section
Files
lib/teac/api/channels/editors.ex
defmodule Teac.Api.Channels.Editors do
alias Teac.Api
@schema NimbleOptions.new!(broadcaster_id: [type: :string, required: true])
@doc """
Gets a list of users who are editors for the specified broadcaster.
## Authorization
Requires a user access token with the `channel:read:editors` scope.
## Options
* `:broadcaster_id` - required. The ID of the broadcaster whose editors 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("channels/editors"),
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