Current section
Files
Jump to
Current section
Files
lib/resources/entitlements/redeem_code.ex
defmodule TwitchApi.Entitlements.RedeemCode do
@moduledoc """
⛔ This module is autogenerated please do not modify manually.
## Example request from twitch api docs:
### descriptions:
### requests:
curl -X POST 'https://api.twitch.tv/helix/entitlements/codes?user_id=12345&code=8CD5P-V3J92-2S6JY&code=PUN4G-HYFVP-MMFET'
-H'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y'
-H'Client-Id: uo6dggojyb8d6soh92zknwmi5ej1q2'
## Example response from twitch api docs:
### descriptions:
### responses:
{"data":[{"code":"8CD5P-V3J92-2S6JY","status":"SUCCESSFULLY_REDEEMED"},{"code":"PUN4G-HYFVP-MMFET","status":"ALREADY_CLAIMED"}]}
"""
alias TwitchApi.MyFinch
alias TwitchApi.ApiJson.Template.Method.Headers
@doc """
### Description:
Redeems one or more redemption codes.
### Required authentication:
Requires an App access token. Only client IDs approved by Twitch may redeem codes on behalf of any Twitch user account.
### Required authorization:
"""
@typedoc """
The redemption code to redeem. To redeem multiple codes, include this parameter for each redemption code. For example, code=1234&code=5678. You may specify a maximum of 20 codes.
"""
@type code :: %{required(:code) => String.t()}
@typedoc """
The ID of the user that owns the redemption code to redeem.
"""
@type user_id :: %{required(:user_id) => String.t()}
@spec call(code | user_id) :: {:ok, Finch.Response.t()} | {:error, Exception.t()}
def call(%{code: code}) do
MyFinch.request(
"POST",
"https://api.twitch.tv/helix/entitlements/codes?code=#{code}",
Headers.config_headers(),
nil
)
end
def call(%{user_id: user_id}) do
MyFinch.request(
"POST",
"https://api.twitch.tv/helix/entitlements/codes?user_id=#{user_id}",
Headers.config_headers(),
nil
)
end
end