Current section

Files

Jump to
scrapped_twitch_api lib resources subscriptions check_user_subscription.ex
Raw

lib/resources/subscriptions/check_user_subscription.ex

defmodule TwitchApi.Subscriptions.CheckUserSubscription do
@moduledoc """
⛔ This module is autogenerated please do not modify manually.
## Example request from twitch api docs:
### descriptions:
Checks if the user TwitchDev (141981764) subscribes to the TwitchPresents (149747285) channel.
### requests:
curl -X GET 'https://api.twitch.tv/helix/subscriptions/user?broadcaster_id=149747285&user_id=141981764'
-H'Authorization: Bearer 2gbdx6oar67tqtcmt49t3wpcgycthx'
-H'Client-Id: wbmytr93xzw8zbg0p1izqyzzc5mbiz'
## Example response from twitch api docs:
### descriptions:
If TwitchDev does subscribe to the TwitchPresents channel.
If TwitchDev does not subscribe to the TwitchPresents channel.
### responses:
{"error":"Not Found","message":"twitchdev has no subscription to twitchpresents","status":404}
{"data":[{"broadcaster_id":"149747285","broadcaster_name":"TwitchPresents","broadcaster_login":"twitchpresents","is_gift":false,"tier":"1000"}]}
"""
alias TwitchApi.MyFinch
alias TwitchApi.ApiJson.Template.Method.Headers
@doc """
### Description:
Checks if a specific user is subscribed to a specific channel.
### Required authentication:
User access token with scope user:read:subscriptions
App access token if the user has authorized your application with scope user:read:subscriptions
### Required authorization:
"""
# User ID of an Affiliate or Partner broadcaster.
@type broadcaster_id :: %{required(:broadcaster_id) => String.t()}
# User ID of a Twitch viewer.
@type user_id :: %{required(:user_id) => String.t()}
@spec call(broadcaster_id | user_id) :: {:ok, Finch.Response.t()} | {:error, Exception.t()}
def call(%{broadcaster_id: broadcaster_id}) do
MyFinch.request(
"GET",
"https://api.twitch.tv/helix/subscriptions/user?broadcaster_id=#{broadcaster_id}",
Headers.config_headers(),
nil
)
end
def call(%{user_id: user_id}) do
MyFinch.request(
"GET",
"https://api.twitch.tv/helix/subscriptions/user?user_id=#{user_id}",
Headers.config_headers(),
nil
)
end
end