| @@ 15-75 (lines=61) @@ | ||
| 12 | * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT  | 
                                |
| 13 | * @homepage https://github.com/jofner/Twitch-SDK  | 
                                |
| 14 | */  | 
                                |
| 15 | class Block  | 
                                |
| 16 | { | 
                                |
| 17 | /** @var TwitchRequest */  | 
                                |
| 18 | protected $request;  | 
                                |
| 19 | ||
| 20 | const URI_BLOCK_USER = 'users/%s/blocks';  | 
                                |
| 21 | const URI_BLOCK_TARGET = 'users/%s/blocks/%s';  | 
                                |
| 22 | ||
| 23 | /**  | 
                                |
| 24 | * Block constructor  | 
                                |
| 25 | * @param TwitchRequest $request  | 
                                |
| 26 | */  | 
                                |
| 27 | public function __construct(TwitchRequest $request)  | 
                                |
| 28 |     { | 
                                |
| 29 | $this->request = $request;  | 
                                |
| 30 | }  | 
                                |
| 31 | ||
| 32 | /**  | 
                                |
| 33 | * Returns a list of blocks  | 
                                |
| 34 | * - requires scope 'user_blocks_read'  | 
                                |
| 35 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md#get-usersuserblocks  | 
                                |
| 36 | * @param string $user  | 
                                |
| 37 | * @param string $queryString  | 
                                |
| 38 | * @return \stdClass  | 
                                |
| 39 | * @throws TwitchException  | 
                                |
| 40 | */  | 
                                |
| 41 | public function getBlocks($user, $queryString)  | 
                                |
| 42 |     { | 
                                |
| 43 | return $this->request->request(sprintf(self::URI_BLOCK_USER, $user) . $queryString);  | 
                                |
| 44 | }  | 
                                |
| 45 | ||
| 46 | /**  | 
                                |
| 47 | * Adds $target to $user block list  | 
                                |
| 48 | * - requires scope 'user_blocks_edit'  | 
                                |
| 49 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md#put-usersuserblockstarget  | 
                                |
| 50 | * @param string $user  | 
                                |
| 51 | * @param string $target  | 
                                |
| 52 | * @param string $queryString  | 
                                |
| 53 | * @return \stdClass  | 
                                |
| 54 | * @throws TwitchException  | 
                                |
| 55 | */  | 
                                |
| 56 | public function blockTarget($user, $target, $queryString)  | 
                                |
| 57 |     { | 
                                |
| 58 | return $this->request->request(sprintf(self::URI_BLOCK_TARGET, $user, $target) . $queryString, 'PUT');  | 
                                |
| 59 | }  | 
                                |
| 60 | ||
| 61 | /**  | 
                                |
| 62 | * Removes $target from $user block list  | 
                                |
| 63 | * - requires scope 'user_blocks_edit'  | 
                                |
| 64 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md#delete-usersuserblockstarget  | 
                                |
| 65 | * @param string $user  | 
                                |
| 66 | * @param string $target  | 
                                |
| 67 | * @param string $queryString  | 
                                |
| 68 | * @return \stdClass  | 
                                |
| 69 | * @throws TwitchException  | 
                                |
| 70 | */  | 
                                |
| 71 | public function removeTarget($user, $target, $queryString)  | 
                                |
| 72 |     { | 
                                |
| 73 | return $this->request->request(sprintf(self::URI_BLOCK_TARGET, $user, $target) . $queryString, 'DELETE');  | 
                                |
| 74 | }  | 
                                |
| 75 | }  | 
                                |
| 76 | ||
| @@ 15-72 (lines=58) @@ | ||
| 12 | * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT  | 
                                |
| 13 | * @homepage https://github.com/jofner/Twitch-SDK  | 
                                |
| 14 | */  | 
                                |
| 15 | class Subscription  | 
                                |
| 16 | { | 
                                |
| 17 | /** @var TwitchRequest */  | 
                                |
| 18 | protected $request;  | 
                                |
| 19 | ||
| 20 | const URI_CHANNEL_SUBSCRIPTIONS = 'channels/%s/subscriptions';  | 
                                |
| 21 | const URI_CHANNEL_SUBSCRIPTIONS_USER = 'channels/%s/subscriptions/%s';  | 
                                |
| 22 | const URI_USER_SUBSCRIPTIONS_CHANNEL = 'users/%s/subscriptions/%s';  | 
                                |
| 23 | ||
| 24 | public function __construct(TwitchRequest $request)  | 
                                |
| 25 |     { | 
                                |
| 26 | $this->request = $request;  | 
                                |
| 27 | }  | 
                                |
| 28 | ||
| 29 | /**  | 
                                |
| 30 | * @description Returns an array of subscriptions who are subscribed to specified channel  | 
                                |
| 31 | * - requires scope 'channel_subscriptions'  | 
                                |
| 32 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/subscriptions.md#get-channelschannelsubscriptions  | 
                                |
| 33 | * @param string $channel  | 
                                |
| 34 | * @param string $queryString  | 
                                |
| 35 | * @return \stdClass  | 
                                |
| 36 | * @throws TwitchException  | 
                                |
| 37 | */  | 
                                |
| 38 | public function getSubscriptions($channel, $queryString)  | 
                                |
| 39 |     { | 
                                |
| 40 | return $this->request->request(sprintf(self::URI_CHANNEL_SUBSCRIPTIONS, $channel) . $queryString);  | 
                                |
| 41 | }  | 
                                |
| 42 | ||
| 43 | /**  | 
                                |
| 44 | * Returns user object if that user is subscribed  | 
                                |
| 45 | * - requires scope 'channel_check_subscription' for channel  | 
                                |
| 46 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/subscriptions.md#get-channelschannelsubscriptionsuser  | 
                                |
| 47 | * @param string $channel  | 
                                |
| 48 | * @param string $user  | 
                                |
| 49 | * @param string $queryString  | 
                                |
| 50 | * @return \stdClass  | 
                                |
| 51 | * @throws TwitchException  | 
                                |
| 52 | */  | 
                                |
| 53 | public function getSubscribedUser($channel, $user, $queryString)  | 
                                |
| 54 |     { | 
                                |
| 55 | return $this->request->request(sprintf(self::URI_CHANNEL_SUBSCRIPTIONS_USER, $channel, $user) . $queryString);  | 
                                |
| 56 | }  | 
                                |
| 57 | ||
| 58 | /**  | 
                                |
| 59 | * Returns a channel object that user subscribes to  | 
                                |
| 60 | * - requires scope 'user_subscriptions' for user  | 
                                |
| 61 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/subscriptions.md#get-usersusersubscriptionschannel  | 
                                |
| 62 | * @param string $user  | 
                                |
| 63 | * @param string $channel  | 
                                |
| 64 | * @param string $queryString  | 
                                |
| 65 | * @return \stdClass  | 
                                |
| 66 | * @throws TwitchException  | 
                                |
| 67 | */  | 
                                |
| 68 | public function getSubscribedToChannel($user, $channel, $queryString)  | 
                                |
| 69 |     { | 
                                |
| 70 | return $this->request->request(sprintf(self::URI_USER_SUBSCRIPTIONS_CHANNEL, $user, $channel) . $queryString);  | 
                                |
| 71 | }  | 
                                |
| 72 | }  | 
                                |
| 73 | ||