Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SendRejectedEmail | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| buildMail | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
6 | |||
| logLabel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Jobs\Email; |
| 4 | |
| 5 | use SendGrid\Mail\Mail; |
| 6 | |
| 7 | /** |
| 8 | * FIRE-1147: async wrapper for the "your quote was rejected" notification. |
| 9 | * Replaces the inline SendGrid call in Quotations::send_rejected_notification |
| 10 | * (Quotations.php:1108-…) called from reject_quotation. |
| 11 | */ |
| 12 | class SendRejectedEmail extends AbstractSendgridJob |
| 13 | { |
| 14 | public function __construct( |
| 15 | public readonly string $toEmail, |
| 16 | public readonly string $subject, |
| 17 | public readonly string $html, |
| 18 | public readonly ?string $quoteId = null, |
| 19 | ) {} |
| 20 | |
| 21 | protected function buildMail(): ?Mail |
| 22 | { |
| 23 | if ($this->toEmail === '') { |
| 24 | return null; |
| 25 | } |
| 26 | |
| 27 | $email = new Mail; |
| 28 | $email->setFrom('fire@fire.es', 'Fire Service Titan'); |
| 29 | $email->setSubject($this->subject); |
| 30 | $email->addTo($this->toEmail); |
| 31 | $email->addContent('text/html', $this->html); |
| 32 | |
| 33 | $imgpath = file_get_contents(public_path('fireservicetitan.png')); |
| 34 | $email->addAttachment( |
| 35 | $imgpath, |
| 36 | 'image/png', |
| 37 | 'fireservicetitan.png', |
| 38 | 'inline', |
| 39 | 'fireservicetitan' |
| 40 | ); |
| 41 | |
| 42 | return $email; |
| 43 | } |
| 44 | |
| 45 | protected function logLabel(): string |
| 46 | { |
| 47 | return 'Quotations::send_rejected_notification'; |
| 48 | } |
| 49 | } |