also looking at this
initialize progress
#1
17 files
+581
-48
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.
| @@ -21,11 +21,9 @@ class Folder | ||
| 21 | 21 | * |
| 22 | 22 | * @param Meema\MeemaApi\Client $client |
| 23 | 23 | */ |
| 24 | public function __construct(Client $client, $id) | |
| 24 | public function __construct(Client $client) | |
| 25 | 25 | { |
| 26 | 26 | $this->client = $client; |
| 27 | ||
| 28 | $this->id = $id; | |
| 29 | 27 | } |
| 30 | 28 | |
| 31 | 29 | /** |
| @@ -38,6 +36,22 @@ class Folder | ||
| 38 | 36 | return $this->client->request('GET', 'folders'); |
| 39 | 37 | } |
| 40 | 38 | |
| 39 | /** | |
| 40 | * Get specific folders. | |
| 41 | * | |
| 42 | * @return array | |
| 43 | */ | |
| 44 | public function get($id = null) | |
| 45 | { | |
| 46 | if (! $id) { | |
| 47 | return $this->all(); | |
| 48 | } | |
| 49 | ||
| 50 | $ids = is_array($id) ? $id : func_get_args(); | |
| 51 | ||
| 52 | return $this->client->request('GET', 'folders/show', ['folder_ids' => $ids]); | |
| 53 | } | |
| 54 | ||
| 41 | 55 | /** |
| 42 | 56 | * Create folder. |
| 43 | 57 | * |
| @@ -47,7 +61,9 @@ class Folder | ||
| 47 | 61 | */ |
| 48 | 62 | public function create($name): array |
| 49 | 63 | { |
| 50 | return $this->client->request('POST', "folders/{$this->client->getAccessKey()}", compact('name')); | |
| 64 | $name = is_array($name) ? $name : compact('name'); | |
| 65 | ||
| 66 | return $this->client->request('POST', "folders/{$this->client->getAccessKey()}", $name); | |
| 51 | 67 | } |
| 52 | 68 | |
| 53 | 69 | /** |
| @@ -58,9 +74,11 @@ class Folder | ||
| 58 | 74 | * |
| 59 | 75 | * @return array |
| 60 | 76 | */ |
| 61 | public function update($name): array | |
| 77 | public function update($id, $name): array | |
| 62 | 78 | { |
| 63 | return $this->client->request('PATCH', "folders/{$this->id}", compact('name')); | |
| 79 | $name = is_array($name) ? $name : compact('name'); | |
| 80 | ||
| 81 | return $this->client->request('PATCH', "folders/{$id}", $name); | |
| 64 | 82 | } |
| 65 | 83 | |
| 66 | 84 | /** |
| @@ -68,11 +86,11 @@ class Folder | ||
| 68 | 86 | * |
| 69 | 87 | * @param int|array $id |
| 70 | 88 | * |
| 71 | * @return array | |
| 89 | * @return null | |
| 72 | 90 | */ |
| 73 | public function delete(): array | |
| 91 | public function delete($id) | |
| 74 | 92 | { |
| 75 | return $this->client->request('DELETE', "folders/{$this->id}"); | |
| 93 | return $this->client->request('DELETE', "folders/{$id}"); | |
| 76 | 94 | } |
| 77 | 95 | |
| 78 | 96 | /** |
| @@ -80,9 +98,9 @@ class Folder | ||
| 80 | 98 | * |
| 81 | 99 | * @return array |
| 82 | 100 | */ |
| 83 | public function archive(): array | |
| 101 | public function archive($id): array | |
| 84 | 102 | { |
| 85 | return $this->client->request('POST', "folders/{$this->id}/archive"); | |
| 103 | return $this->client->request('POST', "folders/{$id}/archive"); | |
| 86 | 104 | } |
| 87 | 105 | |
| 88 | 106 | /** |
| @@ -90,9 +108,9 @@ class Folder | ||
| 90 | 108 | * |
| 91 | 109 | * @return array |
| 92 | 110 | */ |
| 93 | public function unarchive(): array | |
| 111 | public function unarchive($id): array | |
| 94 | 112 | { |
| 95 | return $this->client->request('POST', "folders/{$this->id}/unarchive"); | |
| 113 | return $this->client->request('POST', "folders/{$id}/unarchive"); | |
| 96 | 114 | } |
| 97 | 115 | |
| 98 | 116 | /** |
| @@ -100,8 +118,8 @@ class Folder | ||
| 100 | 118 | * |
| 101 | 119 | * @return array |
| 102 | 120 | */ |
| 103 | public function duplicate(): array | |
| 121 | public function duplicate($id): array | |
| 104 | 122 | { |
| 105 | return $this->client->request('POST', "folders/{$this->id}/duplicate"); | |
| 123 | return $this->client->request('POST', "folders/{$id}/duplicate"); | |
| 106 | 124 | } |
| 107 | 125 | } |