also looking at this
Teams model
#12
3 files
+130
-1
| @@ -6,6 +6,7 @@ use Dotenv\Dotenv; | ||
| 6 | 6 | use GuzzleHttp\Client as GuzzleClient; |
| 7 | 7 | use Meema\MeemaApi\Models\Folder; |
| 8 | 8 | use Meema\MeemaApi\Models\Media; |
| 9 | use Meema\MeemaApi\Models\Team; | |
| 9 | 10 | |
| 10 | 11 | class Client |
| 11 | 12 | { |
| @@ -105,4 +106,14 @@ class Client | ||
| 105 | 106 | { |
| 106 | 107 | return new Media($this); |
| 107 | 108 | } |
| 109 | ||
| 110 | /** | |
| 111 | * Initialize the team model. | |
| 112 | * | |
| 113 | * @return Meema\MeemaApi\Models\Team | |
| 114 | */ | |
| 115 | public function teams(): Team | |
| 116 | { | |
| 117 | return new Team($this); | |
| 118 | } | |
| 108 | 119 | } |
| @@ -0,0 +1,118 @@ | ||
| 1 | <?php | |
| 2 | ||
| 3 | namespace Meema\MeemaApi\Models; | |
| 4 | ||
| 5 | use Meema\MeemaApi\Client; | |
| 6 | use Meema\MeemaApi\Response\Response; | |
| 7 | ||
| 8 | class Team | |
| 9 | { | |
| 10 | /** | |
| 11 | * @var Meema\MeemaApi\Client | |
| 12 | */ | |
| 13 | protected $client; | |
| 14 | ||
| 15 | /** | |
| 16 | * Construct Folder model. | |
| 17 | * | |
| 18 | * @param Meema\MeemaApi\Client $client | |
| 19 | * @param int $teamId | |
| 20 | */ | |
| 21 | public function __construct(Client $client) | |
| 22 | { | |
| 23 | $this->client = $client; | |
| 24 | } | |
| 25 | ||
| 26 | /** | |
| 27 | * List all teams. | |
| 28 | * | |
| 29 | * @return array | |
| 30 | */ | |
| 31 | public function all(): array | |
| 32 | { | |
| 33 | return $this->client->request('GET', 'teams'); | |
| 34 | } | |
| 35 | ||
| 36 | /** | |
| 37 | * Get specific teams. | |
| 38 | * | |
| 39 | * @param int $id | |
| 40 | * | |
| 41 | * @return array | |
| 42 | */ | |
| 43 | public function get($id = null) | |
| 44 | { | |
| 45 | if (! $id) { | |
| 46 | return $this->all(); | |
| 47 | } | |
| 48 | ||
| 49 | $ids = is_array($id) ? $id : func_get_args(); | |
| 50 | ||
| 51 | return $this->client->request('GET', 'teams', ['team_ids' => $ids]); | |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Get specific teams. | |
| 56 | * | |
| 57 | * @param int $id | |
| 58 | * | |
| 59 | * @return array | |
| 60 | */ | |
| 61 | public function find($id) | |
| 62 | { | |
| 63 | $response = $this->client->request('GET', "teams/${id}"); | |
| 64 | ||
| 65 | return new Response($this, $response); | |
| 66 | } | |
| 67 | ||
| 68 | /** | |
| 69 | * Create folder. | |
| 70 | * | |
| 71 | * @param string $name | |
| 72 | * | |
| 73 | * @return array | |
| 74 | */ | |
| 75 | public function create($data) | |
| 76 | { | |
| 77 | return $this->client->request('POST', 'teams', $data); | |
| 78 | } | |
| 79 | ||
| 80 | /** | |
| 81 | * Update folder. | |
| 82 | * | |
| 83 | * @param string $name | |
| 84 | * @param int $id | |
| 85 | * | |
| 86 | * @return array | |
| 87 | */ | |
| 88 | public function update($id, $name): array | |
| 89 | { | |
| 90 | $name = is_array($name) ? $name : compact('name'); | |
| 91 | ||
| 92 | return $this->client->request('PATCH', "teams/{$id}", $name); | |
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * Delete a folder. | |
| 97 | * | |
| 98 | * @param int $id | |
| 99 | * | |
| 100 | * @return null | |
| 101 | */ | |
| 102 | public function delete($id) | |
| 103 | { | |
| 104 | return $this->client->request('DELETE', "teams/{$id}"); | |
| 105 | } | |
| 106 | ||
| 107 | /** | |
| 108 | * Delete a folder. | |
| 109 | * | |
| 110 | * @param int $id | |
| 111 | * | |
| 112 | * @return null | |
| 113 | */ | |
| 114 | public function toggleMediaRecognition($id, $status) | |
| 115 | { | |
| 116 | return $this->client->request('POST', "teams/{$id}/toggle-media-recognition", compact('status')); | |
| 117 | } | |
| 118 | } | |