Current section

Files

Jump to
teac lib teac api guest_star slot_settings.ex
Raw

lib/teac/api/guest_star/slot_settings.ex

defmodule Teac.Api.GuestStar.SlotSettings do
alias Teac.Api
@schema NimbleOptions.new!(
broadcaster_id: [type: :string, required: true],
moderator_id: [type: :string, required: true],
session_id: [type: :string, required: true],
slot_id: [type: :string, required: true],
is_audio_enabled: [type: :boolean],
is_video_enabled: [type: :boolean],
is_live: [type: :boolean],
volume: [type: :integer]
)
@doc """
Updates the settings for a Guest Star slot in an active session.
## Authorization
Requires a user access token with the `channel:manage:guest_star` scope.
## Options
* `:broadcaster_id` - required. The ID of the broadcaster running the session.
* `:moderator_id` - required. The ID of the moderator or broadcaster performing the action.
* `:session_id` - required. The ID of the Guest Star session.
* `:slot_id` - required. The ID of the slot to update.
* `:is_audio_enabled` - optional. If `true`, the guest's audio is enabled.
* `:is_video_enabled` - optional. If `true`, the guest's video is enabled.
* `:is_live` - optional. If `true`, the slot is visible to viewers.
* `:volume` - optional. Audio volume level for the slot. Min 0, max 100.
"""
@spec patch(Teac.Client.t(), keyword()) :: {:ok, nil, Teac.RateLimit.t()} | {:error, Teac.Error.t()}
def patch(%Teac.Client{} = client, opts \\ []) do
case NimbleOptions.validate(opts, @schema) do
{:ok, opts} ->
params =
[
broadcaster_id: opts[:broadcaster_id],
moderator_id: opts[:moderator_id],
session_id: opts[:session_id],
slot_id: opts[:slot_id],
is_audio_enabled: opts[:is_audio_enabled],
is_video_enabled: opts[:is_video_enabled],
is_live: opts[:is_live],
volume: opts[:volume]
]
|> Enum.reject(fn {_k, v} -> is_nil(v) end)
[
base_url: Api.uri("guest_star/slot_settings"),
headers: Api.headers(client),
params: params
]
|> Keyword.merge(Application.get_env(:teac, :api_req_options, []))
|> Req.patch()
|> Api.handle_response()
{:error, %NimbleOptions.ValidationError{} = err} ->
{:error, err.message}
end
end
end