117 lines
4.5 KiB
YAML
117 lines
4.5 KiB
YAML
|
name: ResendApiTransport
|
||
|
class_comment: null
|
||
|
dependencies:
|
||
|
- name: EventDispatcherInterface
|
||
|
type: class
|
||
|
source: Psr\EventDispatcher\EventDispatcherInterface
|
||
|
- name: LoggerInterface
|
||
|
type: class
|
||
|
source: Psr\Log\LoggerInterface
|
||
|
- name: Envelope
|
||
|
type: class
|
||
|
source: Symfony\Component\Mailer\Envelope
|
||
|
- name: HttpTransportException
|
||
|
type: class
|
||
|
source: Symfony\Component\Mailer\Exception\HttpTransportException
|
||
|
- name: InvalidArgumentException
|
||
|
type: class
|
||
|
source: Symfony\Component\Mailer\Exception\InvalidArgumentException
|
||
|
- name: TagHeader
|
||
|
type: class
|
||
|
source: Symfony\Component\Mailer\Header\TagHeader
|
||
|
- name: SentMessage
|
||
|
type: class
|
||
|
source: Symfony\Component\Mailer\SentMessage
|
||
|
- name: AbstractApiTransport
|
||
|
type: class
|
||
|
source: Symfony\Component\Mailer\Transport\AbstractApiTransport
|
||
|
- name: Address
|
||
|
type: class
|
||
|
source: Symfony\Component\Mime\Address
|
||
|
- name: Email
|
||
|
type: class
|
||
|
source: Symfony\Component\Mime\Email
|
||
|
- name: Headers
|
||
|
type: class
|
||
|
source: Symfony\Component\Mime\Header\Headers
|
||
|
- name: DecodingExceptionInterface
|
||
|
type: class
|
||
|
source: Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface
|
||
|
- name: TransportExceptionInterface
|
||
|
type: class
|
||
|
source: Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
|
||
|
- name: HttpClientInterface
|
||
|
type: class
|
||
|
source: Symfony\Contracts\HttpClient\HttpClientInterface
|
||
|
- name: ResponseInterface
|
||
|
type: class
|
||
|
source: Symfony\Contracts\HttpClient\ResponseInterface
|
||
|
properties: []
|
||
|
methods:
|
||
|
- name: formatAddresses
|
||
|
visibility: private
|
||
|
parameters:
|
||
|
- name: addresses
|
||
|
comment: "# * @author Mathieu Santostefano <msantostefano@proton.me>\n# */\n# final\
|
||
|
\ class ResendApiTransport extends AbstractApiTransport\n# {\n# public function\
|
||
|
\ __construct(\n# #[\\SensitiveParameter] private readonly string $apiKey,\n#\
|
||
|
\ ?HttpClientInterface $client = null,\n# ?EventDispatcherInterface $dispatcher\
|
||
|
\ = null,\n# ?LoggerInterface $logger = null,\n# ) {\n# parent::__construct($client,\
|
||
|
\ $dispatcher, $logger);\n# }\n# \n# public function __toString(): string\n# {\n\
|
||
|
# return \\sprintf('resend+api://%s', $this->getEndpoint());\n# }\n# \n# protected\
|
||
|
\ function doSendApi(SentMessage $sentMessage, Email $email, Envelope $envelope):\
|
||
|
\ ResponseInterface\n# {\n# $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/emails',\
|
||
|
\ [\n# 'json' => $this->getPayload($email, $envelope),\n# 'headers' => [\n# 'Authorization'\
|
||
|
\ => 'Bearer '.$this->apiKey,\n# ],\n# ]);\n# \n# try {\n# $statusCode = $response->getStatusCode();\n\
|
||
|
# $result = $response->toArray(false);\n# } catch (DecodingExceptionInterface)\
|
||
|
\ {\n# throw new HttpTransportException('Unable to send an email: '.$response->getContent(false).\\\
|
||
|
sprintf(' (code %d).', $statusCode), $response);\n# } catch (TransportExceptionInterface\
|
||
|
\ $e) {\n# throw new HttpTransportException('Could not reach the remote Resend\
|
||
|
\ server.', $response, 0, $e);\n# }\n# \n# if (200 !== $statusCode) {\n# throw\
|
||
|
\ new HttpTransportException('Unable to send an email: '.$response->getContent(false).\\\
|
||
|
sprintf(' (code %d).', $statusCode), $response);\n# }\n# \n# $sentMessage->setMessageId($result['id']);\n\
|
||
|
# \n# return $response;\n# }\n# \n# /**\n# * @param Address[] $addresses\n# *\n\
|
||
|
# * @return list<string>"
|
||
|
- name: getPayload
|
||
|
visibility: private
|
||
|
parameters:
|
||
|
- name: email
|
||
|
- name: envelope
|
||
|
comment: null
|
||
|
- name: prepareAttachments
|
||
|
visibility: private
|
||
|
parameters:
|
||
|
- name: email
|
||
|
comment: null
|
||
|
- name: prepareHeadersAndTags
|
||
|
visibility: private
|
||
|
parameters:
|
||
|
- name: headers
|
||
|
comment: null
|
||
|
- name: formatAddress
|
||
|
visibility: private
|
||
|
parameters:
|
||
|
- name: address
|
||
|
comment: null
|
||
|
- name: getEndpoint
|
||
|
visibility: private
|
||
|
parameters: []
|
||
|
comment: null
|
||
|
traits:
|
||
|
- Psr\EventDispatcher\EventDispatcherInterface
|
||
|
- Psr\Log\LoggerInterface
|
||
|
- Symfony\Component\Mailer\Envelope
|
||
|
- Symfony\Component\Mailer\Exception\HttpTransportException
|
||
|
- Symfony\Component\Mailer\Exception\InvalidArgumentException
|
||
|
- Symfony\Component\Mailer\Header\TagHeader
|
||
|
- Symfony\Component\Mailer\SentMessage
|
||
|
- Symfony\Component\Mailer\Transport\AbstractApiTransport
|
||
|
- Symfony\Component\Mime\Address
|
||
|
- Symfony\Component\Mime\Email
|
||
|
- Symfony\Component\Mime\Header\Headers
|
||
|
- Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface
|
||
|
- Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
|
||
|
- Symfony\Contracts\HttpClient\HttpClientInterface
|
||
|
- Symfony\Contracts\HttpClient\ResponseInterface
|
||
|
interfaces: []
|