Skip to content

Commit

Permalink
Update generated code (#1678)
Browse files Browse the repository at this point in the history
update generated code
  • Loading branch information
async-aws-bot authored Mar 6, 2024
1 parent f643994 commit edae510
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## NOT RELEASED

### Added

- AWS api-change: Adds support for providing custom headers within SendEmail and SendBulkEmail for SESv2.

## 1.7.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
"dev-master": "1.8-dev"
}
}
}
5 changes: 2 additions & 3 deletions src/Input/SendEmailRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use AsyncAws\Ses\ValueObject\ListManagementOptions;
use AsyncAws\Ses\ValueObject\Message;
use AsyncAws\Ses\ValueObject\MessageTag;
use AsyncAws\Ses\ValueObject\Template;

/**
* Represents a request to send a single formatted email using Amazon SES. For more information, see the Amazon SES
Expand Down Expand Up @@ -91,8 +90,8 @@ final class SendEmailRequest extends Input
private $feedbackForwardingEmailAddressIdentityArn;

/**
* An object that contains the body of the message. You can send either a Simple message Raw message or a template
* Message.
* An object that contains the body of the message. You can send either a Simple message, Raw message, or a Templated
* message.
*
* @required
*
Expand Down
6 changes: 3 additions & 3 deletions src/Result/SendEmailResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class SendEmailResponse extends Result
/**
* A unique identifier for the message that is generated when the message is accepted.
*
* > It's possible for Amazon SES to accept a message without sending it. This can happen when the message that you're
* > trying to send has an attachment contains a virus, or when you send a templated email that contains invalid
* > personalization content, for example.
* > It's possible for Amazon SES to accept a message without sending it. For example, this can happen when the message
* > that you're trying to send has an attachment that contains a virus, or when you send a templated email that
* > contains invalid personalization content.
*
* @var string|null
*/
Expand Down
26 changes: 26 additions & 0 deletions src/ValueObject/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,32 @@ final class Message
*/
private $body;

/**
* The list of message headers that will be added to the email message.
*
* @var MessageHeader[]|null
*/
private $headers;

/**
* @param array{
* Subject: Content|array,
* Body: Body|array,
* Headers?: null|array<MessageHeader|array>,
* } $input
*/
public function __construct(array $input)
{
$this->subject = isset($input['Subject']) ? Content::create($input['Subject']) : $this->throwException(new InvalidArgument('Missing required field "Subject".'));
$this->body = isset($input['Body']) ? Body::create($input['Body']) : $this->throwException(new InvalidArgument('Missing required field "Body".'));
$this->headers = isset($input['Headers']) ? array_map([MessageHeader::class, 'create'], $input['Headers']) : null;
}

/**
* @param array{
* Subject: Content|array,
* Body: Body|array,
* Headers?: null|array<MessageHeader|array>,
* }|Message $input
*/
public static function create($input): self
Expand All @@ -54,6 +64,14 @@ public function getBody(): Body
return $this->body;
}

/**
* @return MessageHeader[]
*/
public function getHeaders(): array
{
return $this->headers ?? [];
}

public function getSubject(): Content
{
return $this->subject;
Expand All @@ -69,6 +87,14 @@ public function requestBody(): array
$payload['Subject'] = $v->requestBody();
$v = $this->body;
$payload['Body'] = $v->requestBody();
if (null !== $v = $this->headers) {
$index = -1;
$payload['Headers'] = [];
foreach ($v as $listValue) {
++$index;
$payload['Headers'][$index] = $listValue->requestBody();
}
}

return $payload;
}
Expand Down
86 changes: 86 additions & 0 deletions src/ValueObject/MessageHeader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace AsyncAws\Ses\ValueObject;

use AsyncAws\Core\Exception\InvalidArgument;

/**
* Contains the name and value of a message header that you add to an email.
*/
final class MessageHeader
{
/**
* The name of the message header. The message header name has to meet the following criteria:.
*
* - Can contain any printable ASCII character (33 - 126) except for colon (:).
* - Can contain no more than 126 characters.
*
* @var string
*/
private $name;

/**
* The value of the message header. The message header value has to meet the following criteria:.
*
* - Can contain any printable ASCII character.
* - Can contain no more than 870 characters.
*
* @var string
*/
private $value;

/**
* @param array{
* Name: string,
* Value: string,
* } $input
*/
public function __construct(array $input)
{
$this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".'));
$this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".'));
}

/**
* @param array{
* Name: string,
* Value: string,
* }|MessageHeader $input
*/
public static function create($input): self
{
return $input instanceof self ? $input : new self($input);
}

public function getName(): string
{
return $this->name;
}

public function getValue(): string
{
return $this->value;
}

/**
* @internal
*/
public function requestBody(): array
{
$payload = [];
$v = $this->name;
$payload['Name'] = $v;
$v = $this->value;
$payload['Value'] = $v;

return $payload;
}

/**
* @return never
*/
private function throwException(\Throwable $exception)
{
throw $exception;
}
}
26 changes: 26 additions & 0 deletions src/ValueObject/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,50 @@ final class Template
*/
private $templateData;

/**
* The list of message headers that will be added to the email message.
*
* @var MessageHeader[]|null
*/
private $headers;

/**
* @param array{
* TemplateName?: null|string,
* TemplateArn?: null|string,
* TemplateData?: null|string,
* Headers?: null|array<MessageHeader|array>,
* } $input
*/
public function __construct(array $input)
{
$this->templateName = $input['TemplateName'] ?? null;
$this->templateArn = $input['TemplateArn'] ?? null;
$this->templateData = $input['TemplateData'] ?? null;
$this->headers = isset($input['Headers']) ? array_map([MessageHeader::class, 'create'], $input['Headers']) : null;
}

/**
* @param array{
* TemplateName?: null|string,
* TemplateArn?: null|string,
* TemplateData?: null|string,
* Headers?: null|array<MessageHeader|array>,
* }|Template $input
*/
public static function create($input): self
{
return $input instanceof self ? $input : new self($input);
}

/**
* @return MessageHeader[]
*/
public function getHeaders(): array
{
return $this->headers ?? [];
}

public function getTemplateArn(): ?string
{
return $this->templateArn;
Expand Down Expand Up @@ -89,6 +107,14 @@ public function requestBody(): array
if (null !== $v = $this->templateData) {
$payload['TemplateData'] = $v;
}
if (null !== $v = $this->headers) {
$index = -1;
$payload['Headers'] = [];
foreach ($v as $listValue) {
++$index;
$payload['Headers'][$index] = $listValue->requestBody();
}
}

return $payload;
}
Expand Down

0 comments on commit edae510

Please sign in to comment.