diff --git a/src/Api/Resources/SegmentsApi.php b/src/Api/Resources/SegmentsApi.php new file mode 100644 index 0000000..8546c3d --- /dev/null +++ b/src/Api/Resources/SegmentsApi.php @@ -0,0 +1,128 @@ +get('segments', [ + 'list_id' => $list_id, + 'limit' => $limit, + 'offset' => $offset, + ]); + + if (! $response->success) { + return new Error($response->data); + } + + $getCollection = $response->data; + + return new SegmentCollection($getCollection); + } + + public function getInstance( + string $segment_id + ) + { + $response = $this->get('lists/251338/segments/' . $segment_id); + + if (! $response->success) { + return new Error($response->data); + } + + $getInstance = $response->data; + + return new Segment($getInstance); + } + + public function getCount( + string $list_id + ) + { + $response = $this->get('lists/' . $list_id . '/segments/count?'); + + if (! $response->success) { + return new Error($response->data); + } + + $getCount = $response->data; + + return new SegmentCount($getCount); + } + + public function getContactsCount( + string $segment_id + ) + { + $response = $this->get('segments/' . $segment_id . '/contacts/count'); + + if (! $response->success) { + return new Error($response->data); + } + + $getContactsCount = $response->data; + + return new ContactsCount($$getContactsCount); + } + + public function createInstance( + array $body + ) + { + $response = $this->post('segments ', $body); + + if (! $response->success) { + return new Error($response->data); + } + + $createInstance = $response->data; + + return new CreateSegment($createInstance); + } + + public function updateInstance( + string $segment_id, + array $body + ) + { + $response = $this->put('segments/'. $segment_id, $body); + + if (! $response->success) { + return new Error($response->data); + } + + $updateInstance = $response->data; + + return new UpdateSegment($updateInstance); + } + + public function deleteInstance( + string $segment_id + ) + { + $response = $this->destroy('segments/'. $segment_id); + + if (! $response->success) { + return new Error($response->data); + } + + $deleteInstance = $response->data; + + return new SegmentDeletion($deleteInstance); + } +} diff --git a/src/Entities/Segments/ContactsCount.php b/src/Entities/Segments/ContactsCount.php new file mode 100644 index 0000000..fcec169 --- /dev/null +++ b/src/Entities/Segments/ContactsCount.php @@ -0,0 +1,12 @@ +