ReviewOS

also looking at this

meemalabs/meema-client-php

initialize progress

#1
Merged glennmichael123 wants to merge initial-progress into main
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.

src/Client.phpmodified+2-2
Changes to src/Client.php
@@ -83,8 +83,8 @@ class Client
8383 *
8484 * @return Meema\MeemaApi\Models\Folder
8585 */
86 public function folders($id = null): Folder
86 public function folders(): Folder
8787 {
88 return new Folder($this, $id);
88 return new Folder($this);
8989 }
9090}
src/Models/Folder.phpmodified+33-15
Changes to src/Models/Folder.php
@@ -21,11 +21,9 @@ class Folder
2121 *
2222 * @param Meema\MeemaApi\Client $client
2323 */
24 public function __construct(Client $client, $id)
24 public function __construct(Client $client)
2525 {
2626 $this->client = $client;
27
28 $this->id = $id;
2927 }
3028
3129 /**
@@ -38,6 +36,22 @@ class Folder
3836 return $this->client->request('GET', 'folders');
3937 }
4038
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
4155 /**
4256 * Create folder.
4357 *
@@ -47,7 +61,9 @@ class Folder
4761 */
4862 public function create($name): array
4963 {
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);
5167 }
5268
5369 /**
@@ -58,9 +74,11 @@ class Folder
5874 *
5975 * @return array
6076 */
61 public function update($name): array
77 public function update($id, $name): array
6278 {
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);
6482 }
6583
6684 /**
@@ -68,11 +86,11 @@ class Folder
6886 *
6987 * @param int|array $id
7088 *
71 * @return array
89 * @return null
7290 */
73 public function delete(): array
91 public function delete($id)
7492 {
75 return $this->client->request('DELETE', "folders/{$this->id}");
93 return $this->client->request('DELETE', "folders/{$id}");
7694 }
7795
7896 /**
@@ -80,9 +98,9 @@ class Folder
8098 *
8199 * @return array
82100 */
83 public function archive(): array
101 public function archive($id): array
84102 {
85 return $this->client->request('POST', "folders/{$this->id}/archive");
103 return $this->client->request('POST', "folders/{$id}/archive");
86104 }
87105
88106 /**
@@ -90,9 +108,9 @@ class Folder
90108 *
91109 * @return array
92110 */
93 public function unarchive(): array
111 public function unarchive($id): array
94112 {
95 return $this->client->request('POST', "folders/{$this->id}/unarchive");
113 return $this->client->request('POST', "folders/{$id}/unarchive");
96114 }
97115
98116 /**
@@ -100,8 +118,8 @@ class Folder
100118 *
101119 * @return array
102120 */
103 public function duplicate(): array
121 public function duplicate($id): array
104122 {
105 return $this->client->request('POST', "folders/{$this->id}/duplicate");
123 return $this->client->request('POST', "folders/{$id}/duplicate");
106124 }
107125}