Skip to content

Commit

Permalink
[Groups] Fix Tags and Tag Groups (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
onairmarc authored Dec 4, 2024
1 parent 223f641 commit c1560ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 17 additions & 1 deletion src/Objects/Groups/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Tag

public TagAttributes $attributes;
private string $groupId;
private string $tagGroupId;

public static function make(string $clientId, string $clientSecret): Tag
{
Expand All @@ -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()
Expand All @@ -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", []));
Expand All @@ -73,4 +89,4 @@ protected function mapFromPco(ClientResponse $clientResponse): void
$clientResponse->data->add($this);
}
}
}
}
9 changes: 4 additions & 5 deletions src/Objects/Groups/TagGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -75,4 +74,4 @@ protected function mapFromPco(ClientResponse $clientResponse): void
$clientResponse->data->add($this);
}
}
}
}

0 comments on commit c1560ea

Please sign in to comment.