1 | <?php |
||
13 | class Boards extends FollowableProvider |
||
14 | { |
||
15 | use CanBeDeleted, Searchable, SendsMessages, ResolvesCurrentUsername; |
||
16 | |||
17 | const BOARD_PRIVACY_PUBLIC = 'public'; |
||
18 | const BOARD_PRIVACY_PRIVATE = 'secret'; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $loginRequiredFor = [ |
||
24 | 'my', |
||
25 | 'send', |
||
26 | 'delete', |
||
27 | 'create', |
||
28 | 'follow', |
||
29 | 'unFollow', |
||
30 | ]; |
||
31 | |||
32 | protected $searchScope = 'boards'; |
||
33 | protected $entityIdName = 'board_id'; |
||
34 | protected $followersFor = 'board_id'; |
||
35 | |||
36 | protected $followUrl = UrlBuilder::RESOURCE_FOLLOW_BOARD; |
||
37 | protected $unFollowUrl = UrlBuilder::RESOURCE_UNFOLLOW_BOARD; |
||
38 | protected $deleteUrl = UrlBuilder::RESOURCE_DELETE_BOARD; |
||
39 | protected $followersUrl = UrlBuilder::RESOURCE_BOARD_FOLLOWERS; |
||
40 | |||
41 | protected $messageEntityName = 'board'; |
||
42 | |||
43 | /** |
||
44 | * Get boards for user by username. |
||
45 | * |
||
46 | * @param string $username |
||
47 | * |
||
48 | * @return array |
||
49 | */ |
||
50 | public function forUser($username) |
||
51 | { |
||
52 | $options = [ |
||
53 | 'username' => $username, |
||
54 | 'field_set_key' => 'detailed', |
||
55 | ]; |
||
56 | |||
57 | $result = $this->get($options, UrlBuilder::RESOURCE_GET_BOARDS); |
||
58 | |||
59 | return $result ? : []; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Get boards for current logged in user. |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | public function forMe() |
||
75 | |||
76 | /** |
||
77 | * Get info about user's board. |
||
78 | * |
||
79 | * @param string $username |
||
80 | * @param string $board |
||
81 | * |
||
82 | * @return array|bool |
||
83 | */ |
||
84 | public function info($username, $board) |
||
94 | |||
95 | /** |
||
96 | * @param string $board |
||
97 | * @return string |
||
98 | */ |
||
99 | protected function formatBoardName($board) |
||
103 | |||
104 | /** |
||
105 | * Get pins from board by boardId. |
||
106 | * |
||
107 | * @param int $boardId |
||
108 | * @param int $limit |
||
109 | * |
||
110 | * @return Pagination |
||
111 | */ |
||
112 | public function pins($boardId, $limit = Pagination::DEFAULT_LIMIT) |
||
120 | |||
121 | /** |
||
122 | * Update board info. Gets boardId and an associative array as params. Available keys of the array are: |
||
123 | * 'name', 'category', 'description', 'privacy'. |
||
124 | * |
||
125 | * - 'privacy' can be 'public' or 'secret'. 'public' by default. |
||
126 | * - 'category' is 'other' by default. |
||
127 | * |
||
128 | * @param $boardId |
||
129 | * @param $attributes |
||
130 | * @return mixed |
||
131 | */ |
||
132 | public function update($boardId, $attributes) |
||
143 | |||
144 | /** |
||
145 | * Create a new board. |
||
146 | * |
||
147 | * @param string $name |
||
148 | * @param string $description |
||
149 | * @param string $privacy Can be 'public' or 'secret'. 'public' by default. |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | public function create($name, $description, $privacy = self::BOARD_PRIVACY_PUBLIC) |
||
163 | |||
164 | /** |
||
165 | * Create a new board. |
||
166 | * |
||
167 | * @codeCoverageIgnore |
||
168 | * @param string $name |
||
169 | * @param string $description |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function createPrivate($name, $description) |
||
177 | |||
178 | /** |
||
179 | * Returns title suggestions for pin. |
||
180 | * |
||
181 | * @param string $pinId |
||
182 | * @return array|bool |
||
183 | */ |
||
184 | public function titleSuggestionsFor($pinId) |
||
188 | } |
||
189 |