1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mozammil\Putio\Endpoints; |
4
|
|
|
|
5
|
|
|
use Mozammil\Putio\Http\Client; |
6
|
|
|
|
7
|
|
|
class Friends |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* The Http Client. |
11
|
|
|
* |
12
|
|
|
* @var \Mozammil\Putio\Http\Client |
13
|
|
|
*/ |
14
|
|
|
protected $client; |
15
|
|
|
|
16
|
|
|
public function __construct(Client $client) |
17
|
|
|
{ |
18
|
|
|
$this->client = $client; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Lists friends. |
23
|
|
|
* |
24
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
25
|
|
|
* |
26
|
|
|
* @see https://api.put.io/v2/docs/friends.html#get--friends-list |
27
|
|
|
* |
28
|
|
|
* @return string |
29
|
|
|
*/ |
30
|
|
|
public function list() |
31
|
|
|
{ |
32
|
|
|
return $this->client->get('friends/list'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Lists incoming friend requests. |
37
|
|
|
* |
38
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
39
|
|
|
* |
40
|
|
|
* @see https://api.put.io/v2/docs/friends.html#get--friends-waiting-requests |
41
|
|
|
* |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function requests() |
45
|
|
|
{ |
46
|
|
|
return $this->client->get('friends/waiting-requests'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Sends a friend request to the given username. |
51
|
|
|
* |
52
|
|
|
* @param string $username |
53
|
|
|
* |
54
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
55
|
|
|
* |
56
|
|
|
* @see https://api.put.io/v2/docs/friends.html#send-request |
57
|
|
|
* |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function sendRequest(string $username) |
61
|
|
|
{ |
62
|
|
|
return $this->client->post(sprintf('friends/%s/request', $username)); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Approves a friend request from the given username. |
67
|
|
|
* |
68
|
|
|
* @param string $username |
69
|
|
|
* |
70
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
71
|
|
|
* |
72
|
|
|
* @see https://api.put.io/v2/docs/friends.html#approve |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function approveRequest(string $username) |
77
|
|
|
{ |
78
|
|
|
return $this->client->post(sprintf('friends/%s/approve', $username)); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Denies a friend request from the given username. |
83
|
|
|
* |
84
|
|
|
* @param string $username |
85
|
|
|
* |
86
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
87
|
|
|
* |
88
|
|
|
* @see https://api.put.io/v2/docs/friends.html#post--friends--username--deny |
89
|
|
|
* |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
|
|
public function denyRequest(string $username) |
93
|
|
|
{ |
94
|
|
|
return $this->client->post(sprintf('friends/%s/deny', $username)); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Removes friend from friend list. |
99
|
|
|
* Files shared with all friends will be automatically |
100
|
|
|
* removed from old friend’s directory. |
101
|
|
|
* |
102
|
|
|
* @param string $username |
103
|
|
|
* |
104
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
105
|
|
|
* |
106
|
|
|
* @see https://api.put.io/v2/docs/friends.html#unfriend |
107
|
|
|
* |
108
|
|
|
* @return string |
109
|
|
|
*/ |
110
|
|
|
public function unfriend(string $username) |
111
|
|
|
{ |
112
|
|
|
return $this->client->post(sprintf('friends/%s/unfriend', $username)); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|