-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SESv2 suppressed destination deletion and retrieval methods (#1834)
- Loading branch information
Showing
17 changed files
with
648 additions
and
3 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
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 |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.10-dev" | ||
"dev-master": "1.11-dev" | ||
} | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace AsyncAws\Ses\Enum; | ||
|
||
/** | ||
* The reason that the address was added to the suppression list for your account. The value can be one of the | ||
* following: | ||
* | ||
* - `COMPLAINT` – Amazon SES added an email address to the suppression list for your account because a message sent | ||
* to that address results in a complaint. | ||
* - `BOUNCE` – Amazon SES added an email address to the suppression list for your account because a message sent to | ||
* that address results in a hard bounce. | ||
*/ | ||
final class SuppressionListReason | ||
{ | ||
public const BOUNCE = 'BOUNCE'; | ||
public const COMPLAINT = 'COMPLAINT'; | ||
|
||
public static function exists(string $value): bool | ||
{ | ||
return isset([ | ||
self::BOUNCE => true, | ||
self::COMPLAINT => true, | ||
][$value]); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
src/Service/Ses/src/Input/DeleteSuppressedDestinationRequest.php
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,87 @@ | ||
<?php | ||
|
||
namespace AsyncAws\Ses\Input; | ||
|
||
use AsyncAws\Core\Exception\InvalidArgument; | ||
use AsyncAws\Core\Input; | ||
use AsyncAws\Core\Request; | ||
use AsyncAws\Core\Stream\StreamFactory; | ||
|
||
/** | ||
* A request to remove an email address from the suppression list for your account. | ||
*/ | ||
final class DeleteSuppressedDestinationRequest extends Input | ||
{ | ||
/** | ||
* The suppressed email destination to remove from the account suppression list. | ||
* | ||
* @required | ||
* | ||
* @var string|null | ||
*/ | ||
private $emailAddress; | ||
|
||
/** | ||
* @param array{ | ||
* EmailAddress?: string, | ||
* '@region'?: string|null, | ||
* } $input | ||
*/ | ||
public function __construct(array $input = []) | ||
{ | ||
$this->emailAddress = $input['EmailAddress'] ?? null; | ||
parent::__construct($input); | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* EmailAddress?: string, | ||
* '@region'?: string|null, | ||
* }|DeleteSuppressedDestinationRequest $input | ||
*/ | ||
public static function create($input): self | ||
{ | ||
return $input instanceof self ? $input : new self($input); | ||
} | ||
|
||
public function getEmailAddress(): ?string | ||
{ | ||
return $this->emailAddress; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public function request(): Request | ||
{ | ||
// Prepare headers | ||
$headers = [ | ||
'Content-Type' => 'application/json', | ||
'Accept' => 'application/json', | ||
]; | ||
|
||
// Prepare query | ||
$query = []; | ||
|
||
// Prepare URI | ||
$uri = []; | ||
if (null === $v = $this->emailAddress) { | ||
throw new InvalidArgument(\sprintf('Missing parameter "EmailAddress" for "%s". The value cannot be null.', __CLASS__)); | ||
} | ||
$uri['EmailAddress'] = $v; | ||
$uriString = '/v2/email/suppression/addresses/' . rawurlencode($uri['EmailAddress']); | ||
|
||
// Prepare Body | ||
$body = ''; | ||
|
||
// Return the Request | ||
return new Request('DELETE', $uriString, $query, $headers, StreamFactory::create($body)); | ||
} | ||
|
||
public function setEmailAddress(?string $value): self | ||
{ | ||
$this->emailAddress = $value; | ||
|
||
return $this; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
src/Service/Ses/src/Input/GetSuppressedDestinationRequest.php
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,87 @@ | ||
<?php | ||
|
||
namespace AsyncAws\Ses\Input; | ||
|
||
use AsyncAws\Core\Exception\InvalidArgument; | ||
use AsyncAws\Core\Input; | ||
use AsyncAws\Core\Request; | ||
use AsyncAws\Core\Stream\StreamFactory; | ||
|
||
/** | ||
* A request to retrieve information about an email address that's on the suppression list for your account. | ||
*/ | ||
final class GetSuppressedDestinationRequest extends Input | ||
{ | ||
/** | ||
* The email address that's on the account suppression list. | ||
* | ||
* @required | ||
* | ||
* @var string|null | ||
*/ | ||
private $emailAddress; | ||
|
||
/** | ||
* @param array{ | ||
* EmailAddress?: string, | ||
* '@region'?: string|null, | ||
* } $input | ||
*/ | ||
public function __construct(array $input = []) | ||
{ | ||
$this->emailAddress = $input['EmailAddress'] ?? null; | ||
parent::__construct($input); | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* EmailAddress?: string, | ||
* '@region'?: string|null, | ||
* }|GetSuppressedDestinationRequest $input | ||
*/ | ||
public static function create($input): self | ||
{ | ||
return $input instanceof self ? $input : new self($input); | ||
} | ||
|
||
public function getEmailAddress(): ?string | ||
{ | ||
return $this->emailAddress; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public function request(): Request | ||
{ | ||
// Prepare headers | ||
$headers = [ | ||
'Content-Type' => 'application/json', | ||
'Accept' => 'application/json', | ||
]; | ||
|
||
// Prepare query | ||
$query = []; | ||
|
||
// Prepare URI | ||
$uri = []; | ||
if (null === $v = $this->emailAddress) { | ||
throw new InvalidArgument(\sprintf('Missing parameter "EmailAddress" for "%s". The value cannot be null.', __CLASS__)); | ||
} | ||
$uri['EmailAddress'] = $v; | ||
$uriString = '/v2/email/suppression/addresses/' . rawurlencode($uri['EmailAddress']); | ||
|
||
// Prepare Body | ||
$body = ''; | ||
|
||
// Return the Request | ||
return new Request('GET', $uriString, $query, $headers, StreamFactory::create($body)); | ||
} | ||
|
||
public function setEmailAddress(?string $value): self | ||
{ | ||
$this->emailAddress = $value; | ||
|
||
return $this; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Service/Ses/src/Result/DeleteSuppressedDestinationResponse.php
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 AsyncAws\Ses\Result; | ||
|
||
use AsyncAws\Core\Result; | ||
|
||
/** | ||
* An HTTP 200 response if the request succeeds, or an error message if the request fails. | ||
*/ | ||
class DeleteSuppressedDestinationResponse extends Result | ||
{ | ||
} |
53 changes: 53 additions & 0 deletions
53
src/Service/Ses/src/Result/GetSuppressedDestinationResponse.php
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,53 @@ | ||
<?php | ||
|
||
namespace AsyncAws\Ses\Result; | ||
|
||
use AsyncAws\Core\Response; | ||
use AsyncAws\Core\Result; | ||
use AsyncAws\Ses\ValueObject\SuppressedDestination; | ||
use AsyncAws\Ses\ValueObject\SuppressedDestinationAttributes; | ||
|
||
/** | ||
* Information about the suppressed email address. | ||
*/ | ||
class GetSuppressedDestinationResponse extends Result | ||
{ | ||
/** | ||
* An object containing information about the suppressed email address. | ||
* | ||
* @var SuppressedDestination | ||
*/ | ||
private $suppressedDestination; | ||
|
||
public function getSuppressedDestination(): SuppressedDestination | ||
{ | ||
$this->initialize(); | ||
|
||
return $this->suppressedDestination; | ||
} | ||
|
||
protected function populateResult(Response $response): void | ||
{ | ||
$data = $response->toArray(); | ||
|
||
$this->suppressedDestination = $this->populateResultSuppressedDestination($data['SuppressedDestination']); | ||
} | ||
|
||
private function populateResultSuppressedDestination(array $json): SuppressedDestination | ||
{ | ||
return new SuppressedDestination([ | ||
'EmailAddress' => (string) $json['EmailAddress'], | ||
'Reason' => (string) $json['Reason'], | ||
'LastUpdateTime' => /** @var \DateTimeImmutable $d */ $d = \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $json['LastUpdateTime'])), | ||
'Attributes' => empty($json['Attributes']) ? null : $this->populateResultSuppressedDestinationAttributes($json['Attributes']), | ||
]); | ||
} | ||
|
||
private function populateResultSuppressedDestinationAttributes(array $json): SuppressedDestinationAttributes | ||
{ | ||
return new SuppressedDestinationAttributes([ | ||
'MessageId' => isset($json['MessageId']) ? (string) $json['MessageId'] : null, | ||
'FeedbackId' => isset($json['FeedbackId']) ? (string) $json['FeedbackId'] : null, | ||
]); | ||
} | ||
} |
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
Oops, something went wrong.