Current section

Files

Jump to
scrapped_twitch_api lib resources predictions create_prediction.ex
Raw

lib/resources/predictions/create_prediction.ex

defmodule TwitchApi.Predictions.CreatePrediction do
@moduledoc """
⛔ This module is autogenerated please do not modify manually.
## Example request from twitch api docs:
### descriptions:
Creates a Prediction for the TwitchDev channel.
### requests:
curl -X POST 'https://api.twitch.tv/helix/predictions'
-H'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y'
-H'Client-Id: uo6dggojyb8d6soh92zknwmi5ej1q2'
-H'Content-Type: application/json'
-d'{
"broadcaster_id": "141981764",
"title": "Any leeks in the stream?",
"outcomes": [
{
"title": "Yes, give it time."
},
{
"title": "Definitely not."
}
],
"prediction_window": 120
}'
## Example response from twitch api docs:
### descriptions:
### responses:
{"data":[{"id":"bc637af0-7766-4525-9308-4112f4cbf178","broadcaster_id":"141981764","broadcaster_name":"TwitchDev","broadcaster_login":"twitchdev","title":"Any leeks in the stream?","winning_outcome_id":null,"outcomes":[{"id":"73085848-a94d-4040-9d21-2cb7a89374b7","title":"Yes, give it time.","users":0,"channel_points":0,"top_predictors":null,"color":"BLUE"},{"id":"906b70ba-1f12-47ea-9e95-e5f93d20e9cc","title":"Definitely not.","users":0,"channel_points":0,"top_predictors":null,"color":"PINK"}],"prediction_window":120,"status":"ACTIVE","created_at":"2021-04-28T17:11:22.595914172Z","ended_at":null,"locked_at":null}]}
"""
alias TwitchApi.MyFinch
alias TwitchApi.ApiJson.Template.Method.Headers
@doc """
### Description:
Create a Channel Points Prediction for a specific Twitch channel.
### Required authentication:
### Required authorization:
User OAuth tokenRequired scope: channel:manage:predictions
"""
@typedoc """
Map containing the user needed information for the fetch of the required user OAuth access token.
You will be able to choose from one way or the other for fetching previously OAuth access tokens.
:user_id field contains the user ID from twitch, e.g. 61425548 or "61425548"
:user_name field constains the user name from twitch, e.g. "hiimkamiyuzu"
"""
@type user_info :: %{user_id: integer | binary} | %{user_name: binary}
# The broadcaster running Predictions. Provided broadcaster_id must match the user_id in the user OAuth token.Maximum => 1
@spec call(
%{
required(:broadcaster_id) => String.t(),
# The list of possible outcomes for the Prediction. The minimum number of outcomes that you may specify is 2 and the maximum is 10.
required(:outcomes) => list(map),
# Total duration for the Prediction (in seconds).Minimum => 1. Maximum => 1800.
required(:prediction_window) => integer,
# Title for the Prediction.Maximum => 45 characters.
required(:title) => String.t()
}
| nil,
user_info
) :: {:ok, Finch.Response.t()} | {:error, Exception.t()}
def call(body_params, user_info) do
MyFinch.request(
"POST",
"https://api.twitch.tv/helix/predictions",
Headers.config_oauth_headers(user_info),
body_params
)
end
end