- chrisSun Oct 25 2026 00:09:39 GMT+0000 (Coordinated Universal Time)
let's only pass the
$signedUrland not the array, please
also looking at this
WIP: Upload Endpoint
#38
6 files
+172
-94
| @@ -41,17 +41,17 @@ class Favorite | ||
| 41 | 41 | /** |
| 42 | 42 | * Get specific favorites. |
| 43 | 43 | * |
| 44 | * @param int $id | |
| 44 | * @param array $ids | |
| 45 | 45 | * |
| 46 | 46 | * @return array |
| 47 | 47 | */ |
| 48 | public function get($id = null) | |
| 48 | public function get($ids = null) | |
| 49 | 49 | { |
| 50 | if (! $id) { | |
| 50 | if (! $ids) { | |
| 51 | 51 | return $this->all(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | $ids = is_array($id) ? $id : func_get_args(); | |
| 54 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 55 | 55 | |
| 56 | 56 | foreach ($ids as $id) { |
| 57 | 57 | if (! is_int($id)) { |
| @@ -81,9 +81,9 @@ class Favorite | ||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | * Create folder. | |
| 84 | * Create favorite. | |
| 85 | 85 | * |
| 86 | * @param string $name | |
| 86 | * @param array $data | |
| 87 | 87 | * |
| 88 | 88 | * @return array |
| 89 | 89 | */ |
| @@ -93,10 +93,10 @@ class Favorite | ||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | * Update folder. | |
| 96 | * Update favorite. | |
| 97 | 97 | * |
| 98 | * @param string $name | |
| 99 | 98 | * @param int $id |
| 99 | * @param string $data | |
| 100 | 100 | * |
| 101 | 101 | * @return array |
| 102 | 102 | */ |
| @@ -110,15 +110,15 @@ class Favorite | ||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | * Delete a folder. | |
| 113 | * Delete a favorite. | |
| 114 | 114 | * |
| 115 | * @param int $id | |
| 115 | * @param array $ids | |
| 116 | 116 | * |
| 117 | 117 | * @return null |
| 118 | 118 | */ |
| 119 | public function delete($id) | |
| 119 | public function delete($ids) | |
| 120 | 120 | { |
| 121 | $ids = is_array($id) ? $id : func_get_args(); | |
| 121 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 122 | 122 | |
| 123 | 123 | foreach ($ids as $id) { |
| 124 | 124 | if (! is_int($id)) { |
| @@ -69,6 +69,18 @@ class Folder | ||
| 69 | 69 | return $this->client->request('GET', 'folders', ['folder_ids' => $ids]); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | /** | |
| 73 | * Search for specific folders. | |
| 74 | * | |
| 75 | * @param string $query | |
| 76 | * | |
| 77 | * @return array | |
| 78 | */ | |
| 79 | public function search($query) | |
| 80 | { | |
| 81 | return $this->client->request('POST', 'folders/search', compact('query')); | |
| 82 | } | |
| 83 | ||
| 72 | 84 | /** |
| 73 | 85 | * Get specific folders. |
| 74 | 86 | * |
| @@ -131,15 +143,15 @@ class Folder | ||
| 131 | 143 | /** |
| 132 | 144 | * Delete a folder. |
| 133 | 145 | * |
| 134 | * @param int $id | |
| 146 | * @param array $ids | |
| 135 | 147 | * |
| 136 | 148 | * @return null |
| 137 | 149 | * |
| 138 | 150 | * @throws InvalidFormatException |
| 139 | 151 | */ |
| 140 | public function delete($id) | |
| 152 | public function delete($ids) | |
| 141 | 153 | { |
| 142 | $ids = is_array($id) ? $id : func_get_args(); | |
| 154 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 143 | 155 | |
| 144 | 156 | foreach ($ids as $id) { |
| 145 | 157 | if (! is_int($id)) { |
| @@ -161,30 +173,18 @@ class Folder | ||
| 161 | 173 | return $this->client->request('DELETE', "folders/{$id}"); |
| 162 | 174 | } |
| 163 | 175 | |
| 164 | /** | |
| 165 | * Get specific folders. | |
| 166 | * | |
| 167 | * @param string $query | |
| 168 | * | |
| 169 | * @return array | |
| 170 | */ | |
| 171 | public function search($query) | |
| 172 | { | |
| 173 | return $this->client->request('POST', 'folders/search', compact('query')); | |
| 174 | } | |
| 175 | ||
| 176 | 176 | /** |
| 177 | 177 | * Archive a folder. |
| 178 | 178 | * |
| 179 | * @param int $id | |
| 179 | * @param array $ids | |
| 180 | 180 | * |
| 181 | 181 | * @return array |
| 182 | 182 | * |
| 183 | 183 | * @throws InvalidFormatException |
| 184 | 184 | */ |
| 185 | public function archive($id) | |
| 185 | public function archive($ids) | |
| 186 | 186 | { |
| 187 | $ids = is_array($id) ? $id : func_get_args(); | |
| 187 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 188 | 188 | |
| 189 | 189 | foreach ($ids as $id) { |
| 190 | 190 | if (! is_int($id)) { |
| @@ -205,15 +205,15 @@ class Folder | ||
| 205 | 205 | /** |
| 206 | 206 | * Unarchive a folder. |
| 207 | 207 | * |
| 208 | * @param int $id | |
| 208 | * @param array $ids | |
| 209 | 209 | * |
| 210 | 210 | * @return array |
| 211 | 211 | * |
| 212 | 212 | * @throws InvalidFormatException |
| 213 | 213 | */ |
| 214 | public function unarchive($id) | |
| 214 | public function unarchive($ids) | |
| 215 | 215 | { |
| 216 | $ids = is_array($id) ? $id : func_get_args(); | |
| 216 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 217 | 217 | |
| 218 | 218 | foreach ($ids as $id) { |
| 219 | 219 | if (! is_int($id)) { |
| @@ -234,15 +234,15 @@ class Folder | ||
| 234 | 234 | /** |
| 235 | 235 | * Duplicate a folder. |
| 236 | 236 | * |
| 237 | * @param int $id | |
| 237 | * @param array $ids | |
| 238 | 238 | * |
| 239 | 239 | * @return array |
| 240 | 240 | * |
| 241 | 241 | * @throws InvalidFormatException |
| 242 | 242 | */ |
| 243 | public function duplicate($id): array | |
| 243 | public function duplicate($ids): array | |
| 244 | 244 | { |
| 245 | $ids = is_array($id) ? $id : func_get_args(); | |
| 245 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 246 | 246 | |
| 247 | 247 | foreach ($ids as $id) { |
| 248 | 248 | if (! is_int($id)) { |
| @@ -264,6 +264,7 @@ class Folder | ||
| 264 | 264 | * Add folder to media. |
| 265 | 265 | * |
| 266 | 266 | * @param int $id |
| 267 | * @param string $name | |
| 267 | 268 | * |
| 268 | 269 | * @return array |
| 269 | 270 | * |
| @@ -314,7 +315,7 @@ class Folder | ||
| 314 | 315 | /** |
| 315 | 316 | * Initialize media model. |
| 316 | 317 | * |
| 317 | * @param Meema\MeemaApi\Models\Folder $folder | |
| 318 | * @param Meema\MeemaApi\Models\Tag $tag | |
| 318 | 319 | * |
| 319 | 320 | * @return self |
| 320 | 321 | */ |
| @@ -338,6 +339,8 @@ class Folder | ||
| 338 | 339 | /** |
| 339 | 340 | * Initialize the media model. |
| 340 | 341 | * |
| 342 | * @param int $id | |
| 343 | * | |
| 341 | 344 | * @return Meema\MeemaApi\Models\Media |
| 342 | 345 | */ |
| 343 | 346 | public function media($id = null): Media |
| @@ -350,6 +353,8 @@ class Folder | ||
| 350 | 353 | /** |
| 351 | 354 | * Initialize the tags model. |
| 352 | 355 | * |
| 356 | * @param int $id | |
| 357 | * | |
| 353 | 358 | * @return Meema\MeemaApi\Models\Tag |
| 354 | 359 | */ |
| 355 | 360 | public function tags($id = null): Tag |
| @@ -2,6 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Meema\MeemaApi\Models; |
| 4 | 4 | |
| 5 | use GuzzleHttp\Client as GuzzleClient; | |
| 6 | use GuzzleHttp\Psr7; | |
| 7 | use GuzzleHttp\Psr7\Request; | |
| 5 | 8 | use Meema\MeemaApi\Client; |
| 6 | 9 | use Meema\MeemaApi\Exceptions\InvalidFormatException; |
| 7 | 10 | use Meema\MeemaApi\Response\Response; |
| @@ -46,21 +49,23 @@ class Media | ||
| 46 | 49 | /** |
| 47 | 50 | * Get specific media. |
| 48 | 51 | * |
| 52 | * @param array $ids | |
| 53 | * | |
| 49 | 54 | * @return array |
| 50 | 55 | * |
| 51 | 56 | * @throws InvalidFormatException |
| 52 | 57 | */ |
| 53 | public function get($id = null) | |
| 58 | public function get($ids = null) | |
| 54 | 59 | { |
| 55 | 60 | if ($this->model) { |
| 56 | 61 | return $this->fetchForModel(); |
| 57 | 62 | } |
| 58 | 63 | |
| 59 | if (! $id) { | |
| 64 | if (! $ids) { | |
| 60 | 65 | return $this->all(); |
| 61 | 66 | } |
| 62 | 67 | |
| 63 | $ids = is_array($id) ? $id : func_get_args(); | |
| 68 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 64 | 69 | |
| 65 | 70 | foreach ($ids as $id) { |
| 66 | 71 | if (! is_int($id)) { |
| @@ -71,6 +76,18 @@ class Media | ||
| 71 | 76 | return $this->client->request('GET', 'media', ['media_ids' => $ids]); |
| 72 | 77 | } |
| 73 | 78 | |
| 79 | /** | |
| 80 | * Search for specific media. | |
| 81 | * | |
| 82 | * @param string $query | |
| 83 | * | |
| 84 | * @return array | |
| 85 | */ | |
| 86 | public function search($query) | |
| 87 | { | |
| 88 | return $this->client->request('POST', 'media/search', compact('query')); | |
| 89 | } | |
| 90 | ||
| 74 | 91 | /** |
| 75 | 92 | * Get specific media. |
| 76 | 93 | * |
| @@ -129,15 +146,15 @@ class Media | ||
| 129 | 146 | /** |
| 130 | 147 | * Delete a media. |
| 131 | 148 | * |
| 132 | * @param int $id | |
| 149 | * @param array $ids | |
| 133 | 150 | * |
| 134 | 151 | * @return null |
| 135 | 152 | * |
| 136 | 153 | * @throws InvalidFormatException |
| 137 | 154 | */ |
| 138 | public function delete($id) | |
| 155 | public function delete($ids) | |
| 139 | 156 | { |
| 140 | $ids = is_array($id) ? $id : func_get_args(); | |
| 157 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 141 | 158 | |
| 142 | 159 | foreach ($ids as $id) { |
| 143 | 160 | if (! is_int($id)) { |
| @@ -156,29 +173,80 @@ class Media | ||
| 156 | 173 | } |
| 157 | 174 | |
| 158 | 175 | /** |
| 159 | * Get specific folders. | |
| 176 | * Upload a media file. | |
| 160 | 177 | * |
| 161 | * @param string $query | |
| 178 | * @param string $path | |
| 162 | 179 | * |
| 163 | 180 | * @return array |
| 164 | 181 | */ |
| 165 | public function search($query) | |
| 182 | public function upload($path) | |
| 166 | 183 | { |
| 167 | return $this->client->request('POST', 'media/search', compact('query')); | |
| 184 | $file = fopen($path, 'r'); | |
| 185 | $stream = Psr7\stream_for($file); | |
| 186 | ||
| 187 | $fileName = basename($path); | |
| 188 | $mimeType = mime_content_type($file); | |
| 189 | ||
| 190 | $vaporParams = ['content_type' => $mimeType]; | |
| 191 | ||
| 192 | $signedUrl = $this->client->request('POST', 'vapor/signed-storage-url', $vaporParams); | |
| 193 | ||
| 194 | if (is_array($signedUrl) && $signedUrl['url']) { | |
| 195 | $headers = $signedUrl['headers']; | |
| 196 | unset($headers['Host']); | |
| 197 | ||
| 198 | $this->uploadToS3($signedUrl['url'], $headers, $fileName, $stream); | |
| 199 | ||
| 200 | $uploadData = ['key' => $signedUrl['key'], 'file_name' => $fileName]; | |
| 201 | ||
| 202 | $response = $this->client->request('POST', 'upload', $uploadData); | |
| 203 | } | |
| 204 | ||
| 205 | return $response; | |
| 206 | } | |
| 207 | ||
| 208 | /** | |
| 209 | * Upload the file stream to s3. | |
| 210 | * | |
| 211 | * @param string $signedUrl | |
| 212 | * @param array $headers | |
| 213 | * @param string $fileName | |
| 214 | * @param GuzzleHttp\Psr7 $stream | |
| 215 | * | |
| 216 | * @return void | |
| 217 | */ | |
| 218 | protected function uploadToS3($signedUrl, $headers, $fileName, $stream) | |
| 219 | { | |
| 220 | $client = new GuzzleClient(); | |
| 221 | $request = new Request( | |
| 222 | 'PUT', | |
| 223 | $signedUrl, | |
| 224 | ['headers' => json_encode($headers)], | |
| 225 | new Psr7\MultipartStream( | |
| 226 | [ | |
| 227 | [ | |
| 228 | 'name' => $fileName, | |
| 229 | 'contents' => $stream, | |
| 230 | ], | |
| 231 | ] | |
| 232 | ) | |
| 233 | ); | |
| 234 | ||
| 235 | $client->send($request); | |
| 168 | 236 | } |
| 169 | 237 | |
| 170 | 238 | /** |
| 171 | 239 | * Archive a media. |
| ||
| 172 | 240 | * |
| 173 | * @param int $id | |
| 241 | * @param array $ids | |
| 174 | 242 | * |
| 175 | 243 | * @return array |
| 176 | 244 | * |
| 177 | 245 | * @throws InvalidFormatException |
| 178 | 246 | */ |
| 179 | public function archive($id) | |
| 247 | public function archive($ids) | |
| 180 | 248 | { |
| 181 | $ids = is_array($id) ? $id : func_get_args(); | |
| 249 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 182 | 250 | |
| 183 | 251 | foreach ($ids as $id) { |
| 184 | 252 | if (! is_int($id)) { |
| @@ -199,15 +267,15 @@ class Media | ||
| 199 | 267 | /** |
| 200 | 268 | * Unarchive a media. |
| 201 | 269 | * |
| 202 | * @param int $id | |
| 270 | * @param array $ids | |
| 203 | 271 | * |
| 204 | 272 | * @return array |
| 205 | 273 | * |
| 206 | 274 | * @throws InvalidFormatException |
| 207 | 275 | */ |
| 208 | public function unarchive($id) | |
| 276 | public function unarchive($ids) | |
| 209 | 277 | { |
| 210 | $ids = is_array($id) ? $id : func_get_args(); | |
| 278 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 211 | 279 | |
| 212 | 280 | foreach ($ids as $id) { |
| 213 | 281 | if (! is_int($id)) { |
| @@ -228,15 +296,15 @@ class Media | ||
| 228 | 296 | /** |
| 229 | 297 | * Make a media private. |
| 230 | 298 | * |
| 231 | * @param int $id | |
| 299 | * @param array $ids | |
| 232 | 300 | * |
| 233 | 301 | * @return array |
| 234 | 302 | * |
| 235 | 303 | * @throws InvalidFormatException |
| 236 | 304 | */ |
| 237 | public function makePrivate($id) | |
| 305 | public function makePrivate($ids) | |
| 238 | 306 | { |
| 239 | $ids = is_array($id) ? $id : func_get_args(); | |
| 307 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 240 | 308 | |
| 241 | 309 | foreach ($ids as $id) { |
| 242 | 310 | if (! is_int($id)) { |
| @@ -257,15 +325,15 @@ class Media | ||
| 257 | 325 | /** |
| 258 | 326 | * Make a media public. |
| 259 | 327 | * |
| 260 | * @param int $id | |
| 328 | * @param array $ids | |
| 261 | 329 | * |
| 262 | 330 | * @return array |
| 263 | 331 | * |
| 264 | 332 | * @throws InvalidFormatException |
| 265 | 333 | */ |
| 266 | public function makePublic($id) | |
| 334 | public function makePublic($ids) | |
| 267 | 335 | { |
| 268 | $ids = is_array($id) ? $id : func_get_args(); | |
| 336 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 269 | 337 | |
| 270 | 338 | foreach ($ids as $id) { |
| 271 | 339 | if (! is_int($id)) { |
| @@ -286,15 +354,15 @@ class Media | ||
| 286 | 354 | /** |
| 287 | 355 | * Duplicate a media. |
| 288 | 356 | * |
| 289 | * @param int $id | |
| 357 | * @param array $ids | |
| 290 | 358 | * |
| 291 | 359 | * @return array |
| 292 | 360 | * |
| 293 | 361 | * @throws InvalidFormatException |
| 294 | 362 | */ |
| 295 | public function duplicate($id) | |
| 363 | public function duplicate($ids) | |
| 296 | 364 | { |
| 297 | $ids = is_array($id) ? $id : func_get_args(); | |
| 365 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 298 | 366 | |
| 299 | 367 | foreach ($ids as $id) { |
| 300 | 368 | if (! is_int($id)) { |
| @@ -339,7 +407,7 @@ class Media | ||
| 339 | 407 | /** |
| 340 | 408 | * Fetch the media for the folder. |
| 341 | 409 | * |
| 342 | * @param int $id | |
| 410 | * @param Meema\MeemaApi\Models\Folder $folder | |
| 343 | 411 | * |
| 344 | 412 | * @return self |
| 345 | 413 | */ |
| @@ -353,7 +421,7 @@ class Media | ||
| 353 | 421 | /** |
| 354 | 422 | * Initialize media model. |
| 355 | 423 | * |
| 356 | * @param Meema\MeemaApi\Models\Folder $folder | |
| 424 | * @param Meema\MeemaApi\Models\Tag $tag | |
| 357 | 425 | * |
| 358 | 426 | * @return self |
| 359 | 427 | */ |
| @@ -46,21 +46,21 @@ class Tag | ||
| 46 | 46 | /** |
| 47 | 47 | * Get specific tags. |
| 48 | 48 | * |
| 49 | * @param int $id | |
| 49 | * @param array $ids | |
| 50 | 50 | * |
| 51 | 51 | * @return array |
| 52 | 52 | */ |
| 53 | public function get($id = null): array | |
| 53 | public function get($ids = null): array | |
| 54 | 54 | { |
| 55 | 55 | if ($this->model) { |
| 56 | 56 | return $this->fetchForModel(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | if (! $id) { | |
| 59 | if (! $ids) { | |
| 60 | 60 | return $this->all(); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | $ids = is_array($id) ? $id : func_get_args(); | |
| 63 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 64 | 64 | |
| 65 | 65 | foreach ($ids as $id) { |
| 66 | 66 | if (! is_int($id)) { |
| @@ -90,10 +90,10 @@ class Tag | ||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | * Update folder. | |
| 93 | * Update a tag color. | |
| 94 | 94 | * |
| 95 | * @param string $name | |
| 96 | 95 | * @param int $id |
| 96 | * @param string $color | |
| 97 | 97 | * |
| 98 | 98 | * @return array |
| 99 | 99 | */ |
| @@ -106,22 +106,21 @@ class Tag | ||
| 106 | 106 | $data = [ |
| 107 | 107 | 'color' => $color, |
| 108 | 108 | 'tag_id' => $id, |
| 109 | 'team_id' => 1, | |
| 110 | 109 | ]; |
| 111 | 110 | |
| 112 | 111 | return $this->client->request('PATCH', 'tags/color', $data); |
| 113 | 112 | } |
| 114 | 113 | |
| 115 | 114 | /** |
| 116 | * Delete a folder. | |
| 115 | * Delete tags. | |
| 117 | 116 | * |
| 118 | * @param int $id | |
| 117 | * @param array $ids | |
| 119 | 118 | * |
| 120 | 119 | * @return Response |
| 121 | 120 | */ |
| 122 | public function delete($id) | |
| 121 | public function delete($ids) | |
| 123 | 122 | { |
| 124 | $ids = is_array($id) ? $id : func_get_args(); | |
| 123 | $ids = is_array($ids) ? $ids : func_get_args(); | |
| 125 | 124 | |
| 126 | 125 | foreach ($ids as $id) { |
| 127 | 126 | if (! is_int($id)) { |
| @@ -142,6 +141,8 @@ class Tag | ||
| 142 | 141 | /** |
| 143 | 142 | * Initialize the media model. |
| 144 | 143 | * |
| 144 | * @param int $id | |
| 145 | * | |
| 145 | 146 | * @return Meema\MeemaApi\Models\Media |
| 146 | 147 | */ |
| 147 | 148 | public function media($id = null): Media |
| @@ -154,6 +155,8 @@ class Tag | ||
| 154 | 155 | /** |
| 155 | 156 | * Initialize the folder model. |
| 156 | 157 | * |
| 158 | * @param int $id | |
| 159 | * | |
| 157 | 160 | * @return Meema\MeemaApi\Models\Folder |
| 158 | 161 | */ |
| 159 | 162 | public function folders($id = null): Folder |
| @@ -14,6 +14,17 @@ it('can fetch all folders', function () { | ||
| 14 | 14 | $this->assertTrue(count($folders) > 0); |
| 15 | 15 | }); |
| 16 | 16 | |
| 17 | it('can search a folder', function () { | |
| 18 | $folder = $this->client->folders()->find(1)->toArray(); | |
| 19 | ||
| 20 | $query = $folder['data']['name']; | |
| 21 | ||
| 22 | $folders = $this->client->folders()->search($query); | |
| 23 | ||
| 24 | $this->assertTrue(is_array($folders)); | |
| 25 | $this->assertTrue(str_contains($folders['data'][0]['name'], $query)); | |
| 26 | }); | |
| 27 | ||
| 17 | 28 | it('can fetch specific group of folders', function () { |
| 18 | 29 | $ids = [1, 2, 3]; |
| 19 | 30 | |
| @@ -50,15 +61,6 @@ it('can update a folder', function () { | ||
| 50 | 61 | $this->assertTrue($folders['data']['name'] === $name); |
| 51 | 62 | }); |
| 52 | 63 | |
| 53 | it('can search a folder', function () { | |
| 54 | $query = 'Invoice'; | |
| 55 | ||
| 56 | $folders = $this->client->folders()->search($query); | |
| 57 | ||
| 58 | $this->assertTrue(is_array($folders)); | |
| 59 | $this->assertTrue(str_contains($folders['data'][0]['name'], $query)); | |
| 60 | }); | |
| 61 | ||
| 62 | 64 | it('can archive a folder', function () { |
| 63 | 65 | $folders = $this->client->folders()->archive(1); |
| 64 | 66 | |
| @@ -14,6 +14,16 @@ it('can be fetch all media', function () { | ||
| 14 | 14 | $this->assertTrue(count($media) > 0); |
| 15 | 15 | }); |
| 16 | 16 | |
| 17 | it('can search a media', function () { | |
| 18 | $media = $this->client->media()->find(1)->toArray(); | |
| 19 | $query = $media['data']['name']; | |
| 20 | ||
| 21 | $media = $this->client->media()->search($query); | |
| 22 | ||
| 23 | $this->assertTrue(is_array($media)); | |
| 24 | $this->assertTrue(str_contains($media['data'][0]['name'], $query)); | |
| 25 | }); | |
| 26 | ||
| 17 | 27 | it('can be fetch all media for a tag', function () { |
| 18 | 28 | // 8 is the tag id for images |
| 19 | 29 | $tag = $this->client->tags()->find(8); |
| @@ -61,16 +71,6 @@ it('can update a media', function () { | ||
| 61 | 71 | $this->assertTrue($media['data']['name'] === $name); |
| 62 | 72 | }); |
| 63 | 73 | |
| 64 | it('can search a media', function () { | |
| 65 | $mediaName = $this->client->media()->find(1)->toArray(); | |
| 66 | $query = $mediaName['name']; | |
| 67 | ||
| 68 | $media = $this->client->media()->search($query); | |
| 69 | ||
| 70 | $this->assertTrue(is_array($media)); | |
| 71 | $this->assertTrue(str_contains($media['data'][0]['name'], $query)); | |
| 72 | }); | |
| 73 | ||
| 74 | 74 | it('can archive a media', function () { |
| 75 | 75 | $media = $this->client->media()->archive(1); |
| 76 | 76 | |