also looking at this
Bulk Media
#29
2 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,25 +137,19 @@ class Media | ||
| 137 | 137 | { |
| 138 | 138 | $ids = is_array($id) ? $id : func_get_args(); |
| 139 | 139 | |
| 140 | try { | |
| 141 | foreach ($ids as $id) { | |
| 142 | if (! is_int($id)) { | |
| 143 | throw new InvalidFormatException(); | |
| 144 | } | |
| 140 | foreach ($ids as $id) { | |
| 141 | if (! is_int($id)) { | |
| 142 | throw new InvalidFormatException(); | |
| 145 | 143 | } |
| 144 | } | |
| 146 | 145 | |
| 147 | if (count($ids) > 1) { | |
| 148 | return $this->client->request('POST', 'bulk/media/delete', ['media_ids' => $ids]); | |
| 149 | } | |
| 150 | ||
| 151 | // If count is equal to 1 get the first element | |
| 152 | $id = $ids[0]; | |
| 153 | ||
| 154 | return $this->client->request('DELETE', "media/{$id}", ['media_id' => $id]); | |
| 155 | } catch (InvalidFormatException $e) { | |
| 156 | return $e->getMessage(); | |
| 146 | if (count($ids) > 1) { | |
| 147 | return $this->client->request('POST', 'bulk/media/delete', ['media_ids' => $ids]); | |
| 157 | 148 | } |
| 158 | 149 | |
| 150 | // If count is equal to 1 get the first element | |
| 151 | $id = $ids[0]; | |
| 152 | ||
| 159 | 153 | return $this->client->request('DELETE', "media/{$id}", ['media_id' => $id]); |
| 160 | 154 | } |
| 161 | 155 | |
| @@ -184,25 +178,19 @@ class Media | ||
| 184 | 178 | { |
| 185 | 179 | $ids = is_array($id) ? $id : func_get_args(); |
| 186 | 180 | |
| 187 | try { | |
| 188 | foreach ($ids as $id) { | |
| 189 | if (! is_int($id)) { | |
| 190 | throw new InvalidFormatException(); | |
| 191 | } | |
| 192 | } | |
| 193 | ||
| 194 | if (count($ids) > 1) { | |
| 195 | return $this->client->request('POST', 'bulk/media/archive', ['media_ids' => $ids]); | |
| 181 | foreach ($ids as $id) { | |
| 182 | if (! is_int($id)) { | |
| 183 | throw new InvalidFormatException(); | |
| 196 | 184 | } |
| 185 | } | |
| 197 | 186 | |
| 198 | // If count is equal to 1 get the first element | |
| 199 | $id = $ids[0]; | |
| 200 | ||
| 201 | return $this->client->request('POST', "media/{$id}/archive"); | |
| 202 | } catch (InvalidFormatException $e) { | |
| 203 | return $e->getMessage(); | |
| 187 | if (count($ids) > 1) { | |
| 188 | return $this->client->request('POST', 'bulk/media/archive', ['media_ids' => $ids]); | |
| 204 | 189 | } |
| 205 | 190 | |
| 191 | // If count is equal to 1 get the first element | |
| 192 | $id = $ids[0]; | |
| 193 | ||
| 206 | 194 | return $this->client->request('POST', "media/{$id}/archive"); |
| 207 | 195 | } |
| 208 | 196 | |
| @@ -219,25 +207,19 @@ class Media | ||
| 219 | 207 | { |
| 220 | 208 | $ids = is_array($id) ? $id : func_get_args(); |
| 221 | 209 | |
| 222 | try { | |
| 223 | foreach ($ids as $id) { | |
| 224 | if (! is_int($id)) { | |
| 225 | throw new InvalidFormatException(); | |
| 226 | } | |
| 227 | } | |
| 228 | ||
| 229 | if (count($ids) > 1) { | |
| 230 | return $this->client->request('POST', 'bulk/media/unarchive', ['media_ids' => $ids]); | |
| 210 | foreach ($ids as $id) { | |
| 211 | if (! is_int($id)) { | |
| 212 | throw new InvalidFormatException(); | |
| 231 | 213 | } |
| 214 | } | |
| 232 | 215 | |
| 233 | // If count is equal to 1 get the first element | |
| 234 | $id = $ids[0]; | |
| 235 | ||
| 236 | return $this->client->request('POST', "media/{$id}/unarchive"); | |
| 237 | } catch (InvalidFormatException $e) { | |
| 238 | return $e->getMessage(); | |
| 216 | if (count($ids) > 1) { | |
| 217 | return $this->client->request('POST', 'bulk/media/unarchive', ['media_ids' => $ids]); | |
| 239 | 218 | } |
| 240 | 219 | |
| 220 | // If count is equal to 1 get the first element | |
| 221 | $id = $ids[0]; | |
| 222 | ||
| 241 | 223 | return $this->client->request('POST', "media/{$id}/unarchive"); |
| 242 | 224 | } |
| 243 | 225 | |
| @@ -254,25 +236,19 @@ class Media | ||
| 254 | 236 | { |
| 255 | 237 | $ids = is_array($id) ? $id : func_get_args(); |
| 256 | 238 | |
| 257 | try { | |
| 258 | foreach ($ids as $id) { | |
| 259 | if (! is_int($id)) { | |
| 260 | throw new InvalidFormatException(); | |
| 261 | } | |
| 239 | foreach ($ids as $id) { | |
| 240 | if (! is_int($id)) { | |
| 241 | throw new InvalidFormatException(); | |
| 262 | 242 | } |
| 243 | } | |
| 263 | 244 | |
| 264 | if (count($ids) > 1) { | |
| 265 | return $this->client->request('POST', 'bulk/media/make-private', ['media_ids' => $ids]); | |
| 266 | } | |
| 267 | ||
| 268 | // If count is equal to 1 get the first element | |
| 269 | $id = $ids[0]; | |
| 270 | ||
| 271 | return $this->client->request('PATCH', "media/{$id}/make-private"); | |
| 272 | } catch (InvalidFormatException $e) { | |
| 273 | return $e->getMessage(); | |
| 245 | if (count($ids) > 1) { | |
| 246 | return $this->client->request('POST', 'bulk/media/make-private', ['media_ids' => $ids]); | |
| 274 | 247 | } |
| 275 | 248 | |
| 249 | // If count is equal to 1 get the first element | |
| 250 | $id = $ids[0]; | |
| 251 | ||
| 276 | 252 | return $this->client->request('PATCH', "media/{$id}/make-private"); |
| 277 | 253 | } |
| 278 | 254 | |
| @@ -289,25 +265,19 @@ class Media | ||
| 289 | 265 | { |
| 290 | 266 | $ids = is_array($id) ? $id : func_get_args(); |
| 291 | 267 | |
| 292 | try { | |
| 293 | foreach ($ids as $id) { | |
| 294 | if (! is_int($id)) { | |
| 295 | throw new InvalidFormatException(); | |
| 296 | } | |
| 297 | } | |
| 298 | ||
| 299 | if (count($ids) > 1) { | |
| 300 | return $this->client->request('POST', 'bulk/media/make-public', ['media_ids' => $ids]); | |
| 268 | foreach ($ids as $id) { | |
| 269 | if (! is_int($id)) { | |
| 270 | throw new InvalidFormatException(); | |
| 301 | 271 | } |
| 272 | } | |
| 302 | 273 | |
| 303 | // If count is equal to 1 get the first element | |
| 304 | $id = $ids[0]; | |
| 305 | ||
| 306 | return $this->client->request('PATCH', "media/{$id}/make-public"); | |
| 307 | } catch (InvalidFormatException $e) { | |
| 308 | return $e->getMessage(); | |
| 274 | if (count($ids) > 1) { | |
| 275 | return $this->client->request('POST', 'bulk/media/make-public', ['media_ids' => $ids]); | |
| 309 | 276 | } |
| 310 | 277 | |
| 278 | // If count is equal to 1 get the first element | |
| 279 | $id = $ids[0]; | |
| 280 | ||
| 311 | 281 | return $this->client->request('PATCH', "media/{$id}/make-public"); |
| 312 | 282 | } |
| 313 | 283 | |
| @@ -324,25 +294,19 @@ class Media | ||
| 324 | 294 | { |
| 325 | 295 | $ids = is_array($id) ? $id : func_get_args(); |
| 326 | 296 | |
| 327 | try { | |
| 328 | foreach ($ids as $id) { | |
| 329 | if (! is_int($id)) { | |
| 330 | throw new InvalidFormatException(); | |
| 331 | } | |
| 332 | } | |
| 333 | ||
| 334 | if (count($ids) > 1) { | |
| 335 | return $this->client->request('POST', 'bulk/media/duplicate', ['media_ids' => $ids]); | |
| 297 | foreach ($ids as $id) { | |
| 298 | if (! is_int($id)) { | |
| 299 | throw new InvalidFormatException(); | |
| 336 | 300 | } |
| 301 | } | |
| 337 | 302 | |
| 338 | // If count is equal to 1 get the first element | |
| 339 | $id = $ids[0]; | |
| 340 | ||
| 341 | return $this->client->request('POST', "media/{$id}/duplicate"); | |
| 342 | } catch (InvalidFormatException $e) { | |
| 343 | return $e->getMessage(); | |
| 303 | if (count($ids) > 1) { | |
| 304 | return $this->client->request('POST', 'bulk/media/duplicate', ['media_ids' => $ids]); | |
| 344 | 305 | } |
| 345 | 306 | |
| 307 | // If count is equal to 1 get the first element | |
| 308 | $id = $ids[0]; | |
| 309 | ||
| 346 | 310 | return $this->client->request('POST', "media/{$id}/duplicate"); |
| 347 | 311 | } |
| 348 | 312 | |