also looking at this
Bulk Media
#29
2 files
+80
-14
| @@ -116,7 +116,7 @@ class Folder | ||
| 116 | 116 | * @return array |
| 117 | 117 | */ |
| 118 | 118 | public function update($id, $name): array |
| 119 | { | |
| 119 | { | |
| 120 | 120 | if (! is_int($id)) { |
| 121 | 121 | throw new InvalidFormatException(); |
| 122 | 122 | } |
| @@ -170,7 +170,7 @@ class Folder | ||
| 170 | 170 | * @throws InvalidFormatException |
| 171 | 171 | */ |
| 172 | 172 | public function archive($id) |
| 173 | { | |
| 173 | { | |
| 174 | 174 | if (! is_int($id)) { |
| 175 | 175 | throw new InvalidFormatException(); |
| 176 | 176 | } |
| @@ -135,10 +135,21 @@ class Media | ||
| 135 | 135 | */ |
| 136 | 136 | public function delete($id) |
| 137 | 137 | { |
| 138 | if (! is_int($id)) { | |
| 139 | throw new InvalidFormatException(); | |
| 138 | $ids = is_array($id) ? $id : func_get_args(); | |
| 139 | ||
| 140 | foreach ($ids as $id) { | |
| 141 | if (! is_int($id)) { | |
| 142 | throw new InvalidFormatException(); | |
| 143 | } | |
| 144 | } | |
| 145 | ||
| 146 | if (count($ids) > 1) { | |
| 147 | return $this->client->request('POST', 'bulk/media/delete', ['media_ids' => $ids]); | |
| 140 | 148 | } |
| 141 | 149 | |
| 150 | // If count is equal to 1 get the first element | |
| 151 | $id = $ids[0]; | |
| 152 | ||
| 142 | 153 | return $this->client->request('DELETE', "media/{$id}", ['media_id' => $id]); |
| 143 | 154 | } |
| 144 | 155 | |
| @@ -165,10 +176,21 @@ class Media | ||
| 165 | 176 | */ |
| 166 | 177 | public function archive($id) |
| 167 | 178 | { |
| 168 | if (! is_int($id)) { | |
| 169 | throw new InvalidFormatException(); | |
| 179 | $ids = is_array($id) ? $id : func_get_args(); | |
| 180 | ||
| 181 | foreach ($ids as $id) { | |
| 182 | if (! is_int($id)) { | |
| 183 | throw new InvalidFormatException(); | |
| 184 | } | |
| 170 | 185 | } |
| 171 | 186 | |
| 187 | if (count($ids) > 1) { | |
| 188 | return $this->client->request('POST', 'bulk/media/archive', ['media_ids' => $ids]); | |
| 189 | } | |
| 190 | ||
| 191 | // If count is equal to 1 get the first element | |
| 192 | $id = $ids[0]; | |
| 193 | ||
| 172 | 194 | return $this->client->request('POST', "media/{$id}/archive"); |
| 173 | 195 | } |
| 174 | 196 | |
| @@ -183,10 +205,21 @@ class Media | ||
| 183 | 205 | */ |
| 184 | 206 | public function unarchive($id) |
| 185 | 207 | { |
| 186 | if (! is_int($id)) { | |
| 187 | throw new InvalidFormatException(); | |
| 208 | $ids = is_array($id) ? $id : func_get_args(); | |
| 209 | ||
| 210 | foreach ($ids as $id) { | |
| 211 | if (! is_int($id)) { | |
| 212 | throw new InvalidFormatException(); | |
| 213 | } | |
| 188 | 214 | } |
| 189 | 215 | |
| 216 | if (count($ids) > 1) { | |
| 217 | return $this->client->request('POST', 'bulk/media/unarchive', ['media_ids' => $ids]); | |
| 218 | } | |
| 219 | ||
| 220 | // If count is equal to 1 get the first element | |
| 221 | $id = $ids[0]; | |
| 222 | ||
| 190 | 223 | return $this->client->request('POST', "media/{$id}/unarchive"); |
| 191 | 224 | } |
| 192 | 225 | |
| @@ -201,10 +234,21 @@ class Media | ||
| 201 | 234 | */ |
| 202 | 235 | public function makePrivate($id) |
| 203 | 236 | { |
| 204 | if (! is_int($id)) { | |
| 205 | throw new InvalidFormatException(); | |
| 237 | $ids = is_array($id) ? $id : func_get_args(); | |
| 238 | ||
| 239 | foreach ($ids as $id) { | |
| 240 | if (! is_int($id)) { | |
| 241 | throw new InvalidFormatException(); | |
| 242 | } | |
| 243 | } | |
| 244 | ||
| 245 | if (count($ids) > 1) { | |
| 246 | return $this->client->request('POST', 'bulk/media/make-private', ['media_ids' => $ids]); | |
| 206 | 247 | } |
| 207 | 248 | |
| 249 | // If count is equal to 1 get the first element | |
| 250 | $id = $ids[0]; | |
| 251 | ||
| 208 | 252 | return $this->client->request('PATCH', "media/{$id}/make-private"); |
| 209 | 253 | } |
| 210 | 254 | |
| @@ -219,10 +263,21 @@ class Media | ||
| 219 | 263 | */ |
| 220 | 264 | public function makePublic($id) |
| 221 | 265 | { |
| 222 | if (! is_int($id)) { | |
| 223 | throw new InvalidFormatException(); | |
| 266 | $ids = is_array($id) ? $id : func_get_args(); | |
| 267 | ||
| 268 | foreach ($ids as $id) { | |
| 269 | if (! is_int($id)) { | |
| 270 | throw new InvalidFormatException(); | |
| 271 | } | |
| 224 | 272 | } |
| 225 | 273 | |
| 274 | if (count($ids) > 1) { | |
| 275 | return $this->client->request('POST', 'bulk/media/make-public', ['media_ids' => $ids]); | |
| 276 | } | |
| 277 | ||
| 278 | // If count is equal to 1 get the first element | |
| 279 | $id = $ids[0]; | |
| 280 | ||
| 226 | 281 | return $this->client->request('PATCH', "media/{$id}/make-public"); |
| 227 | 282 | } |
| 228 | 283 | |
| @@ -237,10 +292,21 @@ class Media | ||
| 237 | 292 | */ |
| 238 | 293 | public function duplicate($id) |
| 239 | 294 | { |
| 240 | if (! is_int($id)) { | |
| 241 | throw new InvalidFormatException(); | |
| 295 | $ids = is_array($id) ? $id : func_get_args(); | |
| 296 | ||
| 297 | foreach ($ids as $id) { | |
| 298 | if (! is_int($id)) { | |
| 299 | throw new InvalidFormatException(); | |
| 300 | } | |
| 242 | 301 | } |
| 243 | 302 | |
| 303 | if (count($ids) > 1) { | |
| 304 | return $this->client->request('POST', 'bulk/media/duplicate', ['media_ids' => $ids]); | |
| 305 | } | |
| 306 | ||
| 307 | // If count is equal to 1 get the first element | |
| 308 | $id = $ids[0]; | |
| 309 | ||
| 244 | 310 | return $this->client->request('POST', "media/{$id}/duplicate"); |
| 245 | 311 | } |
| 246 | 312 | |