Current section
Files
Jump to
Current section
Files
lib/teac/api/channels/ads/schedule/snooze.ex
defmodule Teac.Api.Channels.Ads.Schedule.Snooze do
alias Teac.Api
@schema NimbleOptions.new!(broadcaster_id: [type: :string, required: true])
@doc """
If available, pushes back the timestamp of the upcoming automatic mid-roll ad by 5 minutes.
## Authorization
Requires a user access token with the `channel:manage:ads` scope.
The `user_id` in the user access token must match the `broadcaster_id`.
## Options
* `:broadcaster_id` - required. The ID of the broadcaster whose ad to snooze.
"""
@spec post(Teac.Client.t(), keyword()) :: {:ok, map()} | {:error, Teac.Error.t()}
def post(%Teac.Client{} = client, opts \\ []) do
case NimbleOptions.validate(opts, @schema) do
{:ok, opts} ->
[
base_url: Api.uri("channels/ads/schedule/snooze"),
params: [broadcaster_id: opts[:broadcaster_id]],
headers: Api.headers(client)
]
|> Keyword.merge(Application.get_env(:teac, :api_req_options, []))
|> Req.post!()
|> Api.handle_response()
{:error, %NimbleOptions.ValidationError{} = err} ->
{:error, err.message}
end
end
end