-
Notifications
You must be signed in to change notification settings - Fork 106
/
csrest_administrators.php
110 lines (101 loc) · 4.38 KB
/
csrest_administrators.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
109
110
<?php
require_once dirname(__FILE__).'/class/base_classes.php';
/**
* Class to access the administrator resources from the create send API.
* This class includes functions to add and remove administrators,
* along with getting details for a single administrator
* @author pauld
*
*/
if (!class_exists('CS_REST_Administrators')) {
class CS_REST_Administrators extends CS_REST_Wrapper_Base {
/**
* The base route of the people resource.
* @var string
* @access private
*/
var $_admins_base_route;
/**
* Constructor.
* @param $auth_details array Authentication details to use for API calls.
* This array must take one of the following forms:
* If using OAuth to authenticate:
* array(
* 'access_token' => 'your access token',
* 'refresh_token' => 'your refresh token')
*
* Or if using an API key:
* array('api_key' => 'your api key')
* @param $protocol string The protocol to use for requests (http|https)
* @param $debug_level int The level of debugging required CS_REST_LOG_NONE | CS_REST_LOG_ERROR | CS_REST_LOG_WARNING | CS_REST_LOG_VERBOSE
* @param $host string The host to send API requests to. There is no need to change this
* @param $log CS_REST_Log The logger to use. Used for dependency injection
* @param $serialiser The serialiser to use. Used for dependency injection
* @param $transport The transport to use. Used for dependency injection
* @access public
*/
function __construct (
$auth_details,
$protocol = 'https',
$debug_level = CS_REST_LOG_NONE,
$host = 'api.createsend.com',
$log = NULL,
$serialiser = NULL,
$transport = NULL) {
parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport);
$this->_admins_base_route = $this->_base_route.'admins';
}
/**
* Adds a new administrator to the current account
* @param array $admin The administrator details to use during creation.
* This array should be of the form
* array (
* 'EmailAddress' => The new administrator email address
* 'Name' => The name of the new administrator
* )
* @access public
* @return CS_REST_Wrapper_Result A successful response will be empty
*/
function add($admin) {
return $this->post_request($this->_admins_base_route.'.json', $admin);
}
/**
* Updates details for an existing administrator associated with the current account
* @param string $email The email address of the administrator to be updated
* @param array $admin The updated administrator details to use for the update.
* This array should be of the form
* array (
* 'EmailAddress' => The new email address
* 'Name' => The updated name of the administrator
* )
* @access public
* @return CS_REST_Wrapper_Result A successful response will be empty
*/
function update($email, $admin) {
return $this->put_request($this->_admins_base_route.'.json?email='.urlencode($email), $admin);
}
/**
* Gets the details for a specific administrator
* @access public
* @return CS_REST_Wrapper_Result A successful response will be an object of the form
* {
* 'EmailAddress' => The email address of the administrator
* 'Name' => The name of the administrator
* 'Status' => The status of the administrator
* )
* }
*/
function get($email) {
return $this->get_request($this->_admins_base_route.'.json?email='.urlencode($email));
}
/**
* deletes the given administrator from the current account
* @param string $email The email address of the administrator to delete
* @access public
* @return CS_REST_Wrapper_Result A successful response will be empty
*/
function delete($email) {
return $this->delete_request($this->_admins_base_route.'.json?email='.urlencode($email));
}
}
}