-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathusers.php
46 lines (37 loc) · 1.26 KB
/
users.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use Mailtrap\Config;
use Mailtrap\Helper\ResponseHelper;
use Mailtrap\MailtrapGeneralClient;
require __DIR__ . '/../vendor/autoload.php';
$accountId = getenv('MAILTRAP_ACCOUNT_ID');
$config = new Config(getenv('MAILTRAP_API_KEY')); #your API token from here https://mailtrap.io/api-tokens
$generalUsers = (new MailtrapGeneralClient($config))->users($accountId);
/**
* List all users in account
*
* GET https://mailtrap.io/api/accounts/{account_id}/account_accesses
*/
try {
$response = $generalUsers->getList();
// OR with query parameters (not required)
$inboxIds = [2000005, 2000006];
$projectIds = [1005001];
$response = $generalUsers->getList($inboxIds, $projectIds);
// print the response body (array)
var_dump(ResponseHelper::toArray($response));
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
/**
* Remove user from the account
*
* DELETE https://mailtrap.io/api/accounts/{account_id}/account_accesses/{account_access_id}
*/
try {
$accountAccessId = 10000009;
$response = $generalUsers->delete($accountAccessId);
// print the response body (array)
var_dump(ResponseHelper::toArray($response));
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}