1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Telegraph package. |
5
|
|
|
* |
6
|
|
|
* (c) Arthur Edamov <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace Telegraph; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class Account |
19
|
|
|
* |
20
|
|
|
* This object represents a Telegraph account. |
21
|
|
|
* |
22
|
|
|
* @package Telegraph |
23
|
|
|
*/ |
24
|
|
|
class Account |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Account name, helps users with several accounts remember which they are currently using. |
28
|
|
|
* Displayed to the user above the "Edit/Publish" button on Telegra.ph, other users don't see this name. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $shortName; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Default author name used when creating new articles. |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
private $authorName; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Profile link, opened when users click on the author's name below the title. |
43
|
|
|
* Can be any link, not necessarily to a Telegram profile or channel. |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private $authorUrl; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Only returned by the createAccount and revokeAccessToken method. Access token of the Telegraph account. |
51
|
|
|
* |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
private $accessToken; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* URL to authorize a browser on telegra.ph and connect it to a Telegraph account. |
58
|
|
|
* This URL is valid for only one use and for 5 minutes only. |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
private $authUrl; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Number of pages belonging to the Telegraph account. |
66
|
|
|
* |
67
|
|
|
* @var int |
68
|
|
|
*/ |
69
|
|
|
private $pageCount; |
70
|
|
|
|
71
|
|
|
public function __construct(array $data) |
72
|
|
|
{ |
73
|
|
|
$this->shortName = $data['short_name'] ?? ''; |
74
|
|
|
$this->authorName = $data['author_name'] ?? ''; |
75
|
|
|
$this->authorUrl = $data['author_url'] ?? ''; |
76
|
|
|
$this->authUrl = $data['auth_url'] ?? ''; |
77
|
|
|
$this->accessToken = $data['access_token'] ?? ''; |
78
|
|
|
$this->pageCount = $data['page_count'] ?? 0; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function getShortName(): string |
85
|
|
|
{ |
86
|
|
|
return $this->shortName; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
|
|
public function getAuthorName(): string |
93
|
|
|
{ |
94
|
|
|
return $this->authorName; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
|
|
public function getAuthorUrl(): string |
101
|
|
|
{ |
102
|
|
|
return $this->authorUrl; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return string |
107
|
|
|
*/ |
108
|
|
|
public function getAccessToken(): string |
109
|
|
|
{ |
110
|
|
|
return $this->accessToken; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function getAuthUrl(): string |
117
|
|
|
{ |
118
|
|
|
return $this->authUrl; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return int|null |
123
|
|
|
*/ |
124
|
|
|
public function getPageCount(): int |
125
|
|
|
{ |
126
|
|
|
return $this->pageCount; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|