generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
8faf1b4
commit 50399b3
Showing
3 changed files
with
72 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,54 @@ | ||
<?php | ||
|
||
namespace Spatie\MailcoachSdk\Actions; | ||
|
||
use Spatie\MailcoachSdk\Resources\Suppression; | ||
use Spatie\MailcoachSdk\Support\PaginatedResults; | ||
|
||
trait ManagesSuppressions | ||
{ | ||
/** | ||
* @param array<string, string> $filters | ||
* @return PaginatedResults<Suppression> | ||
*/ | ||
public function suppressions(array $filters = []): PaginatedResults | ||
{ | ||
return PaginatedResults::make( | ||
"suppressions{$this->buildFilterString($filters)}", | ||
Suppression::class, | ||
$this, | ||
); | ||
} | ||
|
||
public function createSuppression(string $email): void | ||
{ | ||
$this->createSuppressions([$email]); | ||
} | ||
|
||
/** @param array<int, string> $emails */ | ||
public function createSuppressions(array $emails): void | ||
{ | ||
$payload = []; | ||
foreach ($emails as $email) { | ||
$payload[] = ['email' => $email]; | ||
} | ||
|
||
$this->post("suppressions", $payload); | ||
} | ||
|
||
public function deleteSuppression(string $email): void | ||
{ | ||
$this->deleteSuppressions([$email]); | ||
} | ||
|
||
/** @param array<int, string> $emails */ | ||
public function deleteSuppressions(array $emails): void | ||
{ | ||
$payload = []; | ||
foreach ($emails as $email) { | ||
$payload[] = ['email' => $email]; | ||
} | ||
|
||
$this->delete("suppressions", $payload); | ||
} | ||
} |
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
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,16 @@ | ||
<?php | ||
|
||
namespace Spatie\MailcoachSdk\Resources; | ||
|
||
class Suppression extends ApiResource | ||
{ | ||
public string $uuid; | ||
|
||
public string $email; | ||
|
||
public string $reason; | ||
|
||
public ?string $createdAt; | ||
|
||
public ?string $updatedAt; | ||
} |