1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace jofner\SDK\TwitchTV\Methods; |
4
|
|
|
|
5
|
|
|
use jofner\SDK\TwitchTV\TwitchSDKException; |
6
|
|
|
use jofner\SDK\TwitchTV\TwitchRequest; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Block method class for TwitchTV API SDK for PHP |
10
|
|
|
* |
11
|
|
|
* @author Josef Ohnheiser <[email protected]> |
12
|
|
|
* @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
13
|
|
|
* @homepage https://github.com/jofner/Twitch-SDK |
14
|
|
|
*/ |
15
|
|
View Code Duplication |
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 TwitchSDKException |
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 TwitchSDKException |
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 TwitchSDKException |
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
|
|
|
|