also looking at this
Collection response
#52
11 files
+3638
-3582
| @@ -5,9 +5,12 @@ namespace Meema\MeemaApi\Models; | ||
| 5 | 5 | use Meema\MeemaApi\Client; |
| 6 | 6 | use Meema\MeemaApi\Exceptions\InvalidFormatException; |
| 7 | 7 | use Meema\MeemaApi\Response\Response; |
| 8 | use Meema\MeemaApi\Traits\CollectionsResponse; | |
| 8 | 9 | |
| 9 | 10 | class Favorite |
| 10 | 11 | { |
| 12 | use CollectionsResponse; | |
| 13 | ||
| 11 | 14 | /** |
| 12 | 15 | * @var Meema\MeemaApi\Client |
| 13 | 16 | */ |
| @@ -33,7 +36,7 @@ class Favorite | ||
| 33 | 36 | * |
| 34 | 37 | * @return array |
| 35 | 38 | */ |
| 36 | public function all(): array | |
| 39 | public function all() | |
| 37 | 40 | { |
| 38 | 41 | return $this->client->request('GET', 'favorites'); |
| 39 | 42 | } |
| @@ -43,12 +46,12 @@ class Favorite | ||
| 43 | 46 | * |
| 44 | 47 | * @param array $ids |
| 45 | 48 | * |
| 46 | * @return array | |
| 49 | * @return \Illuminate\Support\Collection|array | |
| 47 | 50 | */ |
| 48 | 51 | public function get($ids = null) |
| 49 | 52 | { |
| 50 | 53 | if (! $ids) { |
| 51 | return $this->all(); | |
| 54 | return $this->toCollection($this->all()); | |
| 52 | 55 | } |
| 53 | 56 | |
| 54 | 57 | $ids = is_array($ids) ? $ids : func_get_args(); |
| @@ -59,7 +62,9 @@ class Favorite | ||
| 59 | 62 | } |
| 60 | 63 | } |
| 61 | 64 | |
| 62 | return $this->client->request('GET', 'favorites', ['favorite_ids' => $ids]); | |
| 65 | $response = $this->client->request('GET', 'favorites', ['favorite_ids' => $ids]); | |
| 66 | ||
| 67 | return $this->toCollection($response); | |
| 63 | 68 | } |
| 64 | 69 | |
| 65 | 70 | /** |
| @@ -100,7 +105,7 @@ class Favorite | ||
| 100 | 105 | * |
| 101 | 106 | * @return array |
| 102 | 107 | */ |
| 103 | public function update($id, $data): array | |
| 108 | public function update($id, $data) | |
| 104 | 109 | { |
| 105 | 110 | if (! is_int($id)) { |
| 106 | 111 | throw new InvalidFormatException(); |