1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mrkj\Laposta\Models; |
4
|
|
|
|
5
|
|
|
class Member |
6
|
|
|
{ |
7
|
|
|
private $memberId; |
8
|
|
|
private $listId; |
9
|
|
|
private $email; |
10
|
|
|
private $state; |
11
|
|
|
private $signupDate; |
12
|
|
|
private $modified; |
13
|
|
|
private $ip; |
14
|
|
|
private $sourceUrl; |
15
|
|
|
private $customFields = []; |
16
|
|
|
|
17
|
|
|
const STATE_ACTIVE = 'active'; |
18
|
|
|
const STATE_UNSUBSCRIBED = 'unsubscribed'; |
19
|
|
|
const STATE_CLEANED = 'cleaned'; |
20
|
|
|
|
21
|
|
|
const STATES = [self::STATE_ACTIVE, self::STATE_UNSUBSCRIBED, self::STATE_CLEANED]; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param array $response |
25
|
|
|
* @return Member |
26
|
|
|
*/ |
27
|
|
|
public static function createFromResponse(array $response) : Member |
28
|
|
|
{ |
29
|
|
|
$self = new self; |
30
|
|
|
|
31
|
|
|
$self->updateFromResponse($response); |
32
|
|
|
|
33
|
|
|
return $self; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param array $response |
38
|
|
|
*/ |
39
|
|
|
public function updateFromResponse(array $response) |
40
|
|
|
{ |
41
|
|
|
$this->setMemberId($response['member_id']); |
42
|
|
|
$this->setListId($response['list_id']); |
43
|
|
|
$this->setEmail($response['email']); |
44
|
|
|
$this->setState($response['state']); |
45
|
|
|
$this->setSignupDate($response['signup_date']); |
46
|
|
|
$this->setModified($response['modified']); |
47
|
|
|
$this->setIp($response['ip']); |
48
|
|
|
$this->setSourceUrl($response['source_url']); |
49
|
|
|
$this->setCustomFields($response['custom_fields']); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return mixed |
54
|
|
|
*/ |
55
|
|
|
public function getMemberId() |
56
|
|
|
{ |
57
|
|
|
return $this->memberId; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param mixed $memberId |
62
|
|
|
*/ |
63
|
|
|
public function setMemberId($memberId) |
64
|
|
|
{ |
65
|
|
|
$this->memberId = $memberId; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return mixed |
70
|
|
|
*/ |
71
|
|
|
public function getListId() |
72
|
|
|
{ |
73
|
|
|
return $this->listId; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param mixed $listId |
78
|
|
|
*/ |
79
|
|
|
public function setListId($listId) |
80
|
|
|
{ |
81
|
|
|
$this->listId = $listId; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return mixed |
86
|
|
|
*/ |
87
|
|
|
public function getEmail() |
88
|
|
|
{ |
89
|
|
|
return $this->email; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param mixed $email |
94
|
|
|
*/ |
95
|
|
|
public function setEmail($email) |
96
|
|
|
{ |
97
|
|
|
$this->email = $email; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return mixed |
102
|
|
|
*/ |
103
|
|
|
public function getState() |
104
|
|
|
{ |
105
|
|
|
return $this->state; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param mixed $state |
110
|
|
|
*/ |
111
|
|
|
public function setState($state) |
112
|
|
|
{ |
113
|
|
|
$this->state = $state; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return mixed |
118
|
|
|
*/ |
119
|
|
|
public function getSignupDate() |
120
|
|
|
{ |
121
|
|
|
return $this->signupDate; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param mixed $signupDate |
126
|
|
|
*/ |
127
|
|
|
public function setSignupDate($signupDate) |
128
|
|
|
{ |
129
|
|
|
$this->signupDate = $signupDate; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return mixed |
134
|
|
|
*/ |
135
|
|
|
public function getModified() |
136
|
|
|
{ |
137
|
|
|
return $this->modified; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param mixed $modified |
142
|
|
|
*/ |
143
|
|
|
public function setModified($modified) |
144
|
|
|
{ |
145
|
|
|
$this->modified = $modified; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return mixed |
150
|
|
|
*/ |
151
|
|
|
public function getIp() |
152
|
|
|
{ |
153
|
|
|
return $this->ip; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param mixed $ip |
158
|
|
|
*/ |
159
|
|
|
public function setIp($ip) |
160
|
|
|
{ |
161
|
|
|
$this->ip = $ip; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return mixed |
166
|
|
|
*/ |
167
|
|
|
public function getSourceUrl() |
168
|
|
|
{ |
169
|
|
|
return $this->sourceUrl; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param mixed $sourceUrl |
174
|
|
|
*/ |
175
|
|
|
public function setSourceUrl($sourceUrl) |
176
|
|
|
{ |
177
|
|
|
$this->sourceUrl = $sourceUrl; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return array |
182
|
|
|
*/ |
183
|
|
|
public function getCustomFields() : array |
184
|
|
|
{ |
185
|
|
|
return $this->customFields; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param array|null $customFields |
190
|
|
|
*/ |
191
|
|
|
public function setCustomFields($customFields) |
192
|
|
|
{ |
193
|
|
|
if(is_array($customFields)) { |
194
|
|
|
$this->customFields = $customFields; |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|