Skip to content

Commit

Permalink
Merge pull request #1 from own3d/update-endpoints
Browse files Browse the repository at this point in the history
Update endpoints
  • Loading branch information
erwinweber96 authored May 23, 2022
2 parents 883fdaa + d183613 commit c82954c
Show file tree
Hide file tree
Showing 9 changed files with 401 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use romanzipp\Twitch\Objects\Paginator;
use romanzipp\Twitch\Result;

trait ChannelPoints
trait ChannelPointsTrait
{
use AbstractValidationTrait;
use AbstractOperationsTrait;
Expand Down
62 changes: 62 additions & 0 deletions src/Concerns/Api/ChannelsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace romanzipp\Twitch\Concerns\Api;

use romanzipp\Twitch\Concerns\Operations\AbstractOperationsTrait;
use romanzipp\Twitch\Concerns\Operations\AbstractValidationTrait;
use romanzipp\Twitch\Result;

trait ChannelsTrait
{
use AbstractValidationTrait;
use AbstractOperationsTrait;

/**
* Gets channel information for users.
*
* @see https://dev.twitch.tv/docs/api/reference/#get-channel-information
*
* @param array<string, mixed> $parameters
*
* @return \romanzipp\Twitch\Result
*/
public function getChannels(array $parameters = []): Result
{
$this->validateAnyRequired($parameters, ['broadcaster_id']);

return $this->get('channels', $parameters);
}

/**
* Modifies channel information for users.
*
* @see https://dev.twitch.tv/docs/api/reference/#modify-channel-information
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $body
*
* @return \romanzipp\Twitch\Result
*/
public function updateChannels(array $parameters = [], array $body = []): Result
{
$this->validateAnyRequired($parameters, ['broadcaster_id']);

return $this->patch('channels', $parameters, null, $body);
}

/**
* Gets a list of users who have editor permissions for a specific channel.
*
* @see https://dev.twitch.tv/docs/api/reference#get-channel-editors
*
* @param array<string, mixed> $parameters
*
* @return \romanzipp\Twitch\Result
*/
public function getChannelEditors(array $parameters = []): Result
{
$this->validateAnyRequired($parameters, ['broadcaster_id']);

return $this->patch('channels/editors', $parameters);
}
}
33 changes: 33 additions & 0 deletions src/Concerns/Api/ChatTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,37 @@ public function getGlobalChatBadges(): Result
{
return $this->get('chat/badges/global');
}

/**
* Gets the broadcaster’s chat settings.
*
* @see https://dev.twitch.tv/docs/api/reference#get-chat-settings
*
* @param array<string, mixed> $parameters
*
* @return \romanzipp\Twitch\Result
*/
public function getChatSettings(array $parameters = []): Result
{
$this->validateRequired($parameters, ['broadcaster_id']);

return $this->get('chat/settings', $parameters);
}

/**
* https://dev.twitch.tv/docs/api/reference#update-chat-settings.
*
* @see Updates the broadcaster’s chat settings.
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $body
*
* @return \romanzipp\Twitch\Result
*/
public function updateChatSettings(array $parameters, array $body = []): Result
{
$this->validateRequired($parameters, ['broadcaster_id', 'moderator_id']);

return $this->patch('chat/settings', $parameters, null, $body);
}
}
17 changes: 17 additions & 0 deletions src/Concerns/Api/EntitlementsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ trait EntitlementsTrait
* @param array<string, mixed> $parameters
*
* @return \romanzipp\Twitch\Result Result instance
*
* @deprecated since 2021‑02‑26 "Removed the “Create Entitlement Grants Upload URL” Twitch API endpoint associated with a previous version of Twitch Drops."
*/
public function createEntitlementUrl(array $parameters = []): Result
{
Expand Down Expand Up @@ -73,4 +75,19 @@ public function redeemEntitlementsCode(array $parameters = []): Result
{
return $this->post('entitlements/code', $parameters);
}

/**
* Updates the fulfillment status on a set of Drops entitlements, specified by their entitlement IDs.
*
* @see https://dev.twitch.tv/docs/api/reference#update-drops-entitlements
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $body
*
* @return \romanzipp\Twitch\Result
*/
public function updateDropsEntitlements(array $parameters = [], array $body = []): Result
{
return $this->patch('entitlements/drops', $parameters, null, $body);
}
}
30 changes: 30 additions & 0 deletions src/Concerns/Api/GoalsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace romanzipp\Twitch\Concerns\Api;

use romanzipp\Twitch\Concerns\Operations\AbstractOperationsTrait;
use romanzipp\Twitch\Concerns\Operations\AbstractValidationTrait;
use romanzipp\Twitch\Result;

trait GoalsTrait
{
use AbstractOperationsTrait;
use AbstractValidationTrait;

/**
* Gets the broadcaster’s list of active goals. Use this to get the current progress of each goal.
* Alternatively, you can subscribe to receive notifications when a goal makes progress using the channel.goal.progress subscription type. Read more.
*
* @see https://dev.twitch.tv/docs/api/reference#get-creator-goals
*
* @param array<string, mixed> $parameters
*
* @return \romanzipp\Twitch\Result
*/
public function getCreatorGoals(array $parameters = []): Result
{
$this->validateRequired($parameters, ['broadcaster_id']);

return $this->get('goals', $parameters);
}
}
138 changes: 138 additions & 0 deletions src/Concerns/Api/ModerationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function getBannedUsers(array $parameters = [], Paginator $paginator = nu
* @param \romanzipp\Twitch\Objects\Paginator|null $paginator
*
* @return \romanzipp\Twitch\Result
*
* @deprecated since 2022‑03‑18 "Removed documentation for “Get Banned Events” and “Get Moderator Events” Twitch API endpoints."
* @see https://discuss.dev.twitch.tv/t/deprecation-of-twitch-api-event-endpoints-that-supported-websub-based-webhooks/35137
*/
public function getBannedEvents(array $parameters = [], Paginator $paginator = null): Result
{
Expand Down Expand Up @@ -94,11 +97,146 @@ public function getModerators(array $parameters = [], Paginator $paginator = nul
* @param \romanzipp\Twitch\Objects\Paginator|null $paginator
*
* @return \romanzipp\Twitch\Result
*
* @deprecated since 2022‑03‑18 "Removed documentation for “Get Banned Events” and “Get Moderator Events” Twitch API endpoints."
* @see https://discuss.dev.twitch.tv/t/deprecation-of-twitch-api-event-endpoints-that-supported-websub-based-webhooks/35137
*/
public function getModeratorEvents(array $parameters = [], Paginator $paginator = null): Result
{
$this->validateRequired($parameters, ['broadcaster_id']);

return $this->get('moderation/moderators/events', $parameters, $paginator);
}

/**
* Allow or deny a message that was held for review by AutoMod.
* In order to retrieve messages held for review, use the chat_moderator_actions topic via PubSub. For more information about AutoMod, see How to Use AutoMod.
*
* @see https://dev.twitch.tv/docs/api/reference#manage-held-automod-messages
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $body
*
* @return \romanzipp\Twitch\Result
*/
public function manageHeldAutoModMessages(array $parameters = [], array $body = []): Result
{
$this->validateRequired($body, ['user_id', 'msg_id', 'action']);

return $this->post('moderation/automod/message', $parameters, null, $body);
}

/**
* Gets the broadcaster’s AutoMod settings, which are used to automatically block inappropriate or harassing messages from appearing in the broadcaster’s chat room.
*
* @param array<string, mixed> $parameters
*
* @return \romanzipp\Twitch\Result
*/
public function getAutoModSettings(array $parameters = []): Result
{
$this->validateRequired($parameters, ['broadcaster_id', 'moderator_id']);

return $this->get('moderation/automod/settings', $parameters);
}

/**
* Updates the broadcaster’s AutoMod settings, which are used to automatically block inappropriate or harassing messages from appearing in the broadcaster’s chat room.
*
* @see https://dev.twitch.tv/docs/api/reference#update-automod-settings
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $body
*
* @return \romanzipp\Twitch\Result
*/
public function updateAutoModSettings(array $parameters = [], array $body = []): Result
{
return $this->put('moderation/automod/settings', $parameters, null, $body);
}

/**
* Bans a user from participating in a broadcaster’s chat room, or puts them in a timeout. For more information about banning or putting users in a timeout, see Ban a User and Timeout a User.
* If the user is currently in a timeout, you can call this endpoint to change the duration of the timeout or ban them altogether. If the user is currently banned, you cannot call this method to put them in a timeout instead.
* To remove a ban or end a timeout, see Unban user.
*
* @see https://dev.twitch.tv/docs/api/reference#ban-user
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $body
*
* @return \romanzipp\Twitch\Result
*/
public function banUser(array $parameters = [], array $body = []): Result
{
$this->validateRequired($parameters, ['broadcaster_id', 'moderator_id']);

return $this->post('moderation/bans', $parameters, null, $body);
}

/**
* Removes the ban or timeout that was placed on the specified user (see Ban user).
*
* @see https://dev.twitch.tv/docs/api/reference#ban-user
*
* @param array<string, mixed> $parameters
*
* @return \romanzipp\Twitch\Result
*/
public function unbanUser(array $parameters = []): Result
{
$this->validateRequired($parameters, ['broadcaster_id', 'moderator_id', 'user_id']);

return $this->delete('moderation/bans', $parameters);
}

/**
* Gets the broadcaster’s list of non-private, blocked words or phrases. These are the terms that the broadcaster or moderator added manually, or that were denied by AutoMod.
*
* @see https://dev.twitch.tv/docs/api/reference#get-blocked-terms
*
* @param array<string, mixed> $parameters
* @param \romanzipp\Twitch\Objects\Paginator|null $paginator
*
* @return \romanzipp\Twitch\Result
*/
public function getBlockedTerms(array $parameters = [], Paginator $paginator = null): Result
{
$this->validateRequired($parameters, ['broadcaster_id', 'moderator_id']);

return $this->get('moderation/blocked_terms', $parameters, $paginator);
}

/**
* Adds a word or phrase to the broadcaster’s list of blocked terms. These are the terms that broadcasters don’t want used in their chat room.
*
* @see https://dev.twitch.tv/docs/api/reference#add-blocked-term
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $body
*
* @return \romanzipp\Twitch\Result
*/
public function addBlockedTerm(array $parameters = [], array $body = []): Result
{
$this->validateRequired($parameters, ['broadcaster_id', 'moderator_id']);

return $this->post('moderation/blocked_terms', $parameters, null, $body);
}

/**
* Removes the word or phrase that the broadcaster is blocking users from using in their chat room.
*
* @see https://dev.twitch.tv/docs/api/reference#remove-blocked-term
*
* @param array<string, mixed> $parameters
*
* @return \romanzipp\Twitch\Result
*/
public function removeBlockedTerm(array $parameters = []): Result
{
$this->validateRequired($parameters, ['broadcaster_id', 'moderator_id', 'id', 'moderator_id']);

return $this->delete('moderation/blocked_terms', $parameters);
}
}
Loading

0 comments on commit c82954c

Please sign in to comment.