Migrate /commercial command to the Helix API (#4094)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -564,6 +564,34 @@ enum class HelixListVIPsError { // /vips
|
||||
Forwarded,
|
||||
}; // /vips
|
||||
|
||||
struct HelixStartCommercialResponse {
|
||||
// Length of the triggered commercial
|
||||
int length;
|
||||
// Provides contextual information on why the request failed
|
||||
QString message;
|
||||
// Seconds until the next commercial can be served on this channel
|
||||
int retryAfter;
|
||||
|
||||
explicit HelixStartCommercialResponse(const QJsonObject &jsonObject)
|
||||
{
|
||||
auto jsonData = jsonObject.value("data").toArray().at(0).toObject();
|
||||
this->length = jsonData.value("length").toInt();
|
||||
this->message = jsonData.value("message").toString();
|
||||
this->retryAfter = jsonData.value("retry_after").toInt();
|
||||
}
|
||||
};
|
||||
|
||||
enum class HelixStartCommercialError {
|
||||
Unknown,
|
||||
TokenMustMatchBroadcaster,
|
||||
UserMissingScope,
|
||||
BroadcasterNotStreaming,
|
||||
Ratelimited,
|
||||
|
||||
// The error message is forwarded directly from the Twitch API
|
||||
Forwarded,
|
||||
};
|
||||
|
||||
class IHelix
|
||||
{
|
||||
public:
|
||||
@@ -832,6 +860,13 @@ public:
|
||||
ResultCallback<std::vector<HelixVip>> successCallback,
|
||||
FailureCallback<HelixListVIPsError, QString> failureCallback) = 0;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#start-commercial
|
||||
virtual void startCommercial(
|
||||
QString broadcasterID, int length,
|
||||
ResultCallback<HelixStartCommercialResponse> successCallback,
|
||||
FailureCallback<HelixStartCommercialError, QString>
|
||||
failureCallback) = 0;
|
||||
|
||||
virtual void update(QString clientId, QString oauthToken) = 0;
|
||||
|
||||
protected:
|
||||
@@ -1101,6 +1136,13 @@ public:
|
||||
ResultCallback<std::vector<HelixVip>> successCallback,
|
||||
FailureCallback<HelixListVIPsError, QString> failureCallback) final;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#start-commercial
|
||||
void startCommercial(
|
||||
QString broadcasterID, int length,
|
||||
ResultCallback<HelixStartCommercialResponse> successCallback,
|
||||
FailureCallback<HelixStartCommercialError, QString> failureCallback)
|
||||
final;
|
||||
|
||||
void update(QString clientId, QString oauthToken) final;
|
||||
|
||||
static void initialize();
|
||||
|
||||
Reference in New Issue
Block a user