generated from offline-agency/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb84573
commit a47fcb2
Showing
8 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
|
||
namespace OfflineAgency\LaravelEmailChef\Api\Resources; | ||
|
||
use Carbon\Carbon; | ||
use OfflineAgency\LaravelEmailChef\Api\Api; | ||
use OfflineAgency\LaravelEmailChef\Entities\Error; | ||
use OfflineAgency\LaravelEmailChef\Entities\Segments\SegmentCollection; | ||
use OfflineAgency\LaravelEmailChef\Entities\Segments\Segment; | ||
use OfflineAgency\LaravelEmailChef\Entities\Segments\SegmentCount; | ||
use OfflineAgency\LaravelEmailChef\Entities\Segments\ContactsCount; | ||
use OfflineAgency\LaravelEmailChef\Entities\Segments\CreateSegment; | ||
use OfflineAgency\LaravelEmailChef\Entities\Segments\UpdateSegment; | ||
use OfflineAgency\LaravelEmailChef\Entities\Segments\SegmentDeletion; | ||
|
||
class SegmentsApi extends Api | ||
{ | ||
public function getCollection( | ||
string $list_id, | ||
?int $limit, | ||
?int $offset | ||
) { | ||
$response = $this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace OfflineAgency\LaravelEmailChef\Entities\Segments; | ||
|
||
use OfflineAgency\LaravelEmailChef\Entities\AbstractEntity; | ||
|
||
class ContactsCount extends AbstractEntity | ||
{ | ||
public string $match_count; | ||
|
||
public string $total_count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace OfflineAgency\LaravelEmailChef\Entities\Segments; | ||
|
||
use OfflineAgency\LaravelEmailChef\Entities\AbstractEntity; | ||
|
||
class CreateSegment extends AbstractEntity | ||
{ | ||
public object $body; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace OfflineAgency\LaravelEmailChef\Entities\Segments; | ||
|
||
use OfflineAgency\LaravelEmailChef\Entities\AbstractEntity; | ||
|
||
class Segment extends AbstractEntity | ||
{ | ||
public string $id; | ||
|
||
public string $list_id; | ||
|
||
public string $logic; | ||
|
||
public array $condition_groups; | ||
|
||
public string $name; | ||
|
||
public string $description; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace OfflineAgency\LaravelEmailChef\Entities\Segments; | ||
|
||
use OfflineAgency\LaravelEmailChef\Entities\AbstractEntity; | ||
|
||
class SegmentCollection extends AbstractEntity | ||
{ | ||
public string $id; | ||
|
||
public string $name; | ||
|
||
public string $description; | ||
|
||
public string $match_count; | ||
|
||
public string $total_count; | ||
|
||
public $last_refresh_time; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace OfflineAgency\LaravelEmailChef\Entities\Segments; | ||
|
||
use OfflineAgency\LaravelEmailChef\Entities\AbstractEntity; | ||
|
||
class SegmentCount extends AbstractEntity | ||
{ | ||
public string $totalcount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace OfflineAgency\LaravelEmailChef\Entities\Segments; | ||
|
||
use OfflineAgency\LaravelEmailChef\Entities\AbstractEntity; | ||
|
||
class SegmentDeletion extends AbstractEntity | ||
{ | ||
public string $status; | ||
|
||
public string $id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace OfflineAgency\LaravelEmailChef\Entities\Segments; | ||
|
||
use OfflineAgency\LaravelEmailChef\Entities\AbstractEntity; | ||
|
||
class UpdateSegment extends AbstractEntity | ||
{ | ||
public object $body; | ||
} |