also looking at this
Bulk folders
#31
3 files
+80
-14
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -137,15 +137,27 @@ class Folder | ||
| 137 | 137 | */ |
| 138 | 138 | public function delete($id) |
| 139 | 139 | { |
| 140 | if (! is_int($id)) { | |
| 141 | throw new InvalidFormatException(); | |
| 140 | $ids = is_array($id) ? $id : func_get_args(); | |
| 141 | ||
| 142 | foreach ($ids as $id) { | |
| 143 | if (! is_int($id)) { | |
| 144 | throw new InvalidFormatException(); | |
| 145 | } | |
| 146 | ||
| 147 | if ($this->model) { | |
| 148 | return $this->deleteFolderFromMedia($this->model->getId(), $id); | |
| 149 | } | |
| 142 | 150 | } |
| 143 | 151 | |
| 144 | if ($this->model) { | |
| 145 | return $this->deleteFolderFromMedia($this->model->getId(), $id); | |
| 152 | if (count($ids) > 1) { | |
| 153 | return $this->client->request('POST', 'bulk/folders/delete', ['folder_ids' => $ids]); | |
| 146 | 154 | } |
| 147 | 155 | |
| 156 | // If count is equal to 1 get the first element | |
| 157 | $id = $ids[0]; | |
| 158 | ||
| 148 | 159 | return $this->client->request('DELETE', "folders/{$id}"); |
| 160 | ||
| 149 | 161 | } |
| 150 | 162 | |
| 151 | 163 | /** |
| @@ -171,10 +183,21 @@ class Folder | ||
| 171 | 183 | */ |
| 172 | 184 | public function archive($id) |
| 173 | 185 | { |
| 174 | if (! is_int($id)) { | |
| 175 | throw new InvalidFormatException(); | |
| 186 | $ids = is_array($id) ? $id : func_get_args(); | |
| 187 | ||
| 188 | foreach ($ids as $id) { | |
| 189 | if (! is_int($id)) { | |
| 190 | throw new InvalidFormatException(); | |
| 191 | } | |
| 176 | 192 | } |
| 177 | 193 | |
| 194 | if (count($ids) > 1) { | |
| 195 | return $this->client->request('POST', 'bulk/folders/archive', ['folder_ids' => $ids]); | |
| 196 | } | |
| 197 | ||
| 198 | // If count is equal to 1 get the first element | |
| 199 | $id = $ids[0]; | |
| 200 | ||
| 178 | 201 | return $this->client->request('POST', "folders/{$id}/archive"); |
| 179 | 202 | } |
| 180 | 203 | |
| @@ -189,10 +212,21 @@ class Folder | ||
| 189 | 212 | */ |
| 190 | 213 | public function unarchive($id) |
| 191 | 214 | { |
| 192 | if (! is_int($id)) { | |
| 193 | throw new InvalidFormatException(); | |
| 215 | $ids = is_array($id) ? $id : func_get_args(); | |
| 216 | ||
| 217 | foreach ($ids as $id) { | |
| 218 | if (! is_int($id)) { | |
| 219 | throw new InvalidFormatException(); | |
| 220 | } | |
| 194 | 221 | } |
| 195 | 222 | |
| 223 | if (count($ids) > 1) { | |
| 224 | return $this->client->request('POST', 'bulk/folders/unarchive', ['folder_ids' => $ids]); | |
| 225 | } | |
| 226 | ||
| 227 | // If count is equal to 1 get the first element | |
| 228 | $id = $ids[0]; | |
| 229 | ||
| 196 | 230 | return $this->client->request('POST', "folders/{$id}/unarchive"); |
| 197 | 231 | } |
| 198 | 232 | |
| @@ -207,10 +241,21 @@ class Folder | ||
| 207 | 241 | */ |
| 208 | 242 | public function duplicate($id): array |
| 209 | 243 | { |
| 210 | if (! is_int($id)) { | |
| 211 | throw new InvalidFormatException(); | |
| 244 | $ids = is_array($id) ? $id : func_get_args(); | |
| 245 | ||
| 246 | foreach ($ids as $id) { | |
| 247 | if (! is_int($id)) { | |
| 248 | throw new InvalidFormatException(); | |
| 249 | } | |
| 212 | 250 | } |
| 213 | 251 | |
| 252 | if (count($ids) > 1) { | |
| 253 | return $this->client->request('POST', 'bulk/folders/duplicate', ['folder_ids' => $ids]); | |
| 254 | } | |
| 255 | ||
| 256 | // If count is equal to 1 get the first element | |
| 257 | $id = $ids[0]; | |
| 258 | ||
| 214 | 259 | return $this->client->request('POST', "folders/{$id}/duplicate"); |
| 215 | 260 | } |
| 216 | 261 | |