1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace keika299\ConohaAPI\Mail; |
4
|
|
|
|
5
|
|
|
use keika299\ConohaAPI\Common\Network\Request; |
6
|
|
|
use keika299\ConohaAPI\Common\Service\AbstractService; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class Service |
10
|
|
|
* |
11
|
|
|
* This class connect to ConoHa mail service. |
12
|
|
|
* |
13
|
|
|
* @package keika299\ConohaAPI\Mail |
14
|
|
|
*/ |
15
|
|
|
class Service extends AbstractService |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Get version info. |
20
|
|
|
* |
21
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-version-list.html |
22
|
|
|
* |
23
|
|
|
* @return mixed |
24
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
25
|
|
|
*/ |
26
|
1 |
|
public function getVersionInfo() |
27
|
|
|
{ |
28
|
1 |
|
$request = (new Request()) |
29
|
1 |
|
->setMethod('GET') |
30
|
1 |
|
->setBaseURI($this->baseURI) |
31
|
1 |
|
->setURI('/') |
32
|
1 |
|
->setAccept('application/json'); |
33
|
|
|
|
34
|
1 |
|
$response = $request->exec(); |
35
|
1 |
|
return $response->getJson(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Get version detail. |
40
|
|
|
* |
41
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-version-detail.html |
42
|
|
|
* |
43
|
|
|
* @return mixed |
44
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
45
|
|
|
*/ |
46
|
1 |
|
public function getVersionDetail() |
47
|
|
|
{ |
48
|
1 |
|
$request = (new Request()) |
49
|
1 |
|
->setMethod('GET') |
50
|
1 |
|
->setBaseURI($this->baseURI) |
51
|
1 |
|
->setURI('/v1') |
52
|
1 |
|
->setAccept('application/json') |
53
|
1 |
|
->setToken($this->token->getToken()); |
54
|
|
|
|
55
|
1 |
|
$response = $request->exec(); |
56
|
1 |
|
return $response->getJson(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Create mail service. |
61
|
|
|
* |
62
|
|
|
* See https://www.conoha.jp/docs/paas-mail-create-mail-service.html |
63
|
|
|
* |
64
|
|
|
* @param string $serviceName |
65
|
|
|
* @param string $subDomain |
66
|
|
|
* @return mixed |
67
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
68
|
|
|
*/ |
69
|
1 |
|
public function postService($serviceName, $subDomain) |
70
|
|
|
{ |
71
|
|
|
$data = array( |
72
|
1 |
|
'service_name' => $serviceName, |
73
|
|
|
'default_sub_domain' => $subDomain |
74
|
1 |
|
); |
75
|
|
|
|
76
|
1 |
|
$request = (new Request()) |
77
|
1 |
|
->setMethod('POST') |
78
|
1 |
|
->setBaseURI($this->baseURI) |
79
|
1 |
|
->setURI('/v1/services') |
80
|
1 |
|
->setAccept('application/json') |
81
|
1 |
|
->setContentType('application/json') |
82
|
1 |
|
->setToken($this->token->getToken()) |
83
|
1 |
|
->setJson($data); |
84
|
|
|
|
85
|
1 |
|
$response = $request->exec(); |
86
|
1 |
|
return $response->getJson(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get mail service list. |
91
|
|
|
* |
92
|
|
|
* $option can set offset, limit, sort_key, and sort_type. |
93
|
|
|
* 'offset' is list offset (int value). |
94
|
|
|
* 'limit' is list limit (int value). |
95
|
|
|
* 'sort_key is crate_date, service_name, and status. |
96
|
|
|
* 'sort_type' is asc or desc. |
97
|
|
|
* |
98
|
|
|
* See https://www.conoha.jp/docs/paas-mail-list-mail-service.html |
99
|
|
|
* |
100
|
|
|
* @param array $options |
101
|
|
|
* @return mixed |
102
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
103
|
|
|
*/ |
104
|
1 |
|
public function getServiceList($options = array()) |
105
|
|
|
{ |
106
|
1 |
|
$request = (new Request()) |
107
|
1 |
|
->setMethod('GET') |
108
|
1 |
|
->setBaseURI($this->baseURI) |
109
|
1 |
|
->setURI('/v1/services') |
110
|
1 |
|
->setAccept('application/json') |
111
|
1 |
|
->setQuery($options) |
112
|
1 |
|
->setToken($this->token->getToken()); |
113
|
|
|
|
114
|
1 |
|
$response = $request->exec(); |
115
|
1 |
|
return $response->getJson(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Get mail service information. |
120
|
|
|
* |
121
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-service.html |
122
|
|
|
* |
123
|
|
|
* @param string $serviceId |
124
|
|
|
* @return mixed |
125
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
126
|
|
|
*/ |
127
|
1 |
|
public function getServiceInfo($serviceId) |
128
|
|
|
{ |
129
|
1 |
|
$request = (new Request()) |
130
|
1 |
|
->setMethod('GET') |
131
|
1 |
|
->setBaseURI($this->baseURI) |
132
|
1 |
|
->setURI('/v1/services/' . $serviceId) |
133
|
1 |
|
->setAccept('application/json') |
134
|
1 |
|
->setToken($this->token->getToken()); |
135
|
|
|
|
136
|
1 |
|
$response = $request->exec(); |
137
|
1 |
|
return $response->getJson(); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Change service informaiton. |
142
|
|
|
* |
143
|
|
|
* See https://www.conoha.jp/docs/paas-mail-update-mail-service.html |
144
|
|
|
* |
145
|
|
|
* @param string $serviceId |
146
|
|
|
* @param string $serviceName |
147
|
|
|
* @return mixed |
148
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
149
|
|
|
*/ |
150
|
1 |
|
public function putServiceInfo($serviceId, $serviceName) |
151
|
|
|
{ |
152
|
1 |
|
$data = array('service_name' => $serviceName); |
153
|
|
|
|
154
|
1 |
|
$request = (new Request()) |
155
|
1 |
|
->setMethod('PUT') |
156
|
1 |
|
->setBaseURI($this->baseURI) |
157
|
1 |
|
->setURI('/v1/services/' . $serviceId) |
158
|
1 |
|
->setAccept('application/json') |
159
|
1 |
|
->setToken($this->token->getToken()) |
160
|
1 |
|
->setJson($data); |
161
|
|
|
|
162
|
1 |
|
$response = $request->exec(); |
163
|
1 |
|
return $response->getJson(); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Change backup state. |
168
|
|
|
* |
169
|
|
|
* See https://www.conoha.jp/docs/paas-mail-create-backup.html |
170
|
|
|
* |
171
|
|
|
* @param string $serviceId |
172
|
|
|
* @param bool $isBackup |
173
|
|
|
* @return mixed |
174
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
175
|
|
|
*/ |
176
|
1 |
|
public function putBackupState($serviceId, $isBackup) |
177
|
|
|
{ |
178
|
1 |
|
$isBackupState = $isBackup ? 'enable' : 'disable'; |
179
|
|
|
|
180
|
|
|
$data = array( |
181
|
|
|
'backup' => [ |
182
|
|
|
'status' => $isBackupState |
183
|
1 |
|
] |
184
|
1 |
|
); |
185
|
|
|
|
186
|
1 |
|
$request = (new Request()) |
187
|
1 |
|
->setMethod('PUT') |
188
|
1 |
|
->setBaseURI($this->baseURI) |
189
|
1 |
|
->setURI('/v1/services/' . $serviceId . '/action') |
190
|
1 |
|
->setAccept('application/json') |
191
|
1 |
|
->setToken($this->token->getToken()) |
192
|
1 |
|
->setJson($data); |
193
|
|
|
|
194
|
1 |
|
$response = $request->exec(); |
195
|
1 |
|
return $response->getJson(); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Delete mail service. |
200
|
|
|
* |
201
|
|
|
* See https://www.conoha.jp/docs/paas-mail-delete-mail-service.html |
202
|
|
|
* |
203
|
|
|
* @param string $serviceId |
204
|
|
|
* @return null |
205
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
206
|
|
|
*/ |
207
|
1 |
|
public function deleteService($serviceId) |
208
|
|
|
{ |
209
|
1 |
|
$request = (new Request()) |
210
|
1 |
|
->setMethod('DELETE') |
211
|
1 |
|
->setBaseURI($this->baseURI) |
212
|
1 |
|
->setURI('/v1/services/' . $serviceId) |
213
|
1 |
|
->setAccept('application/json') |
214
|
1 |
|
->setToken($this->token->getToken()); |
215
|
|
|
|
216
|
1 |
|
$request->exec(); |
217
|
|
|
|
218
|
1 |
|
return null; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Get service quota value. |
223
|
|
|
* |
224
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-email-quotas.html |
225
|
|
|
* |
226
|
|
|
* @param string $serviceId |
227
|
|
|
* @return mixed |
228
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
229
|
|
|
*/ |
230
|
1 |
|
public function getQuota($serviceId) |
231
|
|
|
{ |
232
|
1 |
|
$request = (new Request()) |
233
|
1 |
|
->setMethod('GET') |
234
|
1 |
|
->setBaseURI($this->baseURI) |
235
|
1 |
|
->setURI('/v1/services/' . $serviceId . '/quotas') |
236
|
1 |
|
->setAccept('application/json') |
237
|
1 |
|
->setToken($this->token->getToken()); |
238
|
|
|
|
239
|
1 |
|
$response = $request->exec(); |
240
|
1 |
|
return $response->getJson(); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Change quota value. |
245
|
|
|
* |
246
|
|
|
* See https://www.conoha.jp/docs/paas-mail-update-email-quotas.html |
247
|
|
|
* |
248
|
|
|
* @param string $serviceId |
249
|
|
|
* @param int $quota |
250
|
|
|
* @return mixed |
251
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
252
|
|
|
*/ |
253
|
1 |
|
public function putQuota($serviceId, $quota) |
254
|
|
|
{ |
255
|
1 |
|
$data = array('quota' => $quota); |
256
|
|
|
|
257
|
1 |
|
$request = (new Request()) |
258
|
1 |
|
->setMethod('PUT') |
259
|
1 |
|
->setBaseURI($this->baseURI) |
260
|
1 |
|
->setURI('/v1/services/' . $serviceId . '/quotas') |
261
|
1 |
|
->setAccept('application/json') |
262
|
1 |
|
->setToken($this->token->getToken()) |
263
|
1 |
|
->setJson($data); |
264
|
|
|
|
265
|
1 |
|
$response = $request->exec(); |
266
|
1 |
|
return $response->getJson(); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* Create domain information. |
271
|
|
|
* |
272
|
|
|
* https://www.conoha.jp/docs/paas-mail-create-domain.html |
273
|
|
|
* |
274
|
|
|
* @param string $serviceId |
275
|
|
|
* @param string $domainName |
276
|
|
|
* @return mixed |
277
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
278
|
|
|
*/ |
279
|
1 |
|
public function postDomain($serviceId, $domainName) |
280
|
|
|
{ |
281
|
|
|
$data = array( |
282
|
1 |
|
'service_id' => $serviceId, |
283
|
|
|
'domain_name' => $domainName |
284
|
1 |
|
); |
285
|
|
|
|
286
|
1 |
|
$request = (new Request()) |
287
|
1 |
|
->setMethod('POST') |
288
|
1 |
|
->setBaseURI($this->baseURI) |
289
|
1 |
|
->setURI('/v1/domains') |
290
|
1 |
|
->setAccept('application/json') |
291
|
1 |
|
->setToken($this->token->getToken()) |
292
|
1 |
|
->setJson($data); |
293
|
|
|
|
294
|
1 |
|
$response = $request->exec(); |
295
|
1 |
|
return $response->getJson(); |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* Get domains list. |
300
|
|
|
* |
301
|
|
|
* $option can set service_id, offset, limit, sort_key, and sort_type. |
302
|
|
|
* 'service_id' is target service UUID. |
303
|
|
|
* 'offset' is list offset (int value). |
304
|
|
|
* 'limit' is list limit (int value). |
305
|
|
|
* 'sort_key is crate_date, service_name, and status. |
306
|
|
|
* 'sort_type' is asc or desc. |
307
|
|
|
* |
308
|
|
|
* See https://www.conoha.jp/docs/paas-mail-list-domain.html |
309
|
|
|
* |
310
|
|
|
* @param array $options |
311
|
|
|
* @return mixed |
312
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
313
|
|
|
*/ |
314
|
1 |
|
public function getDomainList($options = array()) |
315
|
|
|
{ |
316
|
1 |
|
$request = (new Request()) |
317
|
1 |
|
->setMethod('GET') |
318
|
1 |
|
->setBaseURI($this->baseURI) |
319
|
1 |
|
->setURI('/v1/domains') |
320
|
1 |
|
->setQuery($options) |
321
|
1 |
|
->setAccept('application/json') |
322
|
1 |
|
->setToken($this->token->getToken()); |
323
|
|
|
|
324
|
1 |
|
$response = $request->exec(); |
325
|
1 |
|
return $response->getJson(); |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* Delete domain. |
330
|
|
|
* |
331
|
|
|
* See https://www.conoha.jp/docs/paas-mail-delete-domain.html |
332
|
|
|
* |
333
|
|
|
* @param string $serviceId |
334
|
|
|
* @return null |
335
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
336
|
|
|
*/ |
337
|
1 |
|
public function deleteDomain($serviceId) |
338
|
1 |
|
{$request = (new Request()) |
339
|
1 |
|
->setMethod('DELETE') |
340
|
1 |
|
->setBaseURI($this->baseURI) |
341
|
1 |
|
->setURI('/v1/domains/' . $serviceId) |
342
|
1 |
|
->setAccept('application/json') |
343
|
1 |
|
->setToken($this->token->getToken()); |
344
|
|
|
|
345
|
1 |
|
$request->exec(); |
346
|
|
|
|
347
|
1 |
|
return null; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Get domain's dedicated ip. |
352
|
|
|
* |
353
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-dedicated-ip.html |
354
|
|
|
* |
355
|
|
|
* @param string $domainId |
356
|
|
|
* @return mixed |
357
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
358
|
|
|
*/ |
359
|
1 |
|
public function getDedicatedIp($domainId) |
360
|
|
|
{ |
361
|
1 |
|
$request = (new Request()) |
362
|
1 |
|
->setMethod('GET') |
363
|
1 |
|
->setBaseURI($this->baseURI) |
364
|
1 |
|
->setURI('/v1/domains/' . $domainId . '/dedicatedip') |
365
|
1 |
|
->setAccept('application/json') |
366
|
1 |
|
->setToken($this->token->getToken()); |
367
|
|
|
|
368
|
1 |
|
$response = $request->exec(); |
369
|
1 |
|
return $response->getJson(); |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* Change domain's dedicated ip. |
374
|
|
|
* |
375
|
|
|
* See https://www.conoha.jp/docs/paas-mail-create-dedicated-ip.html |
376
|
|
|
* |
377
|
|
|
* @param string $domainId |
378
|
|
|
* @param bool $isDedicate |
379
|
|
|
* @return mixed |
380
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
381
|
|
|
*/ |
382
|
1 |
|
public function putDedicatedIp($domainId, $isDedicate) |
383
|
|
|
{ |
384
|
1 |
|
$isDedicateState = $isDedicate ? 'enable' : 'disable'; |
385
|
|
|
|
386
|
|
|
$data = array( |
387
|
|
|
'dedicatedip' => [ |
388
|
|
|
'status' => $isDedicateState |
389
|
1 |
|
] |
390
|
1 |
|
); |
391
|
|
|
|
392
|
1 |
|
$request = (new Request()) |
393
|
1 |
|
->setMethod('PUT') |
394
|
1 |
|
->setBaseURI($this->baseURI) |
395
|
1 |
|
->setURI('/v1/domains/' . $domainId . '/action') |
396
|
1 |
|
->setAccept('application/json') |
397
|
1 |
|
->setToken($this->token->getToken()) |
398
|
1 |
|
->setJson($data); |
399
|
|
|
|
400
|
1 |
|
$response = $request->exec(); |
401
|
1 |
|
return $response->getJson(); |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* Create email address. |
406
|
|
|
* |
407
|
|
|
* See https://www.conoha.jp/docs/paas-mail-create-email.html |
408
|
|
|
* |
409
|
|
|
* @param string $domainId |
410
|
|
|
* @param string $email |
411
|
|
|
* @param string $password |
412
|
|
|
* @return mixed |
413
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
414
|
|
|
*/ |
415
|
1 |
|
public function postEmail($domainId, $email, $password) |
416
|
|
|
{ |
417
|
|
|
$data = array( |
418
|
1 |
|
'domain_id' => $domainId, |
419
|
1 |
|
'email' => $email, |
420
|
|
|
'password' => $password |
421
|
1 |
|
); |
422
|
|
|
|
423
|
1 |
|
$request = (new Request()) |
424
|
1 |
|
->setMethod('POST') |
425
|
1 |
|
->setBaseURI($this->baseURI) |
426
|
1 |
|
->setURI('/v1/emails') |
427
|
1 |
|
->setAccept('application/json') |
428
|
1 |
|
->setToken($this->token->getToken()) |
429
|
1 |
|
->setJson($data); |
430
|
|
|
|
431
|
1 |
|
$response = $request->exec(); |
432
|
1 |
|
return $response->getJson(); |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Get email list. |
437
|
|
|
* |
438
|
|
|
* $option can set domain_id, offset, limit, sort_key, and sort_type. |
439
|
|
|
* 'domain_id' is target domain UUID. |
440
|
|
|
* 'offset' is list offset (int value). |
441
|
|
|
* 'limit' is list limit (int value). |
442
|
|
|
* 'sort_key is crate_date, service_name, and status. |
443
|
|
|
* 'sort_type' is asc or desc. |
444
|
|
|
* |
445
|
|
|
* See https://www.conoha.jp/docs/paas-mail-list-email-domains.html |
446
|
|
|
* |
447
|
|
|
* @param array $options |
448
|
|
|
* @return mixed |
449
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
450
|
|
|
*/ |
451
|
1 |
|
public function getEmailList($options = array()) |
452
|
|
|
{ |
453
|
1 |
|
$request = (new Request()) |
454
|
1 |
|
->setMethod('GET') |
455
|
1 |
|
->setBaseURI($this->baseURI) |
456
|
1 |
|
->setURI('/v1/emails') |
457
|
1 |
|
->setQuery($options) |
458
|
1 |
|
->setAccept('application/json') |
459
|
1 |
|
->setToken($this->token->getToken()); |
460
|
|
|
|
461
|
1 |
|
$response = $request->exec(); |
462
|
1 |
|
return $response->getJson(); |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
/** |
466
|
|
|
* Get email info. |
467
|
|
|
* |
468
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-email.html |
469
|
|
|
* |
470
|
|
|
* @param string $emailId |
471
|
|
|
* @return mixed |
472
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
473
|
|
|
*/ |
474
|
1 |
|
public function getEmailInfo($emailId) |
475
|
|
|
{ |
476
|
1 |
|
$request = (new Request()) |
477
|
1 |
|
->setMethod('GET') |
478
|
1 |
|
->setBaseURI($this->baseURI) |
479
|
1 |
|
->setURI('/v1/emails/' . $emailId) |
480
|
1 |
|
->setAccept('application/json') |
481
|
1 |
|
->setToken($this->token->getToken()); |
482
|
|
|
|
483
|
1 |
|
$response = $request->exec(); |
484
|
1 |
|
return $response->getJson(); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Delete email. |
489
|
|
|
* |
490
|
|
|
* See https://www.conoha.jp/docs/paas-mail-delete-email.html |
491
|
|
|
* |
492
|
|
|
* @param string $emailId |
493
|
|
|
* @return null |
494
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
495
|
|
|
*/ |
496
|
1 |
|
public function deleteEmail($emailId) |
497
|
|
|
{ |
498
|
1 |
|
$request = (new Request()) |
499
|
1 |
|
->setMethod('DELETE') |
500
|
1 |
|
->setBaseURI($this->baseURI) |
501
|
1 |
|
->setURI('/v1/emails/' . $emailId) |
502
|
1 |
|
->setAccept('application/json') |
503
|
1 |
|
->setToken($this->token->getToken()); |
504
|
|
|
|
505
|
1 |
|
$request->exec(); |
506
|
1 |
|
return null; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* Change email password. |
511
|
|
|
* |
512
|
|
|
* See https://www.conoha.jp/docs/paas-mail-update-email-password.html |
513
|
|
|
* |
514
|
|
|
* @param string $emailId |
515
|
|
|
* @param string $newPassword |
516
|
|
|
* @return mixed |
517
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
518
|
|
|
*/ |
519
|
1 |
|
public function putEmailPassword($emailId, $newPassword) |
520
|
|
|
{ |
521
|
1 |
|
$data = array('password' => $newPassword); |
522
|
1 |
|
$request = (new Request()) |
523
|
1 |
|
->setMethod('PUT') |
524
|
1 |
|
->setBaseURI($this->baseURI) |
525
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/password') |
526
|
1 |
|
->setAccept('application/json') |
527
|
1 |
|
->setToken($this->token->getToken()) |
528
|
1 |
|
->setJson($data); |
529
|
|
|
|
530
|
1 |
|
$response = $request->exec(); |
531
|
1 |
|
return $response->getJson(); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* Change email filter states. |
536
|
|
|
* |
537
|
|
|
* $filterType can select tray or subject. |
538
|
|
|
* |
539
|
|
|
* See https://www.conoha.jp/docs/paas-mail-create-email-spam-filter.html |
540
|
|
|
* |
541
|
|
|
* @param string $emailId |
542
|
|
|
* @param bool $isFilter |
543
|
|
|
* @param string $filterType |
544
|
|
|
* @return mixed |
545
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
546
|
|
|
*/ |
547
|
1 |
|
public function putEmailFilterState($emailId, $isFilter, $filterType) |
548
|
|
|
{ |
549
|
1 |
|
$isFilterStatus = $isFilter ? 'enable' : 'disable'; |
550
|
|
|
|
551
|
|
|
$data = array( |
552
|
|
|
'spam' => [ |
553
|
1 |
|
'status' => $isFilterStatus, |
554
|
|
|
'type' => $filterType |
555
|
1 |
|
] |
556
|
1 |
|
); |
557
|
|
|
|
558
|
1 |
|
$request = (new Request()) |
559
|
1 |
|
->setMethod('PUT') |
560
|
1 |
|
->setBaseURI($this->baseURI) |
561
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/action') |
562
|
1 |
|
->setAccept('application/json') |
563
|
1 |
|
->setToken($this->token->getToken()) |
564
|
1 |
|
->setJson($data); |
565
|
|
|
|
566
|
1 |
|
$response = $request->exec(); |
567
|
1 |
|
return $response->getJson(); |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* Change email forwarding copy state. |
572
|
|
|
* |
573
|
|
|
* See https://www.conoha.jp/docs/paas-mail-create-email-forwarding-copy.html |
574
|
|
|
* |
575
|
|
|
* @param string $emailId |
576
|
|
|
* @param bool $isCopy |
577
|
|
|
* @return mixed |
578
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
579
|
|
|
*/ |
580
|
1 |
|
public function putEmailForwardingCopyState($emailId, $isCopy) |
581
|
|
|
{ |
582
|
1 |
|
$isCopyStatus = $isCopy ? 'enable' : 'disable'; |
583
|
|
|
|
584
|
|
|
$data = array( |
585
|
|
|
'forwarding_copy' => [ |
586
|
|
|
'status' => $isCopyStatus |
587
|
1 |
|
] |
588
|
1 |
|
); |
589
|
|
|
|
590
|
1 |
|
$request = (new Request()) |
591
|
1 |
|
->setMethod('PUT') |
592
|
1 |
|
->setBaseURI($this->baseURI) |
593
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/action') |
594
|
1 |
|
->setAccept('application/json') |
595
|
1 |
|
->setToken($this->token->getToken()) |
596
|
1 |
|
->setJson($data); |
597
|
|
|
|
598
|
1 |
|
$response = $request->exec(); |
599
|
1 |
|
return $response->getJson(); |
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
/** |
603
|
|
|
* Get messages list. |
604
|
|
|
* |
605
|
|
|
* $option can set offset, limit, sort_key, and sort_type. |
606
|
|
|
* 'offset' is list offset (int value). |
607
|
|
|
* 'limit' is list limit (int value). |
608
|
|
|
* 'sort_key is crate_date, service_name, and status. |
609
|
|
|
* 'sort_type' is asc or desc. |
610
|
|
|
* |
611
|
|
|
* See https://www.conoha.jp/docs/paas-mail-list-messages.html |
612
|
|
|
* |
613
|
|
|
* @param string $emailId |
614
|
|
|
* @param array $options |
615
|
|
|
* @return mixed |
616
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
617
|
|
|
*/ |
618
|
1 |
|
public function getMessageList($emailId, $options = array()) |
619
|
|
|
{ |
620
|
1 |
|
$request = (new Request()) |
621
|
1 |
|
->setMethod('GET') |
622
|
1 |
|
->setBaseURI($this->baseURI) |
623
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/messages') |
624
|
1 |
|
->setQuery($options) |
625
|
1 |
|
->setAccept('application/json') |
626
|
1 |
|
->setToken($this->token->getToken()); |
627
|
|
|
|
628
|
1 |
|
$response = $request->exec(); |
629
|
1 |
|
return $response->getJson(); |
630
|
|
|
} |
631
|
|
|
|
632
|
|
|
/** |
633
|
|
|
* Get message information. |
634
|
|
|
* |
635
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-messages.html |
636
|
|
|
* |
637
|
|
|
* @param string $emailId |
638
|
|
|
* @param string $messageId |
639
|
|
|
* @return mixed |
640
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
641
|
|
|
*/ |
642
|
1 |
|
public function getMessage($emailId, $messageId) |
643
|
|
|
{ |
644
|
1 |
|
$request = (new Request()) |
645
|
1 |
|
->setMethod('GET') |
646
|
1 |
|
->setBaseURI($this->baseURI) |
647
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/messages/' . $messageId) |
648
|
1 |
|
->setAccept('application/json') |
649
|
1 |
|
->setToken($this->token->getToken()); |
650
|
|
|
|
651
|
1 |
|
$response = $request->exec(); |
652
|
1 |
|
return $response->getJson(); |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
/** |
656
|
|
|
* Get message's attachment. |
657
|
|
|
* |
658
|
|
|
* This return value contain binary data. |
659
|
|
|
* |
660
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-messages-attachments.html |
661
|
|
|
* |
662
|
|
|
* @param string $emailId |
663
|
|
|
* @param string $messageId |
664
|
|
|
* @param string $attachmentId |
665
|
|
|
* @return mixed |
666
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
667
|
|
|
*/ |
668
|
1 |
|
public function getMessageAttachment($emailId, $messageId, $attachmentId) |
669
|
|
|
{ |
670
|
1 |
|
$request = (new Request()) |
671
|
1 |
|
->setMethod('GET') |
672
|
1 |
|
->setBaseURI($this->baseURI) |
673
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/messages/' . $messageId . '/attachments/' . $attachmentId) |
674
|
1 |
|
->setAccept('application/json') |
675
|
1 |
|
->setToken($this->token->getToken()); |
676
|
|
|
|
677
|
1 |
|
$response = $request->exec(); |
678
|
1 |
|
return $response->getJson(); |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
|
682
|
|
|
/** |
683
|
|
|
* Delete message. |
684
|
|
|
* |
685
|
|
|
* See https://www.conoha.jp/docs/paas-mail-delete-messages.html |
686
|
|
|
* |
687
|
|
|
* @param string $emailId |
688
|
|
|
* @param string $messageId |
689
|
|
|
* @return null |
690
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
691
|
|
|
*/ |
692
|
1 |
|
public function deleteMessage($emailId, $messageId) |
693
|
|
|
{ |
694
|
1 |
|
$request = (new Request()) |
695
|
1 |
|
->setMethod('DELETE') |
696
|
1 |
|
->setBaseURI($this->baseURI) |
697
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/messages/' . $messageId) |
698
|
1 |
|
->setAccept('application/json') |
699
|
1 |
|
->setToken($this->token->getToken()); |
700
|
|
|
|
701
|
1 |
|
$request->exec(); |
702
|
|
|
|
703
|
1 |
|
return null; |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* Create webhook. |
708
|
|
|
* |
709
|
|
|
* See https://www.conoha.jp/docs/paas-mail-create-email-webhook.html |
710
|
|
|
* |
711
|
|
|
* @param string $emailId |
712
|
|
|
* @param string $webhookURI |
713
|
|
|
* @param string $webhookKeyword |
714
|
|
|
* @return mixed |
715
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
716
|
|
|
*/ |
717
|
1 |
|
public function postWebhook($emailId, $webhookURI, $webhookKeyword) |
718
|
|
|
{ |
719
|
|
|
$data = array( |
720
|
1 |
|
'webhook_url' => $webhookURI, |
721
|
|
|
'webhook_keyword' => $webhookKeyword |
722
|
1 |
|
); |
723
|
|
|
|
724
|
1 |
|
$request = (new Request()) |
725
|
1 |
|
->setMethod('POST') |
726
|
1 |
|
->setBaseURI($this->baseURI) |
727
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/webhook') |
728
|
1 |
|
->setAccept('application/json') |
729
|
1 |
|
->setToken($this->token->getToken()) |
730
|
1 |
|
->setJson($data); |
731
|
|
|
|
732
|
1 |
|
$response = $request->exec(); |
733
|
1 |
|
return $response->getJson(); |
734
|
|
|
} |
735
|
|
|
|
736
|
|
|
/** |
737
|
|
|
* Get webhook. |
738
|
|
|
* |
739
|
|
|
* See https://www.conoha.jp/docs/paas-mail-list-email-filter.html |
740
|
|
|
* |
741
|
|
|
* @param string $emailId |
742
|
|
|
* @return mixed |
743
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
744
|
|
|
*/ |
745
|
1 |
|
public function getWebhook($emailId) |
746
|
|
|
{ |
747
|
1 |
|
$request = (new Request()) |
748
|
1 |
|
->setMethod('GET') |
749
|
1 |
|
->setBaseURI($this->baseURI) |
750
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/webhook') |
751
|
1 |
|
->setAccept('application/json') |
752
|
1 |
|
->setToken($this->token->getToken()); |
753
|
|
|
|
754
|
1 |
|
$response = $request->exec(); |
755
|
1 |
|
return $response->getJson(); |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
/** |
759
|
|
|
* Change webhook. |
760
|
|
|
* |
761
|
|
|
* See https://www.conoha.jp/docs/paas-mail-update-email-filter.html |
762
|
|
|
* |
763
|
|
|
* @param string $emailId |
764
|
|
|
* @param string $webhookURI |
765
|
|
|
* @param string $webhookKeyword |
766
|
|
|
* @return mixed |
767
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
768
|
|
|
*/ |
769
|
1 |
|
public function putWebhook($emailId, $webhookURI, $webhookKeyword) |
770
|
|
|
{ |
771
|
|
|
$data = array( |
772
|
1 |
|
'webhook_url' => $webhookURI, |
773
|
|
|
'webhook_keyword' => $webhookKeyword |
774
|
1 |
|
); |
775
|
|
|
|
776
|
1 |
|
$request = (new Request()) |
777
|
1 |
|
->setMethod('PUT') |
778
|
1 |
|
->setBaseURI($this->baseURI) |
779
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/webhook') |
780
|
1 |
|
->setAccept('application/json') |
781
|
1 |
|
->setToken($this->token->getToken()) |
782
|
1 |
|
->setJson($data); |
783
|
|
|
|
784
|
1 |
|
$response = $request->exec(); |
785
|
1 |
|
return $response->getJson(); |
786
|
|
|
} |
787
|
|
|
|
788
|
|
|
/** |
789
|
|
|
* Delete webhook. |
790
|
|
|
* |
791
|
|
|
* See https://www.conoha.jp/docs/paas-mail-delete-email-filter.html |
792
|
|
|
* |
793
|
|
|
* @param string $emailId |
794
|
|
|
* @return null |
795
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
796
|
|
|
*/ |
797
|
1 |
|
public function deleteWebhook($emailId) |
798
|
|
|
{ |
799
|
1 |
|
$request = (new Request()) |
800
|
1 |
|
->setMethod('DELETE') |
801
|
1 |
|
->setBaseURI($this->baseURI) |
802
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/webhook') |
803
|
1 |
|
->setAccept('application/json') |
804
|
1 |
|
->setToken($this->token->getToken()); |
805
|
|
|
|
806
|
1 |
|
$request->exec(); |
807
|
1 |
|
return null; |
808
|
|
|
} |
809
|
|
|
|
810
|
|
|
/** |
811
|
|
|
* Get white list. |
812
|
|
|
* |
813
|
|
|
* $option can set offset, limit, sort_key, and sort_type. |
814
|
|
|
* 'offset' is list offset (int value). |
815
|
|
|
* 'limit' is list limit (int value). |
816
|
|
|
* 'sort_key is crate_date, service_name, and status. |
817
|
|
|
* 'sort_type' is asc or desc. |
818
|
|
|
* |
819
|
|
|
* See https://www.conoha.jp/docs/paas-mail-list-email-whitelist.html |
820
|
|
|
* |
821
|
|
|
* @param string $emailId |
822
|
|
|
* @param array $options |
823
|
|
|
* @return mixed |
824
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
825
|
|
|
*/ |
826
|
1 |
|
public function getWhiteList($emailId, $options = array()) |
827
|
|
|
{ |
828
|
1 |
|
$request = (new Request()) |
829
|
1 |
|
->setMethod('GET') |
830
|
1 |
|
->setBaseURI($this->baseURI) |
831
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/whitelist') |
832
|
1 |
|
->setQuery($options) |
833
|
1 |
|
->setAccept('application/json') |
834
|
1 |
|
->setToken($this->token->getToken()); |
835
|
|
|
|
836
|
1 |
|
$response = $request->exec(); |
837
|
1 |
|
return $response->getJson(); |
838
|
|
|
} |
839
|
|
|
|
840
|
|
|
/** |
841
|
|
|
* Change white list. |
842
|
|
|
* |
843
|
|
|
* See https://www.conoha.jp/docs/paas-mail-update-email-whitelist.html |
844
|
|
|
* |
845
|
|
|
* @param string $emailId |
846
|
|
|
* @param array $mailList |
847
|
|
|
* @return mixed |
848
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
849
|
|
|
*/ |
850
|
1 |
|
public function putWhiteList($emailId, array $mailList) |
851
|
|
|
{ |
852
|
1 |
|
$request = (new Request()) |
853
|
1 |
|
->setMethod('PUT') |
854
|
1 |
|
->setBaseURI($this->baseURI) |
855
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/whitelist') |
856
|
1 |
|
->setAccept('application/json') |
857
|
1 |
|
->setToken($this->token->getToken()) |
858
|
1 |
|
->setJson($this->createTargetMailArray($mailList)); |
859
|
|
|
|
860
|
1 |
|
$response = $request->exec(); |
861
|
1 |
|
return $response->getJson(); |
862
|
|
|
} |
863
|
|
|
|
864
|
|
|
/** |
865
|
|
|
* Get black list. |
866
|
|
|
* |
867
|
|
|
* $option can set offset, limit, sort_key, and sort_type. |
868
|
|
|
* 'offset' is list offset (int value). |
869
|
|
|
* 'limit' is list limit (int value). |
870
|
|
|
* 'sort_key is crate_date, service_name, and status. |
871
|
|
|
* 'sort_type' is asc or desc. |
872
|
|
|
* |
873
|
|
|
* See https://www.conoha.jp/docs/paas-mail-list-email-blacklist.html |
874
|
|
|
* |
875
|
|
|
* @param string $emailId |
876
|
|
|
* @param array $options |
877
|
|
|
* @return mixed |
878
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
879
|
|
|
*/ |
880
|
1 |
|
public function getBlackList($emailId, $options = array()) |
881
|
|
|
{ |
882
|
1 |
|
$request = (new Request()) |
883
|
1 |
|
->setMethod('GET') |
884
|
1 |
|
->setBaseURI($this->baseURI) |
885
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/blacklist') |
886
|
1 |
|
->setQuery($options) |
887
|
1 |
|
->setAccept('application/json') |
888
|
1 |
|
->setToken($this->token->getToken()); |
889
|
|
|
|
890
|
1 |
|
$response = $request->exec(); |
891
|
1 |
|
return $response->getJson(); |
892
|
|
|
} |
893
|
|
|
|
894
|
|
|
/** |
895
|
|
|
* Change black list. |
896
|
|
|
* |
897
|
|
|
* See https://www.conoha.jp/docs/paas-mail-update-email-blacklist.html |
898
|
|
|
* |
899
|
|
|
* @param string $emailId |
900
|
|
|
* @param array $mailList |
901
|
|
|
* @return mixed |
902
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
903
|
|
|
*/ |
904
|
1 |
|
public function putBlackList($emailId, array $mailList) |
905
|
|
|
{ |
906
|
1 |
|
$request = (new Request()) |
907
|
1 |
|
->setMethod('PUT') |
908
|
1 |
|
->setBaseURI($this->baseURI) |
909
|
1 |
|
->setURI('/v1/emails/' . $emailId . '/blacklist') |
910
|
1 |
|
->setAccept('application/json') |
911
|
1 |
|
->setToken($this->token->getToken()) |
912
|
1 |
|
->setJson($this->createTargetMailArray($mailList)); |
913
|
|
|
|
914
|
1 |
|
$response = $request->exec(); |
915
|
1 |
|
return $response->getJson(); |
916
|
|
|
} |
917
|
|
|
|
918
|
|
|
/** |
919
|
|
|
* Create forwarding setting. |
920
|
|
|
* |
921
|
|
|
* See https://www.conoha.jp/docs/paas-mail-create-email-forwarding.html |
922
|
|
|
* |
923
|
|
|
* @param string $emailId |
924
|
|
|
* @param string $address |
925
|
|
|
* @return mixed |
926
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
927
|
|
|
*/ |
928
|
1 |
|
public function postForwarding($emailId, $address) |
929
|
|
|
{ |
930
|
|
|
$data = array( |
931
|
1 |
|
'email_id' => $emailId, |
932
|
|
|
'address' => $address |
933
|
1 |
|
); |
934
|
|
|
|
935
|
1 |
|
$request = (new Request()) |
936
|
1 |
|
->setMethod('POST') |
937
|
1 |
|
->setBaseURI($this->baseURI) |
938
|
1 |
|
->setURI('/v1/forwarding') |
939
|
1 |
|
->setAccept('application/json') |
940
|
1 |
|
->setToken($this->token->getToken()) |
941
|
1 |
|
->setJson($data); |
942
|
|
|
|
943
|
1 |
|
$response = $request->exec(); |
944
|
1 |
|
return $response->getJson(); |
945
|
|
|
} |
946
|
|
|
|
947
|
|
|
/** |
948
|
|
|
* Get forwarding setting. |
949
|
|
|
* |
950
|
|
|
* $option can set offset, limit, sort_key, and sort_type. |
951
|
|
|
* 'offset' is list offset (int value). |
952
|
|
|
* 'limit' is list limit (int value). |
953
|
|
|
* 'sort_key is crate_date, service_name, and status. |
954
|
|
|
* 'sort_type' is asc or desc. |
955
|
|
|
* |
956
|
|
|
* See https://www.conoha.jp/docs/paas-mail-list-email-forwarding.html |
957
|
|
|
* |
958
|
|
|
* @param array $options |
959
|
|
|
* @return mixed |
960
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
961
|
|
|
*/ |
962
|
1 |
|
public function getForwardingList($options = array()) |
963
|
|
|
{ |
964
|
1 |
|
$request = (new Request()) |
965
|
1 |
|
->setMethod('GET') |
966
|
1 |
|
->setBaseURI($this->baseURI) |
967
|
1 |
|
->setURI('/v1/forwarding') |
968
|
1 |
|
->setQuery($options) |
969
|
1 |
|
->setAccept('application/json') |
970
|
1 |
|
->setToken($this->token->getToken()); |
971
|
|
|
|
972
|
1 |
|
$response = $request->exec(); |
973
|
1 |
|
return $response->getJson(); |
974
|
|
|
} |
975
|
|
|
|
976
|
|
|
/** |
977
|
|
|
* Get forwarding setting. |
978
|
|
|
* |
979
|
|
|
* See https://www.conoha.jp/docs/paas-mail-get-email-forwarding.html |
980
|
|
|
* |
981
|
|
|
* @param string $forwardingId |
982
|
|
|
* @return mixed |
983
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
984
|
|
|
*/ |
985
|
1 |
|
public function getForwarding($forwardingId) |
986
|
|
|
{ |
987
|
1 |
|
$request = (new Request()) |
988
|
1 |
|
->setMethod('GET') |
989
|
1 |
|
->setBaseURI($this->baseURI) |
990
|
1 |
|
->setURI('/v1/forwarding/' . $forwardingId) |
991
|
1 |
|
->setAccept('application/json') |
992
|
1 |
|
->setToken($this->token->getToken()); |
993
|
|
|
|
994
|
1 |
|
$response = $request->exec(); |
995
|
1 |
|
return $response->getJson(); |
996
|
|
|
} |
997
|
|
|
|
998
|
|
|
/** |
999
|
|
|
* Change forwarding setting. |
1000
|
|
|
* |
1001
|
|
|
* See https://www.conoha.jp/docs/paas-mail-update-email-forwarding.html |
1002
|
|
|
* |
1003
|
|
|
* @param string $forwardingId |
1004
|
|
|
* @param string $address |
1005
|
|
|
* @return mixed |
1006
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
1007
|
|
|
*/ |
1008
|
1 |
|
public function putForwarding($forwardingId, $address) |
1009
|
|
|
{ |
1010
|
1 |
|
$data = array('address' => $address); |
1011
|
|
|
|
1012
|
1 |
|
$request = (new Request()) |
1013
|
1 |
|
->setMethod('PUT') |
1014
|
1 |
|
->setBaseURI($this->baseURI) |
1015
|
1 |
|
->setURI('/v1/forwarding/' . $forwardingId) |
1016
|
1 |
|
->setAccept('application/json') |
1017
|
1 |
|
->setToken($this->token->getToken()) |
1018
|
1 |
|
->setJson($data); |
1019
|
|
|
|
1020
|
1 |
|
$response = $request->exec(); |
1021
|
1 |
|
return $response->getJson(); |
1022
|
|
|
} |
1023
|
|
|
|
1024
|
|
|
/** |
1025
|
|
|
* Delete forwarding setting |
1026
|
|
|
* |
1027
|
|
|
* See https://www.conoha.jp/docs/paas-mail-delete-email-forwarding.html |
1028
|
|
|
* |
1029
|
|
|
* @param string $forwardingId |
1030
|
|
|
* @return null |
1031
|
|
|
* @throws \keika299\ConohaAPI\Common\Exceptions\IConohaAPIException |
1032
|
|
|
*/ |
1033
|
1 |
|
public function deleteForwarding($forwardingId) |
1034
|
|
|
{ |
1035
|
1 |
|
$request = (new Request()) |
1036
|
1 |
|
->setMethod('DELETE') |
1037
|
1 |
|
->setBaseURI($this->baseURI) |
1038
|
1 |
|
->setURI('/v1/forwarding/' . $forwardingId) |
1039
|
1 |
|
->setAccept('application/json') |
1040
|
1 |
|
->setToken($this->token->getToken()); |
1041
|
|
|
|
1042
|
1 |
|
$request->exec(); |
1043
|
|
|
|
1044
|
1 |
|
return null; |
1045
|
|
|
} |
1046
|
|
|
|
1047
|
|
|
/** |
1048
|
|
|
* Create target mail array. |
1049
|
|
|
* |
1050
|
|
|
* @param array $targetArray |
1051
|
|
|
* @return array |
1052
|
|
|
*/ |
1053
|
2 |
|
private function createTargetMailArray(array $targetArray) |
1054
|
|
|
{ |
1055
|
2 |
|
$target = array(); |
1056
|
|
|
|
1057
|
2 |
|
foreach ($targetArray as $value) { |
1058
|
2 |
|
array_push($target, ['target' => $value]); |
1059
|
2 |
|
} |
1060
|
|
|
|
1061
|
2 |
|
return array('targets' => $target); |
1062
|
|
|
} |
1063
|
|
|
} |
1064
|
|
|
|