ReviewOS

also looking at this

meemalabs/meema-client-php

Bulk Media

#29
Merged glennmichael123 wants to merge bulk-media into main
2 files +80 -14
src/Models/Folder.phpmodifiedformatting only+2-2
Changes to src/Models/Folder.php
@@ -116,7 +116,7 @@ class Folder
116116 * @return array
117117 */
118118 public function update($id, $name): array
119{
119 {
120120 if (! is_int($id)) {
121121 throw new InvalidFormatException();
122122 }
@@ -170,7 +170,7 @@ class Folder
170170 * @throws InvalidFormatException
171171 */
172172 public function archive($id)
173{
173 {
174174 if (! is_int($id)) {
175175 throw new InvalidFormatException();
176176 }
src/Models/Media.phpmodified+78-12
Changes to src/Models/Media.php
@@ -135,10 +135,21 @@ class Media
135135 */
136136 public function delete($id)
137137 {
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]);
140148 }
141149
150 // If count is equal to 1 get the first element
151 $id = $ids[0];
152
142153 return $this->client->request('DELETE', "media/{$id}", ['media_id' => $id]);
143154 }
144155
@@ -165,10 +176,21 @@ class Media
165176 */
166177 public function archive($id)
167178 {
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 }
170185 }
171186
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
172194 return $this->client->request('POST', "media/{$id}/archive");
173195 }
174196
@@ -183,10 +205,21 @@ class Media
183205 */
184206 public function unarchive($id)
185207 {
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 }
188214 }
189215
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
190223 return $this->client->request('POST', "media/{$id}/unarchive");
191224 }
192225
@@ -201,10 +234,21 @@ class Media
201234 */
202235 public function makePrivate($id)
203236 {
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]);
206247 }
207248
249 // If count is equal to 1 get the first element
250 $id = $ids[0];
251
208252 return $this->client->request('PATCH', "media/{$id}/make-private");
209253 }
210254
@@ -219,10 +263,21 @@ class Media
219263 */
220264 public function makePublic($id)
221265 {
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 }
224272 }
225273
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
226281 return $this->client->request('PATCH', "media/{$id}/make-public");
227282 }
228283
@@ -237,10 +292,21 @@ class Media
237292 */
238293 public function duplicate($id)
239294 {
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 }
242301 }
243302
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
244310 return $this->client->request('POST', "media/{$id}/duplicate");
245311 }
246312