This repository has been archived by the owner on Sep 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathApi.php
108 lines (93 loc) · 2.69 KB
/
Api.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
namespace Mailjet\Api\Request;
use Mailjet\Api\MailjetClientInterface;
use Mailjet\Api\RequestApi;
/**
* Higher-level OOP wrapper over Mailjet Client for Api related requests
*
* @link http://www.mailjet.com/docs/api/api
*
* Based on https://github.com/dguyon/Mailjet
*/
class Api
{
private $client;
public function __construct(MailjetClientInterface $client)
{
$this->client = $client;
}
/**
* @link http://www.mailjet.com/docs/api/api/keyadd
*/
public function addKey($name, $status = '')
{
return $this->client->post(RequestApi::API_KEY_ADD, array(
'name' => $name,
'custom_status' => $status
));
}
/**
* @link http://www.mailjet.com/docs/api/api/keyupdate
*/
public function updateKey($key, $name = '', $status = '')
{
return $this->client->post(RequestApi::API_KEY_UPDATE, array(
'apiKey' => $key,
'name' => $name,
'custom_status' => $status
));
}
/**
* @link http://www.mailjet.com/docs/api/api/keyauthenticate
*/
public function authenticateKey($key, array $allowedPages, $defaultPage = '', $lang = '', $timezone = '', $type = null)
{
$options = array(
'apikey' => $key,
'allowed_access' => $allowedPages,
'default_page' => $defaultPage,
'lang' => $lang,
'timezone' => $timezone,
);
if (null !== $type) {
$options['type'] = $type;
}
return $this->client->post(RequestApi::API_KEY_AUTH, $options);
}
/**
* @link http://www.mailjet.com/docs/api/api/keylist
*/
public function getKeys($key = '', $status = '', $name = '', $type = null, $isActive = null)
{
$options = array(
'api_key' => $key,
'custom_status' => $status,
'name' => $name,
);
if (null !== $type) {
$options['type'] = $type;
}
if (null !== $isActive) {
$options['active'] = $isActive;
}
return $this->client->get(RequestApi::API_KEY_LIST, $options);
}
/**
* @link http://www.mailjet.com/docs/api/api/keysecret
*/
public function getSecretForKey($key)
{
return $this->client->get(RequestApi::API_KEY_SECRET, array(
'apiKey' => $key
));
}
/**
* @link http://www.mailjet.com/docs/api/api/keysecretchange
*/
public function resetSecretForKey($key)
{
return $this->client->post(RequestApi::API_KEY_SECRET_CHANGE, array(
'apiKey' => $key
));
}
}