From c1560eac05dc6f63075b48da8dd63058cad1170d Mon Sep 17 00:00:00 2001 From: Marc Beinder <50760632+onairmarc@users.noreply.github.com> Date: Tue, 3 Dec 2024 19:49:29 -0600 Subject: [PATCH] [Groups] Fix Tags and Tag Groups (#32) --- src/Objects/Groups/Tag.php | 18 +++++++++++++++++- src/Objects/Groups/TagGroup.php | 9 ++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Objects/Groups/Tag.php b/src/Objects/Groups/Tag.php index 2a138a6..4b0f9ef 100644 --- a/src/Objects/Groups/Tag.php +++ b/src/Objects/Groups/Tag.php @@ -21,6 +21,7 @@ class Tag public TagAttributes $attributes; private string $groupId; + private string $tagGroupId; public static function make(string $clientId, string $clientSecret): Tag { @@ -38,6 +39,13 @@ public function forGroupId(string $groupId): static return $this; } + public function forTagGroupId(string $tagGroupId): static + { + $this->tagGroupId = $tagGroupId; + + return $this; + } + public function get(array $query = []): ClientResponse { $http = $this->client() @@ -54,6 +62,14 @@ public function groups(array $query = []): ClientResponse return $this->processResponse($http); } + public function tagGroup(array $query = []): ClientResponse + { + $http = $this->client() + ->get($this->hostname() . TagGroup::TAG_GROUP_ENDPOINT . "/{$this->tagGroupId}/tags", $query); + + return $this->processResponse($http); + } + protected function mapFromPco(ClientResponse $clientResponse): void { $records = objectify($clientResponse->meta->response->json("data", [])); @@ -73,4 +89,4 @@ protected function mapFromPco(ClientResponse $clientResponse): void $clientResponse->data->add($this); } } -} +} \ No newline at end of file diff --git a/src/Objects/Groups/TagGroup.php b/src/Objects/Groups/TagGroup.php index e664a96..d0d929f 100644 --- a/src/Objects/Groups/TagGroup.php +++ b/src/Objects/Groups/TagGroup.php @@ -47,10 +47,9 @@ public function all(array $query = []): ClientResponse public function tags(array $query = []): ClientResponse { - $http = $this->client() - ->get($this->hostname() . self::TAG_GROUP_ENDPOINT . "/" . $this->attributes->tagGroupId . "/tags", $query); - - return $this->processResponse($http); + return Tag::make($this->clientId, $this->clientSecret) + ->forTagGroupId($this->attributes->tagGroupId) + ->tagGroup($query); } protected function mapFromPco(ClientResponse $clientResponse): void @@ -75,4 +74,4 @@ protected function mapFromPco(ClientResponse $clientResponse): void $clientResponse->data->add($this); } } -} +} \ No newline at end of file