Modifying API

This commit is contained in:
Loann 2020-06-08 12:00:43 +02:00
parent 6c1aedd2ae
commit 033ee64724
1 changed files with 13 additions and 0 deletions

View File

@ -5,6 +5,8 @@ namespace Bluescale\Mail;
use Bluescale\Mail\BluescaleMailTemplate; use Bluescale\Mail\BluescaleMailTemplate;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Psr\Http\Message\StreamInterface; use Psr\Http\Message\StreamInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class BluescaleMailApi class BluescaleMailApi
{ {
@ -37,6 +39,7 @@ class BluescaleMailApi
$notifiable_recipient = false; $notifiable_recipient = false;
$notifiable_email = $notifiable->email; $notifiable_email = $notifiable->email;
$recipients = $template->recipients; $recipients = $template->recipients;
$attachments = $template->attachments;
if (count($recipients) > 0) if (count($recipients) > 0)
foreach ($recipients as $recipient) foreach ($recipients as $recipient)
@ -48,6 +51,16 @@ class BluescaleMailApi
$template->recipients[] = [ $template->recipients[] = [
'address' => $notifiable->email 'address' => $notifiable->email
]; ];
if (count($attachments) > 0) {
$formatted_attachmments = [];
foreach ($attachments as $attachment) {
$file = new UploadedFile($attachment->path, $attachment->fileName, 'application/octet-stream', null, null, false);
$formatted_attachmments[] = $file;
}
$template->attachments($formatted_attachmments);
}
} }
try { try {