1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the theroadbunch/mandrill-sdk package. |
5
|
|
|
* |
6
|
|
|
* (c) Dan McAdams <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace RoadBunch\Mandrill\Message; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class SendResponse |
17
|
|
|
* |
18
|
|
|
* @author Dan McAdams |
19
|
|
|
* @package RoadBunch\Mandrill\Message |
20
|
|
|
*/ |
21
|
|
|
class SendResponse |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* the message's unique id |
25
|
|
|
* |
26
|
|
|
* @var string $id |
27
|
|
|
*/ |
28
|
|
|
public $id; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* the email address of the recipient |
32
|
|
|
* |
33
|
|
|
* @var string $email |
34
|
|
|
*/ |
35
|
|
|
public $email; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* the sending status of the recipient |
39
|
|
|
* - either "sent", "queued", "scheduled", "rejected", or "invalid" |
40
|
|
|
* |
41
|
|
|
* @var string $status |
42
|
|
|
*/ |
43
|
|
|
public $status; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* the reason for the rejection if the recipient status is "rejected" |
47
|
|
|
* - one of "hard-bounce", "soft-bounce", "spam", "unsub", "custom", |
48
|
|
|
* "invalid-sender", "invalid", "test-mode-limit", "unsigned", or "rule" |
49
|
|
|
* |
50
|
|
|
* @var string $rejectReason |
51
|
|
|
*/ |
52
|
|
|
public $rejectReason; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* SendResponse constructor. |
56
|
|
|
* @param string $id |
57
|
|
|
* @param string $email |
58
|
|
|
* @param string $status |
59
|
|
|
* @param string|null $rejectReason |
60
|
|
|
*/ |
61
|
|
|
public function __construct(string $id, string $email, string $status, string $rejectReason = null) |
62
|
|
|
{ |
63
|
|
|
$this->id = $id; |
64
|
|
|
$this->email = $email; |
65
|
|
|
$this->status = $status; |
66
|
|
|
$this->rejectReason = $rejectReason; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
public function toArray(): array |
73
|
|
|
{ |
74
|
|
|
return [ |
75
|
|
|
'email' => $this->email, |
76
|
|
|
'status' => $this->status, |
77
|
|
|
'reject_reason' => $this->rejectReason, |
78
|
|
|
'_id' => $this->id |
79
|
|
|
]; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
public function __toString(): string |
86
|
|
|
{ |
87
|
|
|
return json_encode($this->toArray()); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|