-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelastic-email-api.php
More file actions
49 lines (37 loc) · 1.16 KB
/
elastic-email-api.php
File metadata and controls
49 lines (37 loc) · 1.16 KB
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
<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
class Elastic_Email_Api {
private $api_key;
private $api_base_url = 'https://api.elasticemail.com/v2/';
public function __construct($api_key) {
$this->api_key = $api_key;
}
private function make_request($endpoint, $data = array()) {
$url = $this->api_base_url . $endpoint;
$data['apikey'] = $this->api_key;
$response = wp_remote_post($url, array(
'body' => $data,
));
if (is_wp_error($response)) {
return false;
}
$body = wp_remote_retrieve_body($response);
$result = json_decode($body);
if ($result->success) {
return $result->data;
}
return false;
}
public function get_sub_account_list($email) {
return $this->make_request('account/getsubaccountlist', array('email' => $email));
}
public function get_summary($from, $to, $subaccount_email) {
return $this->make_request('log/summary', array(
'from' => $from,
'to' => $to,
'subAccountEmail' => $subaccount_email,
));
}
}