1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mozammil\Putio\Endpoints; |
4
|
|
|
|
5
|
|
|
use Mozammil\Putio\Http\Client; |
6
|
|
|
|
7
|
|
|
class Account |
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
|
|
|
* Information about user account. |
23
|
|
|
* subtitle_languages is a list of ISO639-2 codes. |
24
|
|
|
* |
25
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
26
|
|
|
* |
27
|
|
|
* @see https://api.put.io/v2/docs/account.html#get--account-info |
28
|
|
|
* |
29
|
|
|
* @return string |
30
|
|
|
*/ |
31
|
|
|
public function info() |
32
|
|
|
{ |
33
|
|
|
return $this->client->get('account/info'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* User preferences. |
38
|
|
|
* |
39
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
40
|
|
|
* |
41
|
|
|
* @see https://api.put.io/v2/docs/account.html#get--account-settings |
42
|
|
|
* |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
|
|
public function settings() |
46
|
|
|
{ |
47
|
|
|
return $this->client->get('account/settings'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Updates user preferences. Only sent parameters are updated. |
52
|
|
|
* |
53
|
|
|
* @param int $default_download_folder |
54
|
|
|
* @param bool $is_invisible |
55
|
|
|
* @param array $subtitle_languages |
56
|
|
|
* |
57
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
58
|
|
|
* |
59
|
|
|
* @see https://api.put.io/v2/docs/account.html#post--account-settings |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function update( |
64
|
|
|
int $default_download_folder = null, |
65
|
|
|
bool $is_invisible = null, |
66
|
|
|
array $subtitle_languages = [] |
67
|
|
|
) { |
68
|
|
|
$params = []; |
69
|
|
|
|
70
|
|
|
if ($default_download_folder) { |
|
|
|
|
71
|
|
|
$params['default_download_folder'] = $default_download_folder; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
if ($is_invisible) { |
75
|
|
|
$params['is_invisible'] = $is_invisible; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
if (count($subtitle_languages)) { |
79
|
|
|
$params['subtitle_languages'] = implode(',', $subtitle_languages); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $this->client->post('account/settings', [ |
83
|
|
|
'form_params' => $params, |
84
|
|
|
]); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: