1 | <?php |
||
12 | class Boards extends Provider |
||
13 | { |
||
14 | use Searchable, Followable, HasFollowers; |
||
15 | |||
16 | protected $loginRequired = [ |
||
17 | 'delete', |
||
18 | 'create', |
||
19 | 'follow', |
||
20 | 'unFollow', |
||
21 | ]; |
||
22 | |||
23 | /** |
||
24 | * Get boards for user by username. |
||
25 | * |
||
26 | * @param string $username |
||
27 | * |
||
28 | * @return array|bool |
||
29 | */ |
||
30 | public function forUser($username) |
||
31 | { |
||
32 | return $this->execGetRequest(['username' => $username], UrlHelper::RESOURCE_GET_BOARDS); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Get info about user's board. |
||
37 | * |
||
38 | * @param string $username |
||
39 | * @param string $board |
||
40 | * |
||
41 | * @return array|bool |
||
42 | */ |
||
43 | public function info($username, $board) |
||
44 | { |
||
45 | $requestOptions = [ |
||
46 | 'username' => $username, |
||
47 | 'slug' => $board, |
||
48 | 'field_set_key' => 'detailed', |
||
49 | ]; |
||
50 | |||
51 | return $this->execGetRequest( |
||
52 | $requestOptions, UrlHelper::RESOURCE_GET_BOARDS |
||
53 | ); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Get pins from board by boardId. |
||
58 | * |
||
59 | * @param int $boardId |
||
60 | * @param int $batchesLimit |
||
61 | * |
||
62 | * @return Iterator |
||
63 | */ |
||
64 | public function pins($boardId, $batchesLimit = 0) |
||
65 | { |
||
66 | return (new Pagination($this))->run( |
||
67 | 'getPinsFromBoard', |
||
68 | ['boardId' => $boardId], |
||
69 | $batchesLimit |
||
70 | ); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @param int $boardId |
||
75 | * @param array $bookmarks |
||
76 | * |
||
77 | * @return array|bool |
||
78 | */ |
||
79 | public function getPinsFromBoard($boardId, $bookmarks = []) |
||
80 | { |
||
81 | return $this->execGetRequest( |
||
82 | ['board_id' => $boardId], UrlHelper::RESOURCE_GET_BOARD_FEED, true, $bookmarks |
||
83 | ); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Delete your board by ID. |
||
88 | * |
||
89 | * @param int $boardId |
||
90 | * |
||
91 | * @return bool |
||
92 | */ |
||
93 | public function delete($boardId) |
||
94 | { |
||
95 | return $this->execPostRequest(['board_id' => $boardId], UrlHelper::RESOURCE_DELETE_BOARD); |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Update board info. Gets boardId and an associative array as params. Available keys of the array are: |
||
100 | * 'category', 'description', 'privacy'. |
||
101 | * |
||
102 | * - 'privacy' can be 'public' or 'secret'. 'public' by default. |
||
103 | * - 'category' is 'other' by default. |
||
104 | * |
||
105 | * @param $boardId |
||
106 | * @param $attributes |
||
107 | * @return mixed |
||
108 | */ |
||
109 | public function update($boardId, $attributes) |
||
110 | { |
||
111 | $requestOptions = array_merge( |
||
112 | [ |
||
113 | 'board_id' => $boardId, |
||
114 | 'category' => 'other', |
||
115 | ], $attributes |
||
116 | ); |
||
117 | |||
118 | return $this->execPostRequest($requestOptions, UrlHelper::RESOURCE_UPDATE_BOARD); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Create a new board. |
||
123 | * |
||
124 | * @param string $name |
||
125 | * @param string $description |
||
126 | * @param string $privacy Can be 'public' or 'secret'. 'public' by default. |
||
127 | * |
||
128 | * @return bool |
||
129 | */ |
||
130 | public function create($name, $description, $privacy = 'public') |
||
131 | { |
||
132 | $requestOptions = [ |
||
133 | 'name' => $name, |
||
134 | 'description' => $description, |
||
135 | 'privacy' => $privacy, |
||
136 | ]; |
||
137 | |||
138 | return $this->execPostRequest($requestOptions, UrlHelper::RESOURCE_CREATE_BOARD); |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * Get board followers. |
||
143 | * |
||
144 | * @param $boardId |
||
145 | * @param int $batchesLimit |
||
146 | * |
||
147 | * @return Iterator |
||
148 | */ |
||
149 | public function followers($boardId, $batchesLimit = 0) |
||
155 | |||
156 | /** |
||
157 | * Search scope. |
||
158 | * |
||
159 | * @return string |
||
160 | */ |
||
161 | protected function getScope() |
||
162 | { |
||
165 | |||
166 | protected function getEntityIdName() |
||
170 | |||
171 | /** |
||
172 | * Follow resource. |
||
173 | * |
||
174 | * @return string |
||
175 | */ |
||
176 | protected function getFollowUrl() |
||
180 | |||
181 | /** |
||
182 | * UnFollow resource. |
||
183 | * |
||
184 | * @return string |
||
185 | */ |
||
186 | protected function getUnfFollowUrl() |
||
190 | } |
||
191 |