Skip to content

Commit c1560ea

Browse files
authored
[Groups] Fix Tags and Tag Groups (#32)
1 parent 223f641 commit c1560ea

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/Objects/Groups/Tag.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Tag
2121

2222
public TagAttributes $attributes;
2323
private string $groupId;
24+
private string $tagGroupId;
2425

2526
public static function make(string $clientId, string $clientSecret): Tag
2627
{
@@ -38,6 +39,13 @@ public function forGroupId(string $groupId): static
3839
return $this;
3940
}
4041

42+
public function forTagGroupId(string $tagGroupId): static
43+
{
44+
$this->tagGroupId = $tagGroupId;
45+
46+
return $this;
47+
}
48+
4149
public function get(array $query = []): ClientResponse
4250
{
4351
$http = $this->client()
@@ -54,6 +62,14 @@ public function groups(array $query = []): ClientResponse
5462
return $this->processResponse($http);
5563
}
5664

65+
public function tagGroup(array $query = []): ClientResponse
66+
{
67+
$http = $this->client()
68+
->get($this->hostname() . TagGroup::TAG_GROUP_ENDPOINT . "/{$this->tagGroupId}/tags", $query);
69+
70+
return $this->processResponse($http);
71+
}
72+
5773
protected function mapFromPco(ClientResponse $clientResponse): void
5874
{
5975
$records = objectify($clientResponse->meta->response->json("data", []));
@@ -73,4 +89,4 @@ protected function mapFromPco(ClientResponse $clientResponse): void
7389
$clientResponse->data->add($this);
7490
}
7591
}
76-
}
92+
}

src/Objects/Groups/TagGroup.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ public function all(array $query = []): ClientResponse
4747

4848
public function tags(array $query = []): ClientResponse
4949
{
50-
$http = $this->client()
51-
->get($this->hostname() . self::TAG_GROUP_ENDPOINT . "/" . $this->attributes->tagGroupId . "/tags", $query);
52-
53-
return $this->processResponse($http);
50+
return Tag::make($this->clientId, $this->clientSecret)
51+
->forTagGroupId($this->attributes->tagGroupId)
52+
->tagGroup($query);
5453
}
5554

5655
protected function mapFromPco(ClientResponse $clientResponse): void
@@ -75,4 +74,4 @@ protected function mapFromPco(ClientResponse $clientResponse): void
7574
$clientResponse->data->add($this);
7675
}
7776
}
78-
}
77+
}

0 commit comments

Comments
 (0)