Current section

Files

Jump to
teac lib teac api content_classification_labels.ex
Raw

lib/teac/api/content_classification_labels.ex

defmodule Teac.Api.ContentClassificationLabels do
alias Teac.Api
@locales [
"en-US",
"bg-BG",
"cs-CZ",
"da-DK",
"de-DE",
"el-GR",
"en-GB",
"es-ES",
"es-MX",
"fi-FI",
"fr-FR",
"hu-HU",
"it-IT",
"ja-JP",
"ko-KR",
"nl-NL",
"no-NO",
"pl-PL",
"pt-BT",
"pt-PT",
"ro-RO",
"ru-RU",
"sk-SK",
"sv-SE",
"th-TH",
"tr-TR",
"vi-VN",
"zh-CN",
"zh-TW"
]
@schema NimbleOptions.new!(locale: [type: {:in, @locales}])
@doc """
Gets information about Twitch content classification labels.
## Authorization
Requires an app access token or user access token.
## Options
* `:locale` - optional. Locale for the label descriptions. Defaults to `"en-US"`.
Supported values: `"en-US"`, `"bg-BG"`, `"cs-CZ"`, `"da-DK"`, `"de-DE"`, `"el-GR"`,
`"en-GB"`, `"es-ES"`, `"es-MX"`, `"fi-FI"`, `"fr-FR"`, `"hu-HU"`, `"it-IT"`,
`"ja-JP"`, `"ko-KR"`, `"nl-NL"`, `"no-NO"`, `"pl-PL"`, `"pt-BT"`, `"pt-PT"`,
`"ro-RO"`, `"ru-RU"`, `"sk-SK"`, `"sv-SE"`, `"th-TH"`, `"tr-TR"`, `"vi-VN"`,
`"zh-CN"`, `"zh-TW"`.
"""
@spec get(Teac.Client.t(), keyword()) :: {:ok, list(map()), Teac.RateLimit.t()} | {:error, Teac.Error.t()}
def get(%Teac.Client{} = client, opts \\ []) do
case NimbleOptions.validate(opts, @schema) do
{:ok, opts} ->
params = if opts[:locale], do: [locale: opts[:locale]], else: []
[
base_url: Api.uri("content_classification_labels"),
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