Current section
Files
Jump to
Current section
Files
lib/resources/eventsub/create_eventsub_subscription.ex
defmodule TwitchApi.EventSub.CreateEventSubSubscription do
@moduledoc """
⛔ This module is autogenerated please do not modify manually.
## Example request from twitch api docs:
### descriptions:
This example adds a user.update subscription.
### requests:
curl -X POST 'https://api.twitch.tv/helix/eventsub/subscriptions'
-H'Authorization: Bearer 2gbdx6oar67tqtcmt49t3wpcgycthx'
-H'Client-Id: wbmytr93xzw8zbg0p1izqyzzc5mbiz'
-H'Content-Type: application/json'
-d'{"type":"user.update","version":"1","condition":{"user_id":"1234"},"transport":{"method":"webhook","callback":"https://this-is-a-callback.com","secret":"s3cre7"}}'
## Example response from twitch api docs:
### descriptions:
### responses:
{"data":[{"id":"26b1c993-bfcf-44d9-b876-379dacafe75a","status":"webhook_callback_verification_pending","type":"user.update","version":"1","condition":{"user_id":"1234"},"created_at":"2020-11-10T14:32:18.730260295Z","transport":{"method":"webhook","callback":"https://this-is-a-callback.com"},"cost":1}],"total":1,"total_cost":1,"max_total_cost":10000}
# Twitch CLI example that adds a user.update subscription.
twitch api post /eventsub/subscriptions -b'{"type":"user.update","version":"1","condition":{"user_id":"1234"},"transport":{"method":"webhook","callback":"https://this-is-a-callback.com","secret":"s3cre7"}}'
"""
alias TwitchApi.MyFinch
alias TwitchApi.ApiJson.Template.Method.Headers
@doc """
### Description:
Creates an EventSub subscription.
### Required authentication:
Requires an app access token.
To create a subscription, you must use an app access token; however, if the subscription type requires user authorization, the user must have granted your app permissions to receive those events before you subscribe to them. For example, to subscribe to
channel.subscribe
events, the user must have granted your app permission which adds the
channel:read:subscriptions
scope to your app’s client ID.
### Required authorization:
"""
# The parameter values that are specific to the specified subscription type.
@spec call(
%{
required(:condition) => String.t(),
# The transport details such as the transport method and callback URL that you want Twitch to use when sending you notifications.
required(:transport) => String.t(),
# The type of subscription to create. For a list of subscriptions you can create see Subscription Types. Set type to the value in the Name column of the Subscription Types table.
required(:type) => String.t(),
# The version of the subscription type used in this request. A subscription type could define one or more object definitions so you need to specify which definition you’re using.
required(:version) => String.t()
}
| nil
) :: {:ok, Finch.Response.t()} | {:error, Exception.t()}
def call(body_params) do
MyFinch.request(
"POST",
"https://api.twitch.tv/helix/eventsub/subscriptions",
Headers.config_headers(),
body_params
)
end
end