097c2b6f by Jeremy Groot

update to campign monitor plugin

1 parent 51123579
Showing 69 changed files with 2235 additions and 231 deletions
1 { 1 {
2 "require": { 2 "require": {
3 "campaignmonitor/createsend-php": "^5.0" 3 "campaignmonitor/createsend-php": "^6.0"
4 } 4 }
5 } 5 }
......
1 { 1 {
2 "_readme": [ 2 "_readme": [
3 "This file locks the dependencies of your project to a known state", 3 "This file locks the dependencies of your project to a known state",
4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 "This file is @generated automatically" 5 "This file is @generated automatically"
6 ], 6 ],
7 "hash": "ac95bee6727d63b7f76eeff290c1460c", 7 "content-hash": "57adffeef0b1837401aa65c780f09e79",
8 "content-hash": "14d0d7fbb4109cdf1d2e75483963ace9",
9 "packages": [ 8 "packages": [
10 { 9 {
11 "name": "campaignmonitor/createsend-php", 10 "name": "campaignmonitor/createsend-php",
12 "version": "v5.0.2", 11 "version": "v6.1.2",
13 "source": { 12 "source": {
14 "type": "git", 13 "type": "git",
15 "url": "https://github.com/campaignmonitor/createsend-php.git", 14 "url": "https://github.com/campaignmonitor/createsend-php.git",
16 "reference": "05407e838eda316709d55011ad7328a679296988" 15 "reference": "922cec7fbc9da1508c18156db7693a6ddad7194e"
17 }, 16 },
18 "dist": { 17 "dist": {
19 "type": "zip", 18 "type": "zip",
20 "url": "https://api.github.com/repos/campaignmonitor/createsend-php/zipball/05407e838eda316709d55011ad7328a679296988", 19 "url": "https://api.github.com/repos/campaignmonitor/createsend-php/zipball/922cec7fbc9da1508c18156db7693a6ddad7194e",
21 "reference": "05407e838eda316709d55011ad7328a679296988", 20 "reference": "922cec7fbc9da1508c18156db7693a6ddad7194e",
22 "shasum": "" 21 "shasum": ""
23 }, 22 },
24 "require": { 23 "require": {
25 "php": ">=5.3.0" 24 "php": ">=5.3.0"
26 }, 25 },
27 "require-dev": { 26 "require-dev": {
28 "lastcraft/simpletest": "~1.1" 27 "simpletest/simpletest": "~1.1.3"
29 }, 28 },
30 "type": "library", 29 "type": "library",
31 "autoload": { 30 "autoload": {
...@@ -34,6 +33,7 @@ ...@@ -34,6 +33,7 @@
34 "csrest_campaigns.php", 33 "csrest_campaigns.php",
35 "csrest_clients.php", 34 "csrest_clients.php",
36 "csrest_general.php", 35 "csrest_general.php",
36 "csrest_events.php",
37 "csrest_lists.php", 37 "csrest_lists.php",
38 "csrest_people.php", 38 "csrest_people.php",
39 "csrest_segments.php", 39 "csrest_segments.php",
...@@ -41,7 +41,9 @@ ...@@ -41,7 +41,9 @@
41 "csrest_templates.php", 41 "csrest_templates.php",
42 "csrest_transactional_classicemail.php", 42 "csrest_transactional_classicemail.php",
43 "csrest_transactional_smartemail.php", 43 "csrest_transactional_smartemail.php",
44 "csrest_transactional_timeline.php" 44 "csrest_transactional_timeline.php",
45 "csrest_journeys.php",
46 "csrest_journey_emails.php"
45 ] 47 ]
46 }, 48 },
47 "notification-url": "https://packagist.org/downloads/", 49 "notification-url": "https://packagist.org/downloads/",
...@@ -62,7 +64,11 @@ ...@@ -62,7 +64,11 @@
62 "campaign", 64 "campaign",
63 "monitor" 65 "monitor"
64 ], 66 ],
65 "time": "2016-07-19 18:49:32" 67 "support": {
68 "issues": "https://github.com/campaignmonitor/createsend-php/issues",
69 "source": "https://github.com/campaignmonitor/createsend-php/tree/v6.1.2"
70 },
71 "time": "2021-10-02T04:57:43+00:00"
66 } 72 }
67 ], 73 ],
68 "packages-dev": [], 74 "packages-dev": [],
...@@ -72,5 +78,6 @@ ...@@ -72,5 +78,6 @@
72 "prefer-stable": false, 78 "prefer-stable": false,
73 "prefer-lowest": false, 79 "prefer-lowest": false,
74 "platform": [], 80 "platform": [],
75 "platform-dev": [] 81 "platform-dev": [],
82 "plugin-api-version": "2.3.0"
76 } 83 }
......
...@@ -211,6 +211,7 @@ add_action('wp_ajax_load_campaign_data', 'campaign_Monitor_LoadData'); ...@@ -211,6 +211,7 @@ add_action('wp_ajax_load_campaign_data', 'campaign_Monitor_LoadData');
211 211
212 function campaign_Monitor_LoadData() 212 function campaign_Monitor_LoadData()
213 { 213 {
214
214 $action = $_POST['action']; 215 $action = $_POST['action'];
215 $year = $_POST['year']; 216 $year = $_POST['year'];
216 217
...@@ -223,12 +224,15 @@ function campaign_Monitor_LoadData() ...@@ -223,12 +224,15 @@ function campaign_Monitor_LoadData()
223 $apiKey = get_option('cm_api_key'); 224 $apiKey = get_option('cm_api_key');
224 225
225 if ($clientID !== false && $apiKey !== false) { 226 if ($clientID !== false && $apiKey !== false) {
227
226 $auth = array('api_key' => $apiKey); 228 $auth = array('api_key' => $apiKey);
227 $wrap = new CS_REST_Clients( 229 $wrap = new CS_REST_Clients(
228 $clientID, 230 $clientID,
229 $auth 231 $auth
230 ); 232 );
233
231 $result = $wrap->get_campaigns(); 234 $result = $wrap->get_campaigns();
235 // var_dump($result);exit;
232 if ($result->was_successful()) { 236 if ($result->was_successful()) {
233 set_transient('cm_' . $clientID, serialize($result->response), DAY_IN_SECONDS); 237 set_transient('cm_' . $clientID, serialize($result->response), DAY_IN_SECONDS);
234 } else { 238 } else {
...@@ -260,6 +264,7 @@ function campaign_Monitor_LoadData() ...@@ -260,6 +264,7 @@ function campaign_Monitor_LoadData()
260 } 264 }
261 265
262 $results = get_posts($args); 266 $results = get_posts($args);
267
263 foreach ($results as $post) : setup_postdata($post); 268 foreach ($results as $post) : setup_postdata($post);
264 wp_delete_post($post->ID, true); 269 wp_delete_post($post->ID, true);
265 endforeach; 270 endforeach;
...@@ -268,6 +273,7 @@ function campaign_Monitor_LoadData() ...@@ -268,6 +273,7 @@ function campaign_Monitor_LoadData()
268 $campaignItemArray = campaign_Monitor_GetData('DESC'); 273 $campaignItemArray = campaign_Monitor_GetData('DESC');
269 /** @var campaignItemClass $campaignItemObject */ 274 /** @var campaignItemClass $campaignItemObject */
270 foreach ($campaignItemArray as $campaignItemObject) { 275 foreach ($campaignItemArray as $campaignItemObject) {
276
271 $itemYear = (int)date("Y", strtotime($campaignItemObject->getItemDate())); 277 $itemYear = (int)date("Y", strtotime($campaignItemObject->getItemDate()));
272 if($itemYear == $year) { 278 if($itemYear == $year) {
273 $dom = new DOMDocument; 279 $dom = new DOMDocument;
...@@ -285,7 +291,7 @@ function campaign_Monitor_LoadData() ...@@ -285,7 +291,7 @@ function campaign_Monitor_LoadData()
285 $DivContent = $DOMxpath->query("//div"); 291 $DivContent = $DOMxpath->query("//div");
286 $postContent = $DivContent->item(0)->textContent; 292 $postContent = $DivContent->item(0)->textContent;
287 $cm_post = [ 293 $cm_post = [
288 'post_title' => $campaignItemObject->getItemName(), 294 'post_title' => $campaignItemObject->item->Subject,
289 'post_type' => 'campaign', 295 'post_type' => 'campaign',
290 'post_status' => 'publish', 296 'post_status' => 'publish',
291 'post_content' => utf8_decode($postContent), 297 'post_content' => utf8_decode($postContent),
......
...@@ -2,6 +2,24 @@ ...@@ -2,6 +2,24 @@
2 2
3 // autoload.php @generated by Composer 3 // autoload.php @generated by Composer
4 4
5 if (PHP_VERSION_ID < 50600) {
6 if (!headers_sent()) {
7 header('HTTP/1.1 500 Internal Server Error');
8 }
9 $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10 if (!ini_get('display_errors')) {
11 if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12 fwrite(STDERR, $err);
13 } elseif (!headers_sent()) {
14 echo $err;
15 }
16 }
17 trigger_error(
18 $err,
19 E_USER_ERROR
20 );
21 }
22
5 require_once __DIR__ . '/composer/autoload_real.php'; 23 require_once __DIR__ . '/composer/autoload_real.php';
6 24
7 return ComposerAutoloaderInite6414526548bbe1d789ba4acd123ef7d::getLoader(); 25 return ComposerAutoloaderInite6414526548bbe1d789ba4acd123ef7d::getLoader();
......
1 language: php 1 language: php
2 2
3 php: 3 matrix:
4 - 5.3 4 include:
5 - 5.4 5 - php: 5.3
6 - 5.5 6 dist: precise
7 - 5.6 7 - php: 5.4
8 - 7.0 8 dist: trusty
9 - hhvm 9 - php: 5.5
10 dist: trusty
11 - php: 5.6
12 - php: 7.0
13 - php: 7.1
14 - php: 7.2
15 - php: 7.3
16 - php: 7.4
17 - php: hhvm-3.30
10 18
11 before_script: composer install --dev 19 before_script: composer install --dev
12 script: cd tests && php all_tests.php && cd .. 20 script: cd tests && php all_tests.php && cd ..
......
1 # createsend-php history 1 # createsend-php history
2 2
3 ## v6.1.2 - 2nd Oct, 2021
4
5 * Changed local API timeout from 20 secs to 120 secs to cater for changes on get segment subscribers API endpoint.
6
7 ## v6.1.1 - 6th May, 2020
8
9 * Add PHP 7.4 Support
10
11 ## v6.1.0 - 3rd September, 2019
12
13 * Added support for the Journeys API (https://www.campaignmonitor.com/api/journeys/)
14
15 ## v6.0.0 - 23 May, 2018
16
17 * Upgrades to Createsend API v3.2 which includes new breaking changes
18 * Breaking: 'Consent to track' field is now mandatory for sending smart and classic transactionl emails
19 * Breaking: 'Consent to track' field is now mandatory when adding or updating subscribers
20 * Optional 'Include tracking preference' field when retrieving lists of subscribers
21
22 ## v5.1.3 - 15th May, 2017
23
24 * Changed local API timeout from 10 sec to 20 sec
25
26 ## v5.1.2 - 15th May, 2017
27
28 * Added support for Behavioral Event data
29
3 ## v5.0.2 - 18 July, 2016 30 ## v5.0.2 - 18 July, 2016
4 31
5 * Prevent definition re-declarations 32 * Prevent definition re-declarations
......
1 # createsend [![Build Status](https://secure.travis-ci.org/campaignmonitor/createsend-php.png)][travis] 1 # createsend [![Build Status](https://app.travis-ci.com/campaignmonitor/createsend-php.svg?branch=master)](https://app.travis-ci.com/campaignmonitor/createsend-php)
2 A PHP library which implements the complete functionality of the [Campaign Monitor API](http://www.campaignmonitor.com/api/). 2 A PHP library which implements the complete functionality of the [Campaign Monitor API](http://www.campaignmonitor.com/api/).
3 3
4 [travis]: http://travis-ci.org/campaignmonitor/createsend-php
5
6 ## Installation 4 ## Installation
7 5
8 If you use [Composer](http://getcomposer.org/), you can add [campaignmonitor/createsend-php](https://packagist.org/packages/campaignmonitor/createsend-php) to your `composer.json` file: 6 ### Composer
7 If you use [Composer](http://getcomposer.org/), you can run the following command from the root of your project:
8
9 ```
10 composer require campaignmonitor/createsend-php
11 ```
12
13 Or add [campaignmonitor/createsend-php](https://packagist.org/packages/campaignmonitor/createsend-php) to your `composer.json` file:
9 14
10 ```json 15 ```json
11 { 16 {
...@@ -15,6 +20,13 @@ If you use [Composer](http://getcomposer.org/), you can add [campaignmonitor/cre ...@@ -15,6 +20,13 @@ If you use [Composer](http://getcomposer.org/), you can add [campaignmonitor/cre
15 } 20 }
16 ``` 21 ```
17 22
23 Followed by running:
24
25 ```
26 composer update
27 ```
28
29 ### Manual Installation
18 Otherwise you can simply [download](https://github.com/campaignmonitor/createsend-php/tags) the library and include it in your project. 30 Otherwise you can simply [download](https://github.com/campaignmonitor/createsend-php/tags) the library and include it in your project.
19 31
20 After you have installed the library, simply include the relevant API class, as follows: 32 After you have installed the library, simply include the relevant API class, as follows:
...@@ -120,6 +132,8 @@ $wrap = new CS_REST_General($auth); ...@@ -120,6 +132,8 @@ $wrap = new CS_REST_General($auth);
120 $result = $wrap->get_clients(); 132 $result = $wrap->get_clients();
121 var_dump($result->response); 133 var_dump($result->response);
122 ``` 134 ```
135 ## API Call Timeout
136 You can set your local API call timeout time in createsend-php\class\transport.php line 11, in the CS_REST_CALL_TIMEOUT variable. Currently the default is 120 secs.
123 137
124 ## Examples 138 ## Examples
125 139
......
...@@ -4,7 +4,7 @@ require_once dirname(__FILE__).'/serialisation.php'; ...@@ -4,7 +4,7 @@ require_once dirname(__FILE__).'/serialisation.php';
4 require_once dirname(__FILE__).'/transport.php'; 4 require_once dirname(__FILE__).'/transport.php';
5 require_once dirname(__FILE__).'/log.php'; 5 require_once dirname(__FILE__).'/log.php';
6 6
7 defined('CS_REST_WRAPPER_VERSION') or define('CS_REST_WRAPPER_VERSION', '5.0.2'); 7 defined('CS_REST_WRAPPER_VERSION') or define('CS_REST_WRAPPER_VERSION', '6.1.2');
8 defined('CS_HOST') or define('CS_HOST', 'api.createsend.com'); 8 defined('CS_HOST') or define('CS_HOST', 'api.createsend.com');
9 defined('CS_OAUTH_BASE_URI') or define('CS_OAUTH_BASE_URI', 'https://'.CS_HOST.'/oauth'); 9 defined('CS_OAUTH_BASE_URI') or define('CS_OAUTH_BASE_URI', 'https://'.CS_HOST.'/oauth');
10 defined('CS_OAUTH_TOKEN_URI') or define('CS_OAUTH_TOKEN_URI', CS_OAUTH_BASE_URI.'/token'); 10 defined('CS_OAUTH_TOKEN_URI') or define('CS_OAUTH_TOKEN_URI', CS_OAUTH_BASE_URI.'/token');
...@@ -146,7 +146,7 @@ if (!class_exists('CS_REST_Wrapper_Base')) { ...@@ -146,7 +146,7 @@ if (!class_exists('CS_REST_Wrapper_Base')) {
146 $this->_log = is_null($log) ? new CS_REST_Log($debug_level) : $log; 146 $this->_log = is_null($log) ? new CS_REST_Log($debug_level) : $log;
147 147
148 $this->_protocol = $protocol; 148 $this->_protocol = $protocol;
149 $this->_base_route = $protocol.'://'.$host.'/api/v3.1/'; 149 $this->_base_route = $protocol.'://'.$host.'/api/v3.2/';
150 150
151 $this->_log->log_message('Creating wrapper for '.$this->_base_route, get_class($this), CS_REST_LOG_VERBOSE); 151 $this->_log->log_message('Creating wrapper for '.$this->_base_route, get_class($this), CS_REST_LOG_VERBOSE);
152 152
...@@ -164,13 +164,14 @@ if (!class_exists('CS_REST_Wrapper_Base')) { ...@@ -164,13 +164,14 @@ if (!class_exists('CS_REST_Wrapper_Base')) {
164 164
165 $this->_default_call_options = array ( 165 $this->_default_call_options = array (
166 'authdetails' => $auth_details, 166 'authdetails' => $auth_details,
167 'userAgent' => 'CS_REST_Wrapper v'.CS_REST_WRAPPER_VERSION. 167 'userAgent' => 'createsend-php v'.CS_REST_WRAPPER_VERSION.
168 ' PHPv'.phpversion().' over '.$transport_type.' with '.$this->_serialiser->get_type(), 168 ' PHPv'.phpversion().' over '.$transport_type.' with '.$this->_serialiser->get_type(),
169 'contentType' => 'application/json; charset=utf-8', 169 'contentType' => 'application/json; charset=utf-8',
170 'deserialise' => true, 170 'deserialise' => true,
171 'host' => $host, 171 'host' => $host,
172 'protocol' => $protocol 172 'protocol' => $protocol
173 ); 173 );
174
174 } 175 }
175 176
176 /** 177 /**
...@@ -230,7 +231,13 @@ if (!class_exists('CS_REST_Wrapper_Base')) { ...@@ -230,7 +231,13 @@ if (!class_exists('CS_REST_Wrapper_Base')) {
230 return $this->_call($call_options, CS_REST_DELETE, $route); 231 return $this->_call($call_options, CS_REST_DELETE, $route);
231 } 232 }
232 233
233 function get_request($route, $call_options = array()) { 234 function get_request($route, $include_tracking_pref = NULL, $call_options = array()) {
235
236 if(isset($include_tracking_pref)
237 && is_bool($include_tracking_pref)) {
238 $route .= '&includeTrackingPreference='.($include_tracking_pref ? "true" : "false");
239 }
240
234 return $this->_call($call_options, CS_REST_GET, $route); 241 return $this->_call($call_options, CS_REST_GET, $route);
235 } 242 }
236 243
...@@ -247,29 +254,36 @@ if (!class_exists('CS_REST_Wrapper_Base')) { ...@@ -247,29 +254,36 @@ if (!class_exists('CS_REST_Wrapper_Base')) {
247 return $this->get_request($route); 254 return $this->get_request($route);
248 } 255 }
249 256
250 function get_request_paged($route, $page_number, $page_size, $order_field, $order_direction, 257 function get_request_paged($route, $page_number, $page_size, $order_field, $order_direction, $include_tracking_pref = NULL,
251 $join_char = '&') { 258 $join_char = 'deprecated') {
259 // Stores our query values
260 $query = array();
261 // Extract any initial queries in the route into our local query
262 if(strpos($route, '?') !== false) {
263 $parts = parse_url($route);
264 $route = current(explode('?', $route));
265 if(array_key_exists('query', $parts) && !empty($parts['query'])) {
266 parse_str($parts['query'], $query);
267 }
268 }
269 // Now selectively add supplied vars to the query
252 if(!is_null($page_number)) { 270 if(!is_null($page_number)) {
253 $route .= $join_char.'page='.$page_number; 271 $query['page'] = $page_number;
254 $join_char = '&';
255 } 272 }
256
257 if(!is_null($page_size)) { 273 if(!is_null($page_size)) {
258 $route .= $join_char.'pageSize='.$page_size; 274 $query['pageSize'] = $page_size;
259 $join_char = '&';
260 } 275 }
261
262 if(!is_null($order_field)) { 276 if(!is_null($order_field)) {
263 $route .= $join_char.'orderField='.$order_field; 277 $query['orderField'] = $order_field;
264 $join_char = '&';
265 } 278 }
266
267 if(!is_null($order_direction)) { 279 if(!is_null($order_direction)) {
268 $route .= $join_char.'orderDirection='.$order_direction; 280 $query['orderDirection'] = $order_direction;
269 $join_char = '&';
270 } 281 }
271 282 // If we ended up with a query, add it back to the route
272 return $this->get_request($route); 283 if(!empty($query)) {
284 $route .= '?'.http_build_query($query);
285 }
286 return $this->get_request($route, $include_tracking_pref);
273 } 287 }
274 288
275 /** 289 /**
......
1 <?php 1 <?php
2 2
3 if (!class_exists('Services_JSON', false)) {
4 require_once dirname(__FILE__).'/services_json.php';
5 }
6
7 if(!function_exists("CS_REST_SERIALISATION_get_available")) { 3 if(!function_exists("CS_REST_SERIALISATION_get_available")) {
8 function CS_REST_SERIALISATION_get_available($log) { 4 function CS_REST_SERIALISATION_get_available($log) {
9 $log->log_message('Getting serialiser', __FUNCTION__, CS_REST_LOG_VERBOSE); 5 $log->log_message('Getting serialiser', __FUNCTION__, CS_REST_LOG_VERBOSE);
...@@ -53,6 +49,7 @@ if (!class_exists('CS_REST_BaseSerialiser')) { ...@@ -53,6 +49,7 @@ if (!class_exists('CS_REST_BaseSerialiser')) {
53 49
54 if (!class_exists('CS_REST_DoNothingSerialiser')) { 50 if (!class_exists('CS_REST_DoNothingSerialiser')) {
55 class CS_REST_DoNothingSerialiser extends CS_REST_BaseSerialiser { 51 class CS_REST_DoNothingSerialiser extends CS_REST_BaseSerialiser {
52 function __construct() {}
56 function get_type() { return 'do_nothing'; } 53 function get_type() { return 'do_nothing'; }
57 function serialise($data) { return $data; } 54 function serialise($data) { return $data; }
58 function deserialise($text) { 55 function deserialise($text) {
...@@ -106,6 +103,10 @@ if (!class_exists('CS_REST_ServicesJsonSerialiser')) { ...@@ -106,6 +103,10 @@ if (!class_exists('CS_REST_ServicesJsonSerialiser')) {
106 103
107 function __construct($log) { 104 function __construct($log) {
108 parent::__construct($log); 105 parent::__construct($log);
106 if (!class_exists('Services_JSON', false)) {
107 require_once dirname(__FILE__).'/services_json.php';
108 }
109
109 $this->_serialiser = new Services_JSON(); 110 $this->_serialiser = new Services_JSON();
110 } 111 }
111 112
......
...@@ -153,7 +153,7 @@ if (!class_exists('Services_JSON')) { ...@@ -153,7 +153,7 @@ if (!class_exists('Services_JSON')) {
153 return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); 153 return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
154 } 154 }
155 155
156 $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); 156 $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
157 157
158 switch(true) { 158 switch(true) {
159 case ((0x7F & $bytes) == $bytes): 159 case ((0x7F & $bytes) == $bytes):
...@@ -206,17 +206,17 @@ if (!class_exists('Services_JSON')) { ...@@ -206,17 +206,17 @@ if (!class_exists('Services_JSON')) {
206 case 2: 206 case 2:
207 // return a UTF-16 character from a 2-byte UTF-8 char 207 // return a UTF-16 character from a 2-byte UTF-8 char
208 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 208 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
209 return chr(0x07 & (ord($utf8{0}) >> 2)) 209 return chr(0x07 & (ord($utf8[0]) >> 2))
210 . chr((0xC0 & (ord($utf8{0}) << 6)) 210 . chr((0xC0 & (ord($utf8[0]) << 6))
211 | (0x3F & ord($utf8{1}))); 211 | (0x3F & ord($utf8[1])));
212 212
213 case 3: 213 case 3:
214 // return a UTF-16 character from a 3-byte UTF-8 char 214 // return a UTF-16 character from a 3-byte UTF-8 char
215 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 215 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
216 return chr((0xF0 & (ord($utf8{0}) << 4)) 216 return chr((0xF0 & (ord($utf8[0]) << 4))
217 | (0x0F & (ord($utf8{1}) >> 2))) 217 | (0x0F & (ord($utf8[1]) >> 2)))
218 . chr((0xC0 & (ord($utf8{1}) << 6)) 218 . chr((0xC0 & (ord($utf8[1]) << 6))
219 | (0x7F & ord($utf8{2}))); 219 | (0x7F & ord($utf8[2])));
220 } 220 }
221 221
222 // ignoring UTF-32 for now, sorry 222 // ignoring UTF-32 for now, sorry
...@@ -261,7 +261,7 @@ if (!class_exists('Services_JSON')) { ...@@ -261,7 +261,7 @@ if (!class_exists('Services_JSON')) {
261 */ 261 */
262 for ($c = 0; $c < $strlen_var; ++$c) { 262 for ($c = 0; $c < $strlen_var; ++$c) {
263 263
264 $ord_var_c = ord($var{$c}); 264 $ord_var_c = ord($var[$c]);
265 265
266 switch (true) { 266 switch (true) {
267 case $ord_var_c == 0x08: 267 case $ord_var_c == 0x08:
...@@ -284,18 +284,18 @@ if (!class_exists('Services_JSON')) { ...@@ -284,18 +284,18 @@ if (!class_exists('Services_JSON')) {
284 case $ord_var_c == 0x2F: 284 case $ord_var_c == 0x2F:
285 case $ord_var_c == 0x5C: 285 case $ord_var_c == 0x5C:
286 // double quote, slash, slosh 286 // double quote, slash, slosh
287 $ascii .= '\\'.$var{$c}; 287 $ascii .= '\\'.$var[$c];
288 break; 288 break;
289 289
290 case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): 290 case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
291 // characters U-00000000 - U-0000007F (same as ASCII) 291 // characters U-00000000 - U-0000007F (same as ASCII)
292 $ascii .= $var{$c}; 292 $ascii .= $var[$c];
293 break; 293 break;
294 294
295 case (($ord_var_c & 0xE0) == 0xC0): 295 case (($ord_var_c & 0xE0) == 0xC0):
296 // characters U-00000080 - U-000007FF, mask 110XXXXX 296 // characters U-00000080 - U-000007FF, mask 110XXXXX
297 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 297 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
298 $char = pack('C*', $ord_var_c, ord($var{$c + 1})); 298 $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
299 $c += 1; 299 $c += 1;
300 $utf16 = $this->utf82utf16($char); 300 $utf16 = $this->utf82utf16($char);
301 $ascii .= sprintf('\u%04s', bin2hex($utf16)); 301 $ascii .= sprintf('\u%04s', bin2hex($utf16));
...@@ -305,8 +305,8 @@ if (!class_exists('Services_JSON')) { ...@@ -305,8 +305,8 @@ if (!class_exists('Services_JSON')) {
305 // characters U-00000800 - U-0000FFFF, mask 1110XXXX 305 // characters U-00000800 - U-0000FFFF, mask 1110XXXX
306 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 306 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307 $char = pack('C*', $ord_var_c, 307 $char = pack('C*', $ord_var_c,
308 ord($var{$c + 1}), 308 ord($var[$c + 1]),
309 ord($var{$c + 2})); 309 ord($var[$c + 2]));
310 $c += 2; 310 $c += 2;
311 $utf16 = $this->utf82utf16($char); 311 $utf16 = $this->utf82utf16($char);
312 $ascii .= sprintf('\u%04s', bin2hex($utf16)); 312 $ascii .= sprintf('\u%04s', bin2hex($utf16));
...@@ -316,9 +316,9 @@ if (!class_exists('Services_JSON')) { ...@@ -316,9 +316,9 @@ if (!class_exists('Services_JSON')) {
316 // characters U-00010000 - U-001FFFFF, mask 11110XXX 316 // characters U-00010000 - U-001FFFFF, mask 11110XXX
317 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 317 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
318 $char = pack('C*', $ord_var_c, 318 $char = pack('C*', $ord_var_c,
319 ord($var{$c + 1}), 319 ord($var[$c + 1]),
320 ord($var{$c + 2}), 320 ord($var[$c + 2]),
321 ord($var{$c + 3})); 321 ord($var[$c + 3]));
322 $c += 3; 322 $c += 3;
323 $utf16 = $this->utf82utf16($char); 323 $utf16 = $this->utf82utf16($char);
324 $ascii .= sprintf('\u%04s', bin2hex($utf16)); 324 $ascii .= sprintf('\u%04s', bin2hex($utf16));
...@@ -328,10 +328,10 @@ if (!class_exists('Services_JSON')) { ...@@ -328,10 +328,10 @@ if (!class_exists('Services_JSON')) {
328 // characters U-00200000 - U-03FFFFFF, mask 111110XX 328 // characters U-00200000 - U-03FFFFFF, mask 111110XX
329 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 329 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
330 $char = pack('C*', $ord_var_c, 330 $char = pack('C*', $ord_var_c,
331 ord($var{$c + 1}), 331 ord($var[$c + 1]),
332 ord($var{$c + 2}), 332 ord($var[$c + 2]),
333 ord($var{$c + 3}), 333 ord($var[$c + 3]),
334 ord($var{$c + 4})); 334 ord($var[$c + 4]));
335 $c += 4; 335 $c += 4;
336 $utf16 = $this->utf82utf16($char); 336 $utf16 = $this->utf82utf16($char);
337 $ascii .= sprintf('\u%04s', bin2hex($utf16)); 337 $ascii .= sprintf('\u%04s', bin2hex($utf16));
...@@ -341,11 +341,11 @@ if (!class_exists('Services_JSON')) { ...@@ -341,11 +341,11 @@ if (!class_exists('Services_JSON')) {
341 // characters U-04000000 - U-7FFFFFFF, mask 1111110X 341 // characters U-04000000 - U-7FFFFFFF, mask 1111110X
342 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 342 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
343 $char = pack('C*', $ord_var_c, 343 $char = pack('C*', $ord_var_c,
344 ord($var{$c + 1}), 344 ord($var[$c + 1]),
345 ord($var{$c + 2}), 345 ord($var[$c + 2]),
346 ord($var{$c + 3}), 346 ord($var[$c + 3]),
347 ord($var{$c + 4}), 347 ord($var[$c + 4]),
348 ord($var{$c + 5})); 348 ord($var[$c + 5]));
349 $c += 5; 349 $c += 5;
350 $utf16 = $this->utf82utf16($char); 350 $utf16 = $this->utf82utf16($char);
351 $ascii .= sprintf('\u%04s', bin2hex($utf16)); 351 $ascii .= sprintf('\u%04s', bin2hex($utf16));
...@@ -520,7 +520,7 @@ if (!class_exists('Services_JSON')) { ...@@ -520,7 +520,7 @@ if (!class_exists('Services_JSON')) {
520 for ($c = 0; $c < $strlen_chrs; ++$c) { 520 for ($c = 0; $c < $strlen_chrs; ++$c) {
521 521
522 $substr_chrs_c_2 = substr($chrs, $c, 2); 522 $substr_chrs_c_2 = substr($chrs, $c, 2);
523 $ord_chrs_c = ord($chrs{$c}); 523 $ord_chrs_c = ord($chrs[$c]);
524 524
525 switch (true) { 525 switch (true) {
526 case $substr_chrs_c_2 == '\b': 526 case $substr_chrs_c_2 == '\b':
...@@ -550,7 +550,7 @@ if (!class_exists('Services_JSON')) { ...@@ -550,7 +550,7 @@ if (!class_exists('Services_JSON')) {
550 case $substr_chrs_c_2 == '\\/': 550 case $substr_chrs_c_2 == '\\/':
551 if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || 551 if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
552 ($delim == "'" && $substr_chrs_c_2 != '\\"')) { 552 ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
553 $utf8 .= $chrs{++$c}; 553 $utf8 .= $chrs[++$c];
554 } 554 }
555 break; 555 break;
556 556
...@@ -563,7 +563,7 @@ if (!class_exists('Services_JSON')) { ...@@ -563,7 +563,7 @@ if (!class_exists('Services_JSON')) {
563 break; 563 break;
564 564
565 case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): 565 case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
566 $utf8 .= $chrs{$c}; 566 $utf8 .= $chrs[$c];
567 break; 567 break;
568 568
569 case ($ord_chrs_c & 0xE0) == 0xC0: 569 case ($ord_chrs_c & 0xE0) == 0xC0:
...@@ -610,7 +610,7 @@ if (!class_exists('Services_JSON')) { ...@@ -610,7 +610,7 @@ if (!class_exists('Services_JSON')) {
610 } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { 610 } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
611 // array, or object notation 611 // array, or object notation
612 612
613 if ($str{0} == '[') { 613 if ($str[0] == '[') {
614 $stk = array(SERVICES_JSON_IN_ARR); 614 $stk = array(SERVICES_JSON_IN_ARR);
615 $arr = array(); 615 $arr = array();
616 } else { 616 } else {
...@@ -649,7 +649,7 @@ if (!class_exists('Services_JSON')) { ...@@ -649,7 +649,7 @@ if (!class_exists('Services_JSON')) {
649 $top = end($stk); 649 $top = end($stk);
650 $substr_chrs_c_2 = substr($chrs, $c, 2); 650 $substr_chrs_c_2 = substr($chrs, $c, 2);
651 651
652 if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { 652 if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
653 // found a comma that is not inside a string, array, etc., 653 // found a comma that is not inside a string, array, etc.,
654 // OR we've reached the end of the character list 654 // OR we've reached the end of the character list
655 $slice = substr($chrs, $top['where'], ($c - $top['where'])); 655 $slice = substr($chrs, $top['where'], ($c - $top['where']));
...@@ -691,12 +691,12 @@ if (!class_exists('Services_JSON')) { ...@@ -691,12 +691,12 @@ if (!class_exists('Services_JSON')) {
691 691
692 } 692 }
693 693
694 } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { 694 } elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
695 // found a quote, and we are not inside a string 695 // found a quote, and we are not inside a string
696 array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); 696 array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]));
697 //print("Found start of string at {$c}\n"); 697 //print("Found start of string at {$c}\n");
698 698
699 } elseif (($chrs{$c} == $top['delim']) && 699 } elseif (($chrs[$c] == $top['delim']) &&
700 ($top['what'] == SERVICES_JSON_IN_STR) && 700 ($top['what'] == SERVICES_JSON_IN_STR) &&
701 ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { 701 ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
702 // found a quote, we're in a string, and it's not escaped 702 // found a quote, we're in a string, and it's not escaped
...@@ -705,24 +705,24 @@ if (!class_exists('Services_JSON')) { ...@@ -705,24 +705,24 @@ if (!class_exists('Services_JSON')) {
705 array_pop($stk); 705 array_pop($stk);
706 //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); 706 //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
707 707
708 } elseif (($chrs{$c} == '[') && 708 } elseif (($chrs[$c] == '[') &&
709 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { 709 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
710 // found a left-bracket, and we are in an array, object, or slice 710 // found a left-bracket, and we are in an array, object, or slice
711 array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); 711 array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
712 //print("Found start of array at {$c}\n"); 712 //print("Found start of array at {$c}\n");
713 713
714 } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { 714 } elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
715 // found a right-bracket, and we're in an array 715 // found a right-bracket, and we're in an array
716 array_pop($stk); 716 array_pop($stk);
717 //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); 717 //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
718 718
719 } elseif (($chrs{$c} == '{') && 719 } elseif (($chrs[$c] == '{') &&
720 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { 720 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
721 // found a left-brace, and we are in an array, object, or slice 721 // found a left-brace, and we are in an array, object, or slice
722 array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); 722 array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
723 //print("Found start of object at {$c}\n"); 723 //print("Found start of object at {$c}\n");
724 724
725 } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { 725 } elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
726 // found a right-brace, and we're in an object 726 // found a right-brace, and we're in an object
727 array_pop($stk); 727 array_pop($stk);
728 //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); 728 //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
......
...@@ -5,10 +5,10 @@ defined('CS_REST_POST') or define('CS_REST_POST', 'POST'); ...@@ -5,10 +5,10 @@ defined('CS_REST_POST') or define('CS_REST_POST', 'POST');
5 defined('CS_REST_PUT') or define('CS_REST_PUT', 'PUT'); 5 defined('CS_REST_PUT') or define('CS_REST_PUT', 'PUT');
6 defined('CS_REST_DELETE') or define('CS_REST_DELETE', 'DELETE'); 6 defined('CS_REST_DELETE') or define('CS_REST_DELETE', 'DELETE');
7 if (false === defined('CS_REST_SOCKET_TIMEOUT')) { 7 if (false === defined('CS_REST_SOCKET_TIMEOUT')) {
8 define('CS_REST_SOCKET_TIMEOUT', 10); 8 define('CS_REST_SOCKET_TIMEOUT', 120);
9 } 9 }
10 if (false === defined('CS_REST_CALL_TIMEOUT')) { 10 if (false === defined('CS_REST_CALL_TIMEOUT')) {
11 define('CS_REST_CALL_TIMEOUT', 10); 11 define('CS_REST_CALL_TIMEOUT', 120);
12 } 12 }
13 13
14 if(!function_exists("CS_REST_TRANSPORT_get_available")) { 14 if(!function_exists("CS_REST_TRANSPORT_get_available")) {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 "php": ">=5.3.0" 16 "php": ">=5.3.0"
17 }, 17 },
18 "require-dev": { 18 "require-dev": {
19 "lastcraft/simpletest": "~1.1" 19 "simpletest/simpletest": "~1.1.3"
20 }, 20 },
21 "autoload": { 21 "autoload": {
22 "classmap": [ 22 "classmap": [
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 "csrest_campaigns.php", 24 "csrest_campaigns.php",
25 "csrest_clients.php", 25 "csrest_clients.php",
26 "csrest_general.php", 26 "csrest_general.php",
27 "csrest_events.php",
27 "csrest_lists.php", 28 "csrest_lists.php",
28 "csrest_people.php", 29 "csrest_people.php",
29 "csrest_segments.php", 30 "csrest_segments.php",
...@@ -31,8 +32,9 @@ ...@@ -31,8 +32,9 @@
31 "csrest_templates.php", 32 "csrest_templates.php",
32 "csrest_transactional_classicemail.php", 33 "csrest_transactional_classicemail.php",
33 "csrest_transactional_smartemail.php", 34 "csrest_transactional_smartemail.php",
34 "csrest_transactional_timeline.php" 35 "csrest_transactional_timeline.php",
35 36 "csrest_journeys.php",
37 "csrest_journey_emails.php"
36 ] 38 ]
37 } 39 }
38 } 40 }
......
1 { 1 {
2 "_readme": [ 2 "_readme": [
3 "This file locks the dependencies of your project to a known state", 3 "This file locks the dependencies of your project to a known state",
4 "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 ], 5 "This file is @generated automatically"
6 "hash": "eccad7521596b5fe0d81af51ab2f16a1",
7 "packages": [
8
9 ], 6 ],
7 "content-hash": "d6810a171a6fbbf05f7f1156b79fdd3d",
8 "packages": [],
10 "packages-dev": [ 9 "packages-dev": [
11 { 10 {
12 "name": "lastcraft/simpletest", 11 "name": "simpletest/simpletest",
13 "version": "1.1.0", 12 "version": "v1.1.7",
14 "source": { 13 "source": {
15 "type": "git", 14 "type": "git",
16 "url": "https://github.com/lox/simpletest", 15 "url": "https://github.com/simpletest/simpletest.git",
17 "reference": "1.1.0" 16 "reference": "2f8c466c114bdb9c11028a0c3e6d1380ae6a18dc"
18 }, 17 },
19 "dist": { 18 "dist": {
20 "type": "zip", 19 "type": "zip",
21 "url": "https://github.com/lox/simpletest/zipball/1.1.0", 20 "url": "https://api.github.com/repos/simpletest/simpletest/zipball/2f8c466c114bdb9c11028a0c3e6d1380ae6a18dc",
22 "reference": "1.1.0", 21 "reference": "2f8c466c114bdb9c11028a0c3e6d1380ae6a18dc",
23 "shasum": "" 22 "shasum": ""
24 }, 23 },
25 "require": { 24 "require": {
26 "php": ">=5.0.5" 25 "php": ">=5.0.5"
27 }, 26 },
27 "replace": {
28 "lastcraft/simpletest": "self.version",
29 "vierbergenlars/simpletest": "self.version"
30 },
28 "type": "library", 31 "type": "library",
32 "autoload": {
33 "classmap": [
34 "."
35 ]
36 },
29 "notification-url": "https://packagist.org/downloads/", 37 "notification-url": "https://packagist.org/downloads/",
30 "license": [ 38 "license": [
31 "LGPL-2.0+" 39 "LGPL-2.0+"
32 ], 40 ],
33 "authors": [ 41 "authors": [
34 { 42 {
43 "name": "Lars Vierbergen",
44 "email": "vierbergenlars@gmail.com"
45 },
46 {
47 "name": "Lachlan Donald",
48 "email": "lachlan@ljd.cc"
49 },
50 {
35 "name": "Marcus Baker", 51 "name": "Marcus Baker",
36 "email": "marcus@lastcraft.com" 52 "email": "marcus@lastcraft.com",
53 "role": "Original project lead"
54 },
55 {
56 "name": "Jason Sweat",
57 "role": "Original developer"
58 },
59 {
60 "name": "Travis Swicegood",
61 "role": "Original developer"
62 },
63 {
64 "name": "Perrick Penet",
65 "role": "Original developer"
66 },
67 {
68 "name": "Edward Z. Yang",
69 "role": "Original developer"
37 } 70 }
38 ], 71 ],
39 "description": "Unit testing, mock objects and web testing framework for PHP built around test cases.", 72 "description": "Unit testing, mock objects and web testing framework for PHP built around test cases.",
40 "homepage": "http://simpletest.org/", 73 "homepage": "http://simpletest.org/",
41 "time": "2012-06-11 22:22:54" 74 "keywords": [
42 } 75 "SimpleTest",
76 "code-coverage",
77 "selenium",
78 "testing",
79 "unit-test"
43 ], 80 ],
44 "aliases": [ 81 "time": "2015-09-21T18:19:52+00:00"
45 82 }
46 ], 83 ],
84 "aliases": [],
47 "minimum-stability": "stable", 85 "minimum-stability": "stable",
48 "stability-flags": [ 86 "stability-flags": [],
49 87 "prefer-stable": false,
50 ], 88 "prefer-lowest": false,
51 "platform": { 89 "platform": {
52 "php": ">=5.3.0" 90 "php": ">=5.3.0"
53 }, 91 },
54 "platform-dev": [ 92 "platform-dev": []
55
56 ]
57 } 93 }
......
...@@ -191,7 +191,7 @@ if (!class_exists('CS_REST_Campaigns')) { ...@@ -191,7 +191,7 @@ if (!class_exists('CS_REST_Campaigns')) {
191 function get_recipients($page_number = NULL, $page_size = NULL, $order_field = NULL, 191 function get_recipients($page_number = NULL, $page_size = NULL, $order_field = NULL,
192 $order_direction = NULL) { 192 $order_direction = NULL) {
193 return $this->get_request_paged($this->_campaigns_base_route.'recipients.json', $page_number, 193 return $this->get_request_paged($this->_campaigns_base_route.'recipients.json', $page_number,
194 $page_size, $order_field, $order_direction, '?'); 194 $page_size, $order_field, $order_direction);
195 } 195 }
196 196
197 /** 197 /**
......
...@@ -448,5 +448,22 @@ if (!class_exists('CS_REST_Clients')) { ...@@ -448,5 +448,22 @@ if (!class_exists('CS_REST_Clients')) {
448 function set_primary_contact($emailAddress) { 448 function set_primary_contact($emailAddress) {
449 return $this->put_request($this->_clients_base_route.'primarycontact.json?email=' . urlencode($emailAddress), ''); 449 return $this->put_request($this->_clients_base_route.'primarycontact.json?email=' . urlencode($emailAddress), '');
450 } 450 }
451
452
453
454 /**
455 * Gets a list of journeys for the current client
456 * @access public
457 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
458 * array({
459 * 'ListID' => The id of the list
460 * 'JourneyID' => The id of the journey
461 * 'Name' => Name of the journey
462 * 'Status' => Status of the journey
463 * })
464 */
465 function get_journeys() {
466 return $this->get_request($this->_clients_base_route.'journeys.json');
467 }
451 } 468 }
452 } 469 }
...\ No newline at end of file ...\ No newline at end of file
......
1 <?php
2 require_once dirname(__FILE__).'/class/base_classes.php';
3
4 /**
5 * Class to send event data to the create send API.
6 * @author cameronn
7 *
8 */
9 if (!class_exists('CS_REST_Events')) {
10 class CS_REST_Events extends CS_REST_Wrapper_Base {
11
12 /**
13 * The base route of the clients resource.
14 * @var string
15 * @access private
16 */
17 var $_events_base_route;
18
19 /**
20 * The type of event supports 'shopify', 'identify' and 'custom'
21 * @var string
22 * @access private
23 */
24 private $_event_type;
25
26 /**
27 * Client ID
28 * @var string
29 * @access private
30 */
31 private $_client_id;
32
33 /**
34 * Anonymous ID
35 * @var string
36 * @access private
37 */
38 private $_anonymous_id;
39
40 /**
41 * User ID
42 * @var string
43 * @access private
44 */
45 private $_user_id;
46
47 /**
48 * Email address
49 * @var string
50 * @access private
51 */
52 private $_email;
53
54 /**
55 * Indicates invalid Event
56 * @var bool
57 * @access private
58 */
59 private $_invalid_event = false;
60
61 /**
62 * Constructor.
63 *
64 * @param $auth_details array Authentication details to use for API calls.
65 * This array must take one of the following forms:
66 * If using OAuth to authenticate:
67 * array(
68 * 'access_token' => 'your access token',
69 * 'refresh_token' => 'your refresh token')
70 *
71 * Or if using an API key:
72 * array('api_key' => 'your api key')
73 * @param $client_id string The client id to send event to
74 * @param $event_type string The event type we support - `custom`, `identify` and `shopify`
75 * @param $protocol string The protocol to use for requests (http|https)
76 * @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
77 * @param $host string The host to send API requests to. There is no need to change this
78 * @param $log CS_REST_Log The logger to use. Used for dependency injection
79 * @param $serialiser The serialiser to use. Used for dependency injection
80 * @param $transport The transport to use. Used for dependency injection
81 * @access public
82 */
83 function __construct (
84 $auth_details,
85 $client_id,
86 $event_type,
87 $protocol = 'https',
88 $debug_level = CS_REST_LOG_NONE,
89 $host = 'api.createsend.com',
90 $log = NULL,
91 $serialiser = NULL,
92 $transport = NULL) {
93 parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport);
94 $this->set_client_id($client_id);
95 if (!isset($event_type)) {
96 trigger_error('$event_type should be one of \'custom\', \'identify\' or \'shopify\'');
97 }
98 $this->setEventType($event_type);
99 }
100
101 /**
102 * Change the client id used for calls after construction
103 * @param $client_id
104 * @access public
105 */
106 function set_client_id($client_id) {
107 if (!isset($client_id)) {
108 trigger_error('$client_id needs to be set');
109 }
110 $this->_events_base_route = $this->_base_route.'events/'.$client_id.'/';
111 $this->_client_id = $client_id;
112 }
113
114 /**
115 * Set the type of event that we support: 'custom', 'identify' and 'shopify'
116 * @param $event_type string Event that we support: 'custom', 'identify' and 'shopify'
117 * @access private
118 */
119 private function setEventType($event_type) {
120 if (!isset($event_type)) {
121 trigger_error('$event_type needs to be set');
122 return new CS_REST_Wrapper_Result(null, 400);
123 }
124
125 if (strcmp($event_type, "custom") !== 0 &&
126 strcmp($event_type,"identify") !== 0 &&
127 strcmp($event_type,"shopify") !== 0) {
128 trigger_error('$event_type needs to be one of \'custom\', \'identify\' or \'shopify\'');
129 $this->_invalid_event = true;
130 return new CS_REST_Wrapper_Result(null, 400);
131 }
132 $this->_event_type = $event_type;
133 }
134
135
136 /*
137 * Validate email address
138 * @param $email string email address
139 * @access private
140 */
141 private function validateEmail($email) {
142 if (!isset($email)) {
143 trigger_error('$email needs to be set');
144 return new CS_REST_Wrapper_Result(null, 400);
145 }
146
147 if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
148 trigger_error('$email needs to be a valid email address');
149 return new CS_REST_Wrapper_Result(null, 400);
150 }
151
152 return $email;
153 }
154
155 /**
156 * Get the event type name
157 * @access public
158 */
159 function getEventType() {
160 return $this->_event_type;
161 }
162
163 /**
164 * Tracks an event
165 * @param string $email required email in the form "user@example.com"
166 *
167 * @param string $event_name. Name to group events by for reporting max length 1000
168 * For example "Page View", "Order confirmation"
169 *
170 * @param array $data optional. Event payload.
171 * This should be an array, with details of the event
172 * array(
173 * 'RandomFieldObject' => array(
174 * 'Example'' => 'test'
175 * ),
176 * 'RandomFieldURL' => 'Example',
177 * 'RandomArray' => array(1,3,5,6,7),
178 * )
179 * @param $anonymous_id string Anonymous ID to use for identify events
180 * @param $user_id string User ID to use for identify events
181 * @access public
182 * @return CS_REST_Wrapper_Result A successful response will include an Event ID.
183 * array(
184 * array(
185 * 'EventID' => 'string'
186 * )
187 * )
188 */
189 function track($email, $event_name, $anonymous_id = NULL, $user_id = NULL, $data = NULL)
190 {
191 // Basic validation
192 if (!isset($event_name)) {
193 trigger_error('$event_name needs to be set');
194 return new CS_REST_Wrapper_Result(null, 400);
195 }
196 if (strlen($event_name) > 1000) {
197 trigger_error('$event_name needs to be shorter, max length is 1000 bytes');
198 return new CS_REST_Wrapper_Result(null, 400);
199 }
200 if (isset($data)) {
201 if (!is_array($data)) {
202 trigger_error('$data needs to be a valid array');
203 return new CS_REST_Wrapper_Result(null, 400);
204 }
205 }
206 if (empty($data)) {
207 $data = NULL;
208 }
209
210 if (strcmp($this->_event_type, "identify") === 0) {
211 return $this->sendIdentifyTrack($email, $event_name, $anonymous_id, $user_id, $data);
212 } elseif (strcmp($this->_event_type, "custom") === 0 || strcmp($this->_event_type, "shopify") === 0) {
213 return $this->sendNonIdentifyTrack($email, $event_name, $anonymous_id, $user_id, $data);
214 }
215
216 trigger_error('event type is invalid. Supported - custom, identify or shopify');
217 return new CS_REST_Wrapper_Result(null, 400);
218 }
219
220 /*
221 * Send identify track event
222 * @param $email string email address
223 * @param $event_name string event name
224 * @param $anonymousId string anonymous id
225 * @param $userId string user id
226 * @param $data array event data
227 * @access private
228 */
229 private function sendIdentifyTrack($email, $event_name, $anonymousId, $userId, $data) {
230 if (!isset($email)) {
231 trigger_error('email needs to be a set for identify event');
232 return new CS_REST_Wrapper_Result(null, 400);
233 }
234 $minRequiredParam = 1; // anonymous id / user id
235 $paramPresent = 0;
236 if (isset($anonymousId)) {
237 $paramPresent += 1;
238 }
239 if (isset($userId)) {
240 $paramPresent += 1;
241 }
242
243 if ($paramPresent < $minRequiredParam) {
244 trigger_error('at least one of: anonymous id, user id needs to be set and be a valid string for identify event');
245 return new CS_REST_Wrapper_Result(null, 400);
246 }
247
248 $this->_anonymous_id = $anonymousId;
249 $this->_email = $this->validateEmail($email);
250 $this->_user_id = $userId;
251
252 $payload = array(
253 'ContactID' =>
254 array(
255 'Email' => $this->_email,
256 'AnonymousID' => $this->_anonymous_id,
257 'UserID' => $this->_user_id,
258 ),
259 'EventName' => $event_name,
260 'Data' => $data
261 );
262 return $this->sendTrack($payload);
263 }
264
265 /*
266 * Send non-identify track event (custom or shopify)
267 * @param $email string email
268 * @param $event_name string event name
269 * @param $data array event data
270 */
271 private function sendNonIdentifyTrack($email, $event_name, $anonymousId, $userId, $data) {
272 $paramPresent = 0;
273 if (isset($email)) {
274 $this->_email = $this->validateEmail($email);
275 $paramPresent += 1;
276 } else {
277 $this->_email = NULL;
278 }
279 $minRequiredParam = 1; // anonymous id / user id / email
280 if (isset($anonymousId)) {
281 $paramPresent += 1;
282 }
283 if (isset($userId)) {
284 $paramPresent += 1;
285 }
286
287 if ($paramPresent < $minRequiredParam) {
288 trigger_error('at least one of: anonymous id, user id, email needs to be set and be a valid string for identify event');
289 return new CS_REST_Wrapper_Result(null, 400);
290 }
291
292 $this->_anonymous_id = $anonymousId;
293 $this->_user_id = $userId;
294
295 $payload = array(
296 'ContactID' =>
297 array(
298 'Email' => $this->_email,
299 'AnonymousID' => $this->_anonymous_id,
300 'UserID' => $this->_user_id
301 ),
302 'EventName' => $event_name,
303 'Data' => $data
304 );
305 return $this->sendTrack($payload);
306 }
307
308 /*
309 * Send track event payload
310 * @param $payload array Payload to send to track endpoint
311 * @access private
312 */
313 private function sendTrack($payload) {
314 if ($this->_invalid_event) {
315 trigger_error('$event_type must be one of \'identify\', \'custom\' or \'shopify\'');
316 return new CS_REST_Wrapper_Result(null, 400);
317 }
318 // Basic validation before finally POST'ing
319 if (!isset($this->_base_route) || !isset($this->_event_type) || !isset($this->_client_id)) {
320 trigger_error('one of: $_base_route, $_event_type, $_client_id is missing during URL construction');
321 return new CS_REST_Wrapper_Result(null, 400);
322 }
323 if (isset($payload) && is_array($payload)) {
324 $event_url = $this->_base_route . 'events/' . $this->_event_type . '/' . $this->_client_id . '/track';
325 return $this->post_request($event_url, $payload);
326 }
327 trigger_error('$payload needs to be a valid array');
328 return new CS_REST_Wrapper_Result(null, 400);
329 }
330 }
331 }
332
1 <?php
2 require_once dirname(__FILE__).'/class/base_classes.php';
3
4 /**
5 * Class to access a journey resource from the create send API.
6 * This class includes functions to retrieve journey information,such as summaries,
7 * recipients, opens, clicks etc.
8 * @author peterv
9 *
10 */
11
12 if (!class_exists('CS_REST_JourneyEmails')) {
13 class CS_REST_JourneyEmails extends CS_REST_Wrapper_Base {
14
15 /**
16 * The base route of the lists resource.
17 * @var string
18 * @access private
19 */
20 var $_journey_emails_base_route;
21
22 /**
23 * Constructor.
24 * @param $journey_id string The journey id to access
25 * @param $auth_details array Authentication details to use for API calls.
26 * This array must take one of the following forms:
27 * If using OAuth to authenticate:
28 * array(
29 * 'access_token' => 'your access token',
30 * 'refresh_token' => 'your refresh token')
31 *
32 * Or if using an API key:
33 * array('api_key' => 'your api key')
34 * @param $protocol string The protocol to use for requests (http|https)
35 * @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
36 * @param $host string The host to send API requests to. There is no need to change this
37 * @param $log CS_REST_Log The logger to use. Used for dependency injection
38 * @param $serialiser The serialiser to use. Used for dependency injection
39 * @param $transport The transport to use. Used for dependency injection
40 * @access public
41 */
42
43 function __construct (
44 $email_id,
45 $auth_details,
46 $protocol = 'https',
47 $debug_level = CS_REST_LOG_NONE,
48 $host = 'api.createsend.com',
49 $log = NULL,
50 $serialiser = NULL,
51 $transport = NULL) {
52
53 parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport);
54 $this->set_email_id($email_id);
55 }
56
57
58 /**
59 * Change the email id used for calls after construction
60 * @param $email_id
61 * @access public
62 */
63 function set_email_id($email_id) {
64 $this->_journey_emails_base_route = $this->_base_route.'journeys/email/'.$email_id;
65 }
66
67
68
69 /**
70 * Gets all email addresses from the journey email id specified
71 * @param string $since The date to start getting bounces from
72 * @param int $page_number The page number to get
73 * @param int $page_size The number of records per page
74 * @param string $order_field Not used
75 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
76 * @access public
77 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
78 * {
79
80 * 'ResultsOrderedBy' => The field the results are ordered by
81 * 'OrderDirection' => The order direction
82 * 'PageNumber' => The page number for the result set
83 * 'PageSize' => The page size used
84 * 'RecordsOnThisPage' => The number of records returned
85 * 'TotalNumberOfRecords' => The total number of records available
86 * 'NumberOfPages' => The total number of pages for this collection
87 * 'Results' => array(
88 * {
89 * 'EmailAddress' => The email address of the subscriber
90 * 'SentDate' => The date the subscriber was sent the mailing
91 * }
92 * )
93 * }
94 */
95
96 function get_journey_recipients($since = '', $page_number = NULL, $page_size = NULL, $order_field = NULL,
97 $order_direction = NULL) {
98 return $this->get_request_paged($this->_journey_emails_base_route.'/recipients.json?date='.urlencode($since), $page_number,
99 $page_size, $order_field, $order_direction);
100 }
101
102
103 /**
104 * Gets all recipients from the journey email id specified
105 * @param string $since The date to start getting bounces from
106 * @param int $page_number The page number to get
107 * @param int $page_size The number of records per page
108 * @param string $order_field Not used
109 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
110 * @access public
111 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
112 * {
113
114 * 'ResultsOrderedBy' => The field the results are ordered by
115 * 'OrderDirection' => The order direction
116 * 'PageNumber' => The page number for the result set
117 * 'PageSize' => The page size used
118 * 'RecordsOnThisPage' => The number of records returned
119 * 'TotalNumberOfRecords' => The total number of records available
120 * 'NumberOfPages' => The total number of pages for this collection
121 * 'Results' => array(
122 * {
123 * 'EmailAddress' => The email address of the subscriber who opened
124 * 'Date' => The date of the open
125 * 'IPAddress' => The ip address where the open originated
126 * 'Latitude' => The geocoded latitude from the IP address
127 * 'Longitude' => The geocoded longitude from the IP address
128 * 'City' => The geocoded city from the IP address
129 * 'Region' => The geocoded region from the IP address
130 * 'CountryCode' => The geocoded two letter country code from the IP address
131 * 'CountryName' => The geocoded full country name from the IP address
132 * }
133 * )
134 * }
135 */
136
137 function get_journey_opens($since = '', $page_number = NULL, $page_size = NULL, $order_field = NULL,
138 $order_direction = NULL) {
139 return $this->get_request_paged($this->_journey_emails_base_route.'/opens.json?date='.urlencode($since), $page_number,
140 $page_size, $order_field, $order_direction);
141 }
142
143 /**
144 * Gets all recipients who opened the journey email
145 * @param string $since The date to start getting bounces from
146 * @param int $page_number The page number to get
147 * @param int $page_size The number of records per page
148 * @param string $order_field Not used
149 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
150 * @access public
151 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
152 * {
153
154 * 'ResultsOrderedBy' => The field the results are ordered by
155 * 'OrderDirection' => The order direction
156 * 'PageNumber' => The page number for the result set
157 * 'PageSize' => The page size used
158 * 'RecordsOnThisPage' => The number of records returned
159 * 'TotalNumberOfRecords' => The total number of records available
160 * 'NumberOfPages' => The total number of pages for this collection
161 * 'Results' => array(
162 * {
163 * 'EmailAddress' => The email address of the subscriber who clicked
164 * 'Date' => The date of the click
165 * 'URL' => The URL of the link that was clicked
166 * 'IPAddress' => The ip address where the click originated
167 * 'Latitude' => The geocoded latitude from the IP address
168 * 'Longitude' => The geocoded longitude from the IP address
169 * 'City' => The geocoded city from the IP address
170 * 'Region' => The geocoded region from the IP address
171 * 'CountryCode' => The geocoded two letter country code from the IP address
172 * 'CountryName' => The geocoded full country name from the IP address
173 * }
174 * )
175 * }
176 */
177
178 function get_journey_clicks($since = '', $page_number = NULL, $page_size = NULL, $order_field = NULL,
179 $order_direction = NULL) {
180 return $this->get_request_paged($this->_journey_emails_base_route.'/clicks.json?date='.urlencode($since), $page_number,
181 $page_size, $order_field, $order_direction);
182 }
183
184 /**
185 * Gets all recipients who unsubscribed from the journey email
186 * @param string $since The date to start getting bounces from
187 * @param int $page_number The page number to get
188 * @param int $page_size The number of records per page
189 * @param string $order_field Not used
190 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
191 * @access public
192 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
193 * {
194
195 * 'ResultsOrderedBy' => The field the results are ordered by
196 * 'OrderDirection' => The order direction
197 * 'PageNumber' => The page number for the result set
198 * 'PageSize' => The page size used
199 * 'RecordsOnThisPage' => The number of records returned
200 * 'TotalNumberOfRecords' => The total number of records available
201 * 'NumberOfPages' => The total number of pages for this collection
202 * 'Results' => array(
203 * {
204 * 'EmailAddress' => The email address of the subscriber who unsubscribed
205 * 'Date' => The date of the unsubscribe
206 * 'IPAddress' => The ip address where the unsubscribe originated
207 * }
208 * )
209 * }
210 */
211 function get_journey_unsubscribes($since = '', $page_number = NULL, $page_size = NULL, $order_field = NULL,
212 $order_direction = NULL) {
213 return $this->get_request_paged($this->_journey_emails_base_route.'/unsubscribes.json?date='.urlencode($since), $page_number,
214 $page_size, $order_field, $order_direction);
215 }
216
217 /**
218 * Gets all recipients who bounced from the journey email send
219 * @param string $since The date to start getting bounces from
220 * @param int $page_number The page number to get
221 * @param int $page_size The number of records per page
222 * @param string $order_field Not used
223 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
224 * @access public
225 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
226 * {
227
228 * 'ResultsOrderedBy' => The field the results are ordered by
229 * 'OrderDirection' => The order direction
230 * 'PageNumber' => The page number for the result set
231 * 'PageSize' => The page size used
232 * 'RecordsOnThisPage' => The number of records returned
233 * 'TotalNumberOfRecords' => The total number of records available
234 * 'NumberOfPages' => The total number of pages for this collection
235 * 'Results' => array(
236 * {
237 * 'EmailAddress' => The email address of the subscriber who unsubscribed
238 * 'BounceType' => The bounce type
239 * 'Date' => The date of the bounce
240 * 'Reason' => The reason for the bounce
241 * }
242 * )
243 * }
244 */
245
246 function get_journey_bounces($since = '', $page_number = NULL, $page_size = NULL, $order_field = NULL,
247 $order_direction = NULL) {
248 return $this->get_request_paged($this->_journey_emails_base_route.'/bounces.json?date='.urlencode($since), $page_number,
249 $page_size, $order_field, $order_direction);
250 }
251 }
252
253 }
1 <?php
2 require_once dirname(__FILE__).'/class/base_classes.php';
3
4 /**
5 * Class to access a journey resource from the create send API.
6 * This class includes functions to retrieve journey information,such as summaries,
7 * recipients, opens, clicks etc.
8 * @author peterv
9 *
10 */
11
12 if (!class_exists('CS_REST_Journeys')) {
13 class CS_REST_Journeys extends CS_REST_Wrapper_Base {
14
15 /**
16 * The base route of the lists resource.
17 * @var string
18 * @access private
19 */
20 var $_journeys_base_route;
21
22 /**
23 * Constructor.
24 * @param $journey_id string The journey id to access
25 * @param $auth_details array Authentication details to use for API calls.
26 * This array must take one of the following forms:
27 * If using OAuth to authenticate:
28 * array(
29 * 'access_token' => 'your access token',
30 * 'refresh_token' => 'your refresh token')
31 *
32 * Or if using an API key:
33 * array('api_key' => 'your api key')
34 * @param $protocol string The protocol to use for requests (http|https)
35 * @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
36 * @param $host string The host to send API requests to. There is no need to change this
37 * @param $log CS_REST_Log The logger to use. Used for dependency injection
38 * @param $serialiser The serialiser to use. Used for dependency injection
39 * @param $transport The transport to use. Used for dependency injection
40 * @access public
41 */
42
43 function __construct (
44 $journey_id,
45 $auth_details,
46 $protocol = 'https',
47 $debug_level = CS_REST_LOG_NONE,
48 $host = 'api.createsend.com',
49 $log = NULL,
50 $serialiser = NULL,
51 $transport = NULL) {
52
53 parent::__construct($auth_details, $protocol, $debug_level, $host, $log, $serialiser, $transport);
54 $this->set_journey_id($journey_id);
55 }
56
57
58 /**
59 * Change the email id used for calls after construction
60 * @param $email_id
61 * @access public
62 */
63 function set_journey_id($journey_id) {
64 $this->_journeys_base_route = $this->_base_route.'journeys/'.$journey_id;
65 }
66
67 /**
68 * Gets the details of the current journey
69 * @access public
70 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
71 * {
72 * 'JourneyID' => The journey id
73 * 'Name' => The name of the journey
74 * 'TriggerType' => The method in which the journey was triggered
75 * 'Status' => The status of the journey
76 * 'Emails' => array(
77 * {
78 * 'EmailID' => The ID of the email attached to the journey
79 * 'Name' => The name of the email attached to the journey
80 * 'Bounced' => The number of recipients who bounced
81 * 'Clicked' => The total number of recorded clicks
82 * 'Opened' => The total number of recorded opens
83 * 'Sent' => The total recipients of the journey email
84 * 'UniqueOpened' => The number of recipients who opened
85 * 'Unsubscribed' => The number of recipients who unsubscribed
86 * }
87 * )
88 *
89 */
90
91 function get_journey_summary() {
92 return $this->get_request(trim($this->_journeys_base_route, '/').'.json');
93 }
94 }
95
96 }
...@@ -258,6 +258,7 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -258,6 +258,7 @@ if (!class_exists('CS_REST_Lists')) {
258 * @param int $page_size The number of records per page 258 * @param int $page_size The number of records per page
259 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE') 259 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE')
260 * @param string $order_direction The direction to order the record set ('ASC', 'DESC') 260 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
261 * @param boolean $include_tracking_pref Whether or not to return the ConsentToTrack value (true, false)
261 * @access public 262 * @access public
262 * @return CS_REST_Wrapper_Result A successful response will be an object of the form 263 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
263 * { 264 * {
...@@ -285,10 +286,10 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -285,10 +286,10 @@ if (!class_exists('CS_REST_Lists')) {
285 * } 286 * }
286 */ 287 */
287 function get_active_subscribers($added_since = '', $page_number = NULL, 288 function get_active_subscribers($added_since = '', $page_number = NULL,
288 $page_size = NULL, $order_field = NULL, $order_direction = NULL) { 289 $page_size = NULL, $order_field = NULL, $order_direction = NULL, $include_tracking_pref = NULL) {
289 290
290 return $this->get_request_paged($this->_lists_base_route.'active.json?date='.urlencode($added_since), 291 return $this->get_request_paged($this->_lists_base_route.'active.json?date='.urlencode($added_since),
291 $page_number, $page_size, $order_field, $order_direction); 292 $page_number, $page_size, $order_field, $order_direction, $include_tracking_pref);
292 } 293 }
293 294
294 /** 295 /**
...@@ -298,6 +299,7 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -298,6 +299,7 @@ if (!class_exists('CS_REST_Lists')) {
298 * @param int $page_size The number of records per page 299 * @param int $page_size The number of records per page
299 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE') 300 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE')
300 * @param string $order_direction The direction to order the record set ('ASC', 'DESC') 301 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
302 * @param boolean $include_tracking_pref Whether or not to return the ConsentToTrack value (true, false)
301 * @access public 303 * @access public
302 * @return CS_REST_Wrapper_Result A successful response will be an object of the form 304 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
303 * { 305 * {
...@@ -325,10 +327,10 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -325,10 +327,10 @@ if (!class_exists('CS_REST_Lists')) {
325 * } 327 * }
326 */ 328 */
327 function get_unconfirmed_subscribers($added_since = '', $page_number = NULL, 329 function get_unconfirmed_subscribers($added_since = '', $page_number = NULL,
328 $page_size = NULL, $order_field = NULL, $order_direction = NULL) { 330 $page_size = NULL, $order_field = NULL, $order_direction = NULL, $include_tracking_pref = NULL) {
329 331
330 return $this->get_request_paged($this->_lists_base_route.'unconfirmed.json?date='.urlencode($added_since), 332 return $this->get_request_paged($this->_lists_base_route.'unconfirmed.json?date='.urlencode($added_since),
331 $page_number, $page_size, $order_field, $order_direction); 333 $page_number, $page_size, $order_field, $order_direction, $include_tracking_pref);
332 } 334 }
333 335
334 /** 336 /**
...@@ -338,6 +340,7 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -338,6 +340,7 @@ if (!class_exists('CS_REST_Lists')) {
338 * @param int $page_size The number of records per page 340 * @param int $page_size The number of records per page
339 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE') 341 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE')
340 * @param string $order_direction The direction to order the record set ('ASC', 'DESC') 342 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
343 * @param boolean $include_tracking_pref Whether or not to return the ConsentToTrack value (true, false)
341 * @access public 344 * @access public
342 * @return CS_REST_Wrapper_Result A successful response will be an object of the form 345 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
343 * { 346 * {
...@@ -365,10 +368,10 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -365,10 +368,10 @@ if (!class_exists('CS_REST_Lists')) {
365 * } 368 * }
366 */ 369 */
367 function get_bounced_subscribers($bounced_since = '', $page_number = NULL, 370 function get_bounced_subscribers($bounced_since = '', $page_number = NULL,
368 $page_size = NULL, $order_field = NULL, $order_direction = NULL) { 371 $page_size = NULL, $order_field = NULL, $order_direction = NULL, $include_tracking_pref = NULL) {
369 372
370 return $this->get_request_paged($this->_lists_base_route.'bounced.json?date='.urlencode($bounced_since), 373 return $this->get_request_paged($this->_lists_base_route.'bounced.json?date='.urlencode($bounced_since),
371 $page_number, $page_size, $order_field, $order_direction); 374 $page_number, $page_size, $order_field, $order_direction, $include_tracking_pref);
372 } 375 }
373 376
374 /** 377 /**
...@@ -378,6 +381,7 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -378,6 +381,7 @@ if (!class_exists('CS_REST_Lists')) {
378 * @param int $page_size The number of records per page 381 * @param int $page_size The number of records per page
379 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE') 382 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE')
380 * @param string $order_direction The direction to order the record set ('ASC', 'DESC') 383 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
384 * @param boolean $include_tracking_pref Whether or not to return the ConsentToTrack value (true, false)
381 * @access public 385 * @access public
382 * @return CS_REST_Wrapper_Result A successful response will be an object of the form 386 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
383 * { 387 * {
...@@ -405,10 +409,10 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -405,10 +409,10 @@ if (!class_exists('CS_REST_Lists')) {
405 * } 409 * }
406 */ 410 */
407 function get_unsubscribed_subscribers($unsubscribed_since = '', $page_number = NULL, 411 function get_unsubscribed_subscribers($unsubscribed_since = '', $page_number = NULL,
408 $page_size = NULL, $order_field = NULL, $order_direction = NULL) { 412 $page_size = NULL, $order_field = NULL, $order_direction = NULL, $include_tracking_pref = NULL) {
409 413
410 return $this->get_request_paged($this->_lists_base_route.'unsubscribed.json?date='.urlencode($unsubscribed_since), 414 return $this->get_request_paged($this->_lists_base_route.'unsubscribed.json?date='.urlencode($unsubscribed_since),
411 $page_number, $page_size, $order_field, $order_direction); 415 $page_number, $page_size, $order_field, $order_direction,$include_tracking_pref);
412 } 416 }
413 417
414 /** 418 /**
...@@ -418,6 +422,7 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -418,6 +422,7 @@ if (!class_exists('CS_REST_Lists')) {
418 * @param int $page_size The number of records per page 422 * @param int $page_size The number of records per page
419 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE') 423 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE')
420 * @param string $order_direction The direction to order the record set ('ASC', 'DESC') 424 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
425 * @param boolean $include_tracking_pref Whether or not to return the ConsentToTrack value (true, false)
421 * @access public 426 * @access public
422 * @return CS_REST_Wrapper_Result A successful response will be an object of the form 427 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
423 * { 428 * {
...@@ -445,10 +450,10 @@ if (!class_exists('CS_REST_Lists')) { ...@@ -445,10 +450,10 @@ if (!class_exists('CS_REST_Lists')) {
445 * } 450 * }
446 */ 451 */
447 function get_deleted_subscribers($deleted_since = '', $page_number = NULL, 452 function get_deleted_subscribers($deleted_since = '', $page_number = NULL,
448 $page_size = NULL, $order_field = NULL, $order_direction = NULL) { 453 $page_size = NULL, $order_field = NULL, $order_direction = NULL, $include_tracking_pref = NULL) {
449 454
450 return $this->get_request_paged($this->_lists_base_route.'deleted.json?date='.urlencode($deleted_since), 455 return $this->get_request_paged($this->_lists_base_route.'deleted.json?date='.urlencode($deleted_since),
451 $page_number, $page_size, $order_field, $order_direction); 456 $page_number, $page_size, $order_field, $order_direction, $include_tracking_pref);
452 } 457 }
453 458
454 /** 459 /**
......
...@@ -172,6 +172,7 @@ if (!class_exists('CS_REST_Segments')) { ...@@ -172,6 +172,7 @@ if (!class_exists('CS_REST_Segments')) {
172 * @param int $page_size The number of records per page 172 * @param int $page_size The number of records per page
173 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE') 173 * @param string $order_field The field to order the record set by ('EMAIL', 'NAME', 'DATE')
174 * @param string $order_direction The direction to order the record set ('ASC', 'DESC') 174 * @param string $order_direction The direction to order the record set ('ASC', 'DESC')
175 * @param boolean $include_tracking_pref Whether or not to return the ConsentToTrack value (true, false)
175 * @access public 176 * @access public
176 * @return CS_REST_Wrapper_Result A successful response will be an object of the form 177 * @return CS_REST_Wrapper_Result A successful response will be an object of the form
177 * { 178 * {
...@@ -199,10 +200,10 @@ if (!class_exists('CS_REST_Segments')) { ...@@ -199,10 +200,10 @@ if (!class_exists('CS_REST_Segments')) {
199 * } 200 * }
200 */ 201 */
201 function get_subscribers($subscribed_since = '', $page_number = NULL, 202 function get_subscribers($subscribed_since = '', $page_number = NULL,
202 $page_size = NULL, $order_field = NULL, $order_direction = NULL) { 203 $page_size = NULL, $order_field = NULL, $order_direction = NULL, $include_tracking_pref = NULL) {
203 204
204 return $this->get_request_paged($this->_segments_base_route.'/active.json?date='.urlencode($subscribed_since), 205 return $this->get_request_paged($this->_segments_base_route.'/active.json?date='.urlencode($subscribed_since),
205 $page_number, $page_size, $order_field, $order_direction); 206 $page_number, $page_size, $order_field, $order_direction, $include_tracking_pref);
206 } 207 }
207 } 208 }
208 } 209 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -75,6 +75,7 @@ if (!class_exists('CS_REST_Subscribers')) { ...@@ -75,6 +75,7 @@ if (!class_exists('CS_REST_Subscribers')) {
75 * 'Value' => The value for this subscriber 75 * 'Value' => The value for this subscriber
76 * ) 76 * )
77 * ) 77 * )
78 * 'ConsentToTrack' => Subscriber tracking preference ("yes", "no")
78 * 'Resubscribe' => Whether we should resubscribe this subscriber if they already exist in the list 79 * 'Resubscribe' => Whether we should resubscribe this subscriber if they already exist in the list
79 * 'RestartSubscriptionBasedAutoResponders' => Whether we should restart subscription based auto responders which are sent when the subscriber first subscribes to a list. 80 * 'RestartSubscriptionBasedAutoResponders' => Whether we should restart subscription based auto responders which are sent when the subscriber first subscribes to a list.
80 * ) 81 * )
...@@ -102,6 +103,7 @@ if (!class_exists('CS_REST_Subscribers')) { ...@@ -102,6 +103,7 @@ if (!class_exists('CS_REST_Subscribers')) {
102 * 'Clear' => true/false (pass true to remove this custom field. in the case of a [multi-option, select many] field, pass an option in the 'Value' field to clear that option or leave Value blank to remove all options) 103 * 'Clear' => true/false (pass true to remove this custom field. in the case of a [multi-option, select many] field, pass an option in the 'Value' field to clear that option or leave Value blank to remove all options)
103 * ) 104 * )
104 * ) 105 * )
106 * 'ConsentToTrack' => Subscriber tracking preference ("yes", "no")
105 * 'Resubscribe' => Whether we should resubscribe this subscriber if they already exist in the list 107 * 'Resubscribe' => Whether we should resubscribe this subscriber if they already exist in the list
106 * 'RestartSubscriptionBasedAutoResponders' => Whether we should restart subscription based auto responders which are sent when the subscriber first subscribes to a list. 108 * 'RestartSubscriptionBasedAutoResponders' => Whether we should restart subscription based auto responders which are sent when the subscriber first subscribes to a list.
107 * ) 109 * )
...@@ -177,8 +179,8 @@ if (!class_exists('CS_REST_Subscribers')) { ...@@ -177,8 +179,8 @@ if (!class_exists('CS_REST_Subscribers')) {
177 * ) 179 * )
178 * } 180 * }
179 */ 181 */
180 function get($email) { 182 function get($email, $include_tracking_pref = NULL) {
181 return $this->get_request($this->_subscribers_base_route.'.json?email='.urlencode($email)); 183 return $this->get_request($this->_subscribers_base_route.'.json?email='.urlencode($email), $include_tracking_pref);
182 } 184 }
183 185
184 /** 186 /**
......
...@@ -105,10 +105,15 @@ if (!class_exists('CS_REST_Transactional_ClassicEmail')) { ...@@ -105,10 +105,15 @@ if (!class_exists('CS_REST_Transactional_ClassicEmail')) {
105 * ) 105 * )
106 * ) 106 * )
107 */ 107 */
108 function send($message, $group = NULL, $add_to_list_ID = NULL, $options = array()) { 108 function send($message, $group = NULL, $consent_to_track, $add_to_list_ID = NULL, $options = array()) {
109 $group_param = array( "Group" => $group); 109 $all_params = array(
110 $add_to_list_param = array( "AddRecipientsToListID" => $add_to_list_ID); 110 "Group" => $group,
111 $data = array_merge($this->_client_id_param, $message, $group_param, $add_to_list_param, $options); 111 "AddRecipientsToListID" => $add_to_list_ID,
112 "ConsentToTrack" => $consent_to_track
113 );
114 $data = array_merge(
115 $this->_client_id_param, $message, $all_params, $options
116 );
112 return $this->post_request($this->_base_route.'transactional/classicemail/send', $data); 117 return $this->post_request($this->_base_route.'transactional/classicemail/send', $data);
113 } 118 }
114 119
......
...@@ -140,8 +140,11 @@ if (!class_exists('CS_REST_Transactional_SmartEmail')) { ...@@ -140,8 +140,11 @@ if (!class_exists('CS_REST_Transactional_SmartEmail')) {
140 * ) 140 * )
141 * ) 141 * )
142 */ 142 */
143 function send($message, $add_to_list = true) { 143 function send($message, $consent_to_track, $add_to_list = true) {
144 $data = array_merge($message, array("AddRecipientsToList" => $add_to_list)); 144 $data = array_merge($message, array(
145 "AddRecipientsToList" => $add_to_list,
146 "ConsentToTrack" => $consent_to_track
147 ));
145 return $this->post_request($this->_smartemail_base_route . '/send.json', $data); 148 return $this->post_request($this->_smartemail_base_route . '/send.json', $data);
146 } 149 }
147 150
...@@ -153,7 +156,7 @@ if (!class_exists('CS_REST_Transactional_SmartEmail')) { ...@@ -153,7 +156,7 @@ if (!class_exists('CS_REST_Transactional_SmartEmail')) {
153 * "SmartEmailID" => string 156 * "SmartEmailID" => string
154 * "Name" => string 157 * "Name" => string
155 * "CreatedAt" => string 158 * "CreatedAt" => string
156 * "Status" => stirng 159 * "Status" => string
157 * "Properties" => array ( 160 * "Properties" => array (
158 * "From" =. string 161 * "From" =. string
159 * "ReplyTo" => string 162 * "ReplyTo" => string
......
1 <?php
2
3 require_once '../../csrest_clients.php';
4
5 $auth = array(
6 'access_token' => 'your access token',
7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_Clients(
9 'ClientID to get Journeys for',
10 $auth);
11
12 $result = $wrap->get_journeys();
13
14 echo "Result of /api/v3.2/clients/{id}/journeys\n<br />";
15 if($result->was_successful()) {
16 echo "Got journeys\n<br /><pre>";
17 var_dump($result->response);
18 } else {
19 echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
20 var_dump($result->response);
21 }
22 echo '</pre>';
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 require_once "../../csrest_events.php";
3
4 $auth = array("api_key" => "sample api key");
5 $client_id = "sample client id";
6 $api_event_type = "identify";
7 $wrap = new CS_REST_Events($auth, $client_id, $api_event_type);
8
9 echo "\nSending a $api_event_type event...\n";
10
11 $contact = "joe@example.org";
12 $event_type = "checkout";
13 $event_data = array(
14 "Page" => "/cart/checkout",
15 "Items" => array(
16 array(
17 "Description" => "Rubber Widget",
18 "Quantity" => 1,
19 "Price" => 300,
20 ),
21 array(
22 "Description" => "Paint 1L",
23 "Quantity" => 10,
24 "Price" => 1,
25 ),
26 ),
27 "User" => "joe@example.org",
28 "CardType" => "VISA",
29 );
30
31 if (strcmp($wrap->getEventType(), "identify") === 0) {
32 // `Identify` event
33 $anon_id = "anonymousid-0";
34 $user_id = "userid-0";
35 $result = $wrap->track($contact, $event_type, $anon_id, $user_id, $event_data);
36 } else {
37 // `Non-identify` event (custom, shopify)
38 $result = $wrap->track($contact, $event_type, NULL, NULL, $event_data);
39 }
40 echo "\nEvent Sent! Here's the response:\n";
41 var_dump($result);
42
1 <?php
2
3 require_once '../../csrest_journey_emails.php';
4
5 $auth = array(
6 'access_token' => 'your access token',
7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_JourneyEmails('Email ID to get bounces for', $auth);
9
10 //$result = $wrap->get_journey_bounces(date('Y-m-d', strtotime('-30 days')), page, page size, order direction);
11 $result = $wrap->get_journey_bounces('Get bounces since', 1, 50, 'email', 'asc');
12
13 echo "Result of GET /api/v3.2/journeys/email/{id}/bounces\n<br />";
14 if($result->was_successful()) {
15 echo "Got bounces\n<br /><pre>";
16 var_dump($result->response);
17 } else {
18 echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
19 var_dump($result->response);
20 }
21 echo '</pre>';
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 require_once '../../csrest_journey_emails.php';
4
5 $auth = array(
6 'access_token' => 'your access token',
7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_JourneyEmails('Email ID to get clicks for', $auth);
9
10 //$result = $wrap->get_journey_clicks(date('Y-m-d', strtotime('-30 days')), page, page size, order direction);
11 $result = $wrap->get_journey_clicks('Get clicks since', 1, 50, 'email', 'asc');
12
13 echo "Result of GET /api/v3.2/journeys/email/{id}/clicks\n<br />";
14 if($result->was_successful()) {
15 echo "Got clicks\n<br /><pre>";
16 var_dump($result->response);
17 } else {
18 echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
19 var_dump($result->response);
20 }
21 echo '</pre>';
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 require_once '../../csrest_journey_emails.php';
4
5 $auth = array(
6 'access_token' => 'your access token',
7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_JourneyEmails('Email ID to get opens for', $auth);
9
10 //$result = $wrap->get_journey_opens(date('Y-m-d', strtotime('-30 days')), page, page size, order direction);
11 $result = $wrap->get_journey_opens('Get opens since', 1, 50, 'email', 'asc');
12
13 echo "Result of GET /api/v3.2/journeys/email/{id}/opens\n<br />";
14 if($result->was_successful()) {
15 echo "Got opens\n<br /><pre>";
16 var_dump($result->response);
17 } else {
18 echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
19 var_dump($result->response);
20 }
21 echo '</pre>';
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 require_once '../../csrest_journey_emails.php';
4
5 $auth = array(
6 'access_token' => 'your access token',
7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_JourneyEmails('Email ID to get recipients for', $auth);
9
10 //$result = $wrap->get_journey_recipients(date('Y-m-d', strtotime('-30 days')), page, page size, order direction);
11 $result = $wrap->get_journey_recipients('Get recipients since', 1, 50, 'email', 'asc');
12
13 echo "Result of GET /api/v3.2/journeys/email/{id}/recipients\n<br />";
14 if($result->was_successful()) {
15 echo "Got recipients\n<br /><pre>";
16 var_dump($result->response);
17 } else {
18 echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
19 var_dump($result->response);
20 }
21 echo '</pre>';
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 require_once '../../csrest_journeys.php';
4
5 $auth = array(
6 'access_token' => 'your access token',
7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_Journeys('Journey ID to get the summary of', $auth);
9 $result = $wrap->get_summary();
10
11 echo "Result of GET /api/v3.2/journeys/{id}\n<br />";
12 if($result->was_successful()) {
13 echo "Got summary\n<br /><pre>";
14 var_dump($result->response);
15 } else {
16 echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
17 var_dump($result->response);
18 }
19 echo '</pre>';
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 require_once '../../csrest_journey_emails.php';
4
5 $auth = array(
6 'access_token' => 'your access token',
7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_JourneyEmails('Email ID to get unsubscribes for', $auth);
9
10 //$result = $wrap->get_journey_unsubscribes(date('Y-m-d', strtotime('-30 days')), page, page size, order direction);
11 $result = $wrap->get_journey_unsubscribes('Get unsubscribes since', 1, 50, 'email', 'asc');
12
13 echo "Result of GET /api/v3.2/journeys/email/{id}/unsubscribes\n<br />";
14 if($result->was_successful()) {
15 echo "Got unsubscribes\n<br /><pre>";
16 var_dump($result->response);
17 } else {
18 echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
19 var_dump($result->response);
20 }
21 echo '</pre>';
...\ No newline at end of file ...\ No newline at end of file
...@@ -7,7 +7,9 @@ $auth = array( ...@@ -7,7 +7,9 @@ $auth = array(
7 'refresh_token' => 'your refresh token'); 7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_Lists('List ID', $auth); 8 $wrap = new CS_REST_Lists('List ID', $auth);
9 9
10 $result = $wrap->get_active_subscribers('Added since', 1, 50, 'email', 'asc'); 10 //The 6th argument will return the tracking preference of the subscribers - 'ConsentToTrack'
11 $result = $wrap->get_active_subscribers('Added since', 1, 50, 'email', 'asc', true);
12
11 //$result = $wrap->get_active_subscribers(date('Y-m-d', strtotime('-30 days')), 13 //$result = $wrap->get_active_subscribers(date('Y-m-d', strtotime('-30 days')),
12 // page number, page size, order by, order direction); 14 // page number, page size, order by, order direction);
13 15
......
...@@ -7,7 +7,9 @@ $auth = array( ...@@ -7,7 +7,9 @@ $auth = array(
7 'refresh_token' => 'your refresh token'); 7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_Segments('Segment ID', $auth); 8 $wrap = new CS_REST_Segments('Segment ID', $auth);
9 9
10 $result = $wrap->get_subscribers('Added since', 1, 50, 'email', 'asc'); 10 //The 6th argument will return the tracking preference of the subscribers - 'ConsentToTrack'
11 $result = $wrap->get_subscribers('Added since', 1, 50, 'email', 'asc', true);
12
11 //$result = $wrap->get_subscribers(date('Y-m-d', strtotime('-30 days')), 13 //$result = $wrap->get_subscribers(date('Y-m-d', strtotime('-30 days')),
12 // page number, page size, order by, order description); 14 // page number, page size, order by, order description);
13 15
......
...@@ -27,6 +27,7 @@ $result = $wrap->add(array( ...@@ -27,6 +27,7 @@ $result = $wrap->add(array(
27 'Value' => 'Option 2' 27 'Value' => 'Option 2'
28 ) 28 )
29 ), 29 ),
30 'ConsentToTrack' => 'yes',
30 'Resubscribe' => true 31 'Resubscribe' => true
31 )); 32 ));
32 33
......
...@@ -6,7 +6,9 @@ $auth = array( ...@@ -6,7 +6,9 @@ $auth = array(
6 'access_token' => 'your access token', 6 'access_token' => 'your access token',
7 'refresh_token' => 'your refresh token'); 7 'refresh_token' => 'your refresh token');
8 $wrap = new CS_REST_Subscribers('Your list ID', $auth); 8 $wrap = new CS_REST_Subscribers('Your list ID', $auth);
9 $result = $wrap->get('Email address'); 9
10 //The 2nd argument will return the tracking preference of the subscriber - 'ConsentToTrack'
11 $result = $wrap->get('Email address', true);
10 12
11 echo "Result of GET /api/v3.1/subscribers/{list id}.{format}?email={email}\n<br />"; 13 echo "Result of GET /api/v3.1/subscribers/{list id}.{format}?email={email}\n<br />";
12 if($result->was_successful()) { 14 if($result->was_successful()) {
......
...@@ -15,6 +15,7 @@ $result = $wrap->update('Old Email Address', array( ...@@ -15,6 +15,7 @@ $result = $wrap->update('Old Email Address', array(
15 'Value' => 'Field Value' 15 'Value' => 'Field Value'
16 ) 16 )
17 ), 17 ),
18 'ConsentToTrack' => 'unchanged',
18 'Resubscribe' => true 19 'Resubscribe' => true
19 )); 20 ));
20 21
......
1 <?php 1 <?php
2 require_once "../../csrest_transactional_classicemail.php"; 2 require_once "../../csrest_transactional_classicemail.php";
3 3
4 $client_id = "Your Client ID";
4 $auth = array("api_key" => "Your API Key"); 5 $auth = array("api_key" => "Your API Key");
5 $wrap = new CS_REST_Transactional_ClassicEmail($auth); 6
7 $wrap = new CS_REST_Transactional_ClassicEmail($auth, $client_id);
6 8
7 echo "Get the list of classic groups...\n"; 9 echo "Get the list of classic groups...\n";
8 $result = $wrap->groups(); 10 $result = $wrap->groups();
......
1 <?php 1 <?php
2 require_once "../../csrest_transactional_classicemail.php"; 2 require_once "../../csrest_transactional_classicemail.php";
3 3
4 $client_id = "Your Client ID";
4 $auth = array("api_key" => "Your API Key"); 5 $auth = array("api_key" => "Your API Key");
5 $wrap = new CS_REST_Transactional_ClassicEmail($auth, NULL); 6 $wrap = new CS_REST_Transactional_ClassicEmail($auth, $client_id);
6 7
7 echo "\nSending a simple message...\n"; 8 echo "\nSending a simple message...\n";
8 9
...@@ -13,11 +14,12 @@ $simple_message = array( ...@@ -13,11 +14,12 @@ $simple_message = array(
13 "HTML" => "This is the HTML message body with a <a href='http://google.com'>link</a>." 14 "HTML" => "This is the HTML message body with a <a href='http://google.com'>link</a>."
14 ); 15 );
15 $group_name = 'PHP test group'; # optional but great for reporting, should not be unique per message 16 $group_name = 'PHP test group'; # optional but great for reporting, should not be unique per message
16 $result = $wrap->send($simple_message, $group_name); 17 $consent_to_track = 'yes'; # Valid: 'yes', 'no', 'unchanged'
18
19 $result = $wrap->send($simple_message, $group_name,$consent_to_track);
17 echo "\nSent! Here's the response:\n"; 20 echo "\nSent! Here's the response:\n";
18 var_dump($result->response); 21 var_dump($result->response);
19 22
20
21 echo "\nSending a message with all the options...\n"; 23 echo "\nSending a message with all the options...\n";
22 24
23 $complex_message = array( 25 $complex_message = array(
...@@ -48,12 +50,14 @@ $complex_message = array( ...@@ -48,12 +50,14 @@ $complex_message = array(
48 ); 50 );
49 $group_name = "PHP test group"; # optional, great for reporting, should not be unique message 51 $group_name = "PHP test group"; # optional, great for reporting, should not be unique message
50 $add_recipients_to_subscriber_list_ID = "6d0366fcee146ab9bdaf3247446bbfdd"; # optional, make sure you have permission 52 $add_recipients_to_subscriber_list_ID = "6d0366fcee146ab9bdaf3247446bbfdd"; # optional, make sure you have permission
53 $consent_to_track = 'yes'; # Valid: 'yes', 'no', 'unchanged'
54
51 $options = array( 55 $options = array(
52 "TrackOpens" => true, 56 "TrackOpens" => true,
53 "TrackClicks" => true, 57 "TrackClicks" => true,
54 "InlineCSS" => true, 58 "InlineCSS" => true,
55 ); # all are true by default, but you can override 59 ); # all are true by default, but you can override
56 $result = $wrap->send($complex_message, $group_name, $add_recipients_to_subscriber_list_ID, $options); 60 $result = $wrap->send($complex_message, $group_name, $consent_to_track, $add_recipients_to_subscriber_list_ID, $options);
57 echo "\nSent! Here's the response:\n"; 61 echo "\nSent! Here's the response:\n";
58 var_dump($result->response); 62 var_dump($result->response);
59 63
......
1 <?php 1 <?php
2 require_once "../../csrest_transactional_smartemail.php"; 2 require_once "../../csrest_transactional_smartemail.php";
3 3
4 $client_id = "Your Client ID";
4 $auth = array("api_key" => "Your API Key"); 5 $auth = array("api_key" => "Your API Key");
5 $wrap = new CS_REST_Transactional_SmartEmail(NULL, $auth); 6 $wrap = new CS_REST_Transactional_SmartEmail(NULL, $auth, $client_id);
6 7
7 echo "\nGetting the list of smart emails...\n"; 8 echo "\nGetting the list of smart emails...\n";
8 9
......
...@@ -13,7 +13,8 @@ $simple_message = array( ...@@ -13,7 +13,8 @@ $simple_message = array(
13 "username" => "janebloggs" 13 "username" => "janebloggs"
14 ), 14 ),
15 ); 15 );
16 $result = $wrap->send($simple_message); 16 $consent_to_track = 'yes'; # Valid: 'yes', 'no', 'unchanged'
17 $result = $wrap->send($simple_message, $consent_to_track);
17 echo "\nSent! Here's the response:\n"; 18 echo "\nSent! Here's the response:\n";
18 var_dump($result->response); 19 var_dump($result->response);
19 20
...@@ -47,7 +48,9 @@ $complex_message = array( ...@@ -47,7 +48,9 @@ $complex_message = array(
47 ); 48 );
48 49
49 $add_recipients_to_subscriber_list = true; 50 $add_recipients_to_subscriber_list = true;
50 $result = $wrap->send($complex_message, $add_recipients_to_subscriber_list); 51 $consent_to_track = 'yes'; # Valid: 'yes', 'no', 'unchanged'
52
53 $result = $wrap->send($complex_message, $consent_to_track, $add_recipients_to_subscriber_list);
51 echo "\nSent! Here's the response:\n"; 54 echo "\nSent! Here's the response:\n";
52 var_dump($result->response); 55 var_dump($result->response);
53 56
......
1 <?php 1 <?php
2 require_once "../../csrest_transactional_timeline.php"; 2 require_once "../../csrest_transactional_timeline.php";
3 3
4 $client_id = "Your Client ID";
4 $auth = array("api_key" => "Your API Key"); 5 $auth = array("api_key" => "Your API Key");
5 $wrap = new CS_REST_Transactional_Timeline($auth); 6 $wrap = new CS_REST_Transactional_Timeline($auth, $client_id);
6 7
7 8
8 echo "\nGetting the statistics with the default parameters...\n"; 9 echo "\nGetting the statistics with the default parameters...\n";
......
1 <?php 1 <?php
2 require_once __DIR__.'/../vendor/autoload.php'; 2 require_once __DIR__.'/../vendor/autoload.php';
3 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 3 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/mock_objects.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/mock_objects.php';
5 5
6 class AllTests extends TestSuite { 6 class AllTests extends TestSuite {
7 function AllTests() { 7 function __construct() {
8 $this->TestSuite('All Tests'); 8 parent::__construct('All Tests');
9 $this->addFile('class_tests/transport_test.php'); 9 $this->addFile('class_tests/transport_test.php');
10 $this->addFile('class_tests/response_tests.php'); 10 $this->addFile('class_tests/response_tests.php');
11 $this->addFile('csrest_test.php'); 11 $this->addFile('csrest_test.php');
...@@ -17,5 +17,8 @@ class AllTests extends TestSuite { ...@@ -17,5 +17,8 @@ class AllTests extends TestSuite {
17 $this->addFile('csrest_segments_test.php'); 17 $this->addFile('csrest_segments_test.php');
18 $this->addFile('csrest_people_test.php'); 18 $this->addFile('csrest_people_test.php');
19 $this->addFile('csrest_administrators_test.php'); 19 $this->addFile('csrest_administrators_test.php');
20 $this->addFile('csrest_events_test.php');
21 $this->addFile('csrest_journeys_test.php');
22 $this->addFile('csrest_journey_emails_test.php');
20 } 23 }
21 } 24 }
...\ No newline at end of file ...\ No newline at end of file
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../../vendor/autoload.php'; 3 require_once __DIR__.'/../../vendor/autoload.php';
4 require_once __DIR__.'/../../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../../vendor/simpletest/simpletest/autorun.php';
5 require_once '../class/serialisation.php'; 5 require_once '../class/serialisation.php';
6 require_once '../class/log.php'; 6 require_once '../class/log.php';
7 7
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../../vendor/autoload.php'; 3 require_once __DIR__.'/../../vendor/autoload.php';
4 require_once __DIR__.'/../../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../../vendor/simpletest/simpletest/autorun.php';
5 require_once '../class/transport.php'; 5 require_once '../class/transport.php';
6 require_once '../class/log.php'; 6 require_once '../class/log.php';
7 7
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
...@@ -35,6 +35,14 @@ abstract class CS_REST_TestClients extends CS_REST_TestBase { ...@@ -35,6 +35,14 @@ abstract class CS_REST_TestClients extends CS_REST_TestBase {
35 $this->general_test('get_campaigns', $call_options, $raw_result, $deserialised); 35 $this->general_test('get_campaigns', $call_options, $raw_result, $deserialised);
36 } 36 }
37 37
38 function testget_journeys() {
39 $raw_result = 'some journeys';
40 $deserialised = array('Journey 1', 'Journey 2');
41 $call_options = $this->get_call_options($this->client_base_route.'journeys.json');
42
43 $this->general_test('get_journeys', $call_options, $raw_result, $deserialised);
44 }
45
38 function testget_scheduled() { 46 function testget_scheduled() {
39 $raw_result = 'some scheduled campaigns'; 47 $raw_result = 'some scheduled campaigns';
40 $deserialised = array('Campaign 1', 'Campaign 2'); 48 $deserialised = array('Campaign 1', 'Campaign 2');
......
1 <?php
2
3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5
6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser');
8 @Mock::generate('CS_REST_CurlTransport');
9
10 class CS_REST_ApiKeyTestEvents extends CS_REST_TestEvents {
11 var $auth = array('api_key' => 'not a real api key');
12 }
13
14 class CS_REST_OAuthTestEvents extends CS_REST_TestEvents {
15 var $auth = array(
16 'access_token' => '7y872y3872i3eh',
17 'refresh_token' => 'kjw8qjd9ow8jo');
18 }
19
20 abstract class CS_REST_TestEvents extends CS_REST_TestBase {
21 var $client_id = 'fakeclientid';
22 var $events_base_route;
23 var $event_type = "identify";
24
25 function set_up_inner() {
26 $this->events_base_route = $this->base_route.'events/'.$this->client_id.'/';
27 $this->wrapper = new CS_REST_Events($this->auth, $this->client_id, $this->event_type, $this->protocol,
28 $this->log_level, $this->api_host, $this->mock_log,
29 $this->mock_serialiser, $this->mock_transport);
30 }
31
32 function testtrack() {
33 $client_id = 'fakeclientid';
34 $raw_result = 'the new event id';
35 $email = 'test@email.com';
36 $event_name = 'Widget Man!';
37 $data = array('ExampleField'=> 'Me');
38 $anon_id = 'anonid-0';
39 $user_id = 'userid-0';
40 $response_code = 202;
41
42 $call_options = $this->get_call_options($this->base_route.'events/'.$this->event_type.'/'.$this->client_id.'/track', 'POST');
43
44 // `Non-identify` event (custom, shopify)
45 $event_info = array (
46 'ContactID' => array(
47 'Email' => 'test@email.com',
48 ),
49 'EventName' => $event_name,
50 'Data' => array(
51 'ExampleField'=> 'Me'
52 )
53 );
54
55 if (strcmp($this->event_type, "identify") === 0) {
56 // `Identify` event
57 $event_info['ContactID']['AnonymousID'] = $anon_id;
58 $event_info['ContactID']['UserID'] = $user_id;
59 }
60
61 $transport_result = array (
62 'code' => $response_code,
63 'response' => $raw_result
64 );
65
66 $expected_result = new CS_REST_Wrapper_Result($raw_result, $response_code);
67
68 $call_options['data'] = 'event info was serialised to this';
69
70 $this->setup_transport_and_serialisation($transport_result, $call_options,
71 $raw_result, $raw_result, 'event info was serialised to this', $event_info, $response_code);
72
73 if (strcmp($this->event_type, "identify") == 0) {
74 $result = $this->wrapper->track($email, $event_name, $anon_id, $user_id, $data);
75 } else {
76 $result = $this->wrapper->track($email, $event_name, NULL, NULL, $data);
77 }
78
79 $this->assertIdentical($expected_result, $result);
80
81 }
82 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5
6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser');
8 @Mock::generate('CS_REST_CurlTransport');
9
10 class CS_REST_ApiKeyTestJourneyEmails extends CS_REST_TestJourneyEmails {
11 var $auth = array('api_key' => 'not a real api key');
12 }
13
14 class CS_REST_OAuthTestJourneyEmails extends CS_REST_TestJourneyEmails {
15 var $auth = array(
16 'access_token' => '7y872y3872i3eh',
17 'refresh_token' => 'kjw8qjd9ow8jo');
18 }
19
20 abstract class CS_REST_TestJourneyEmails extends CS_REST_TestBase {
21 var $journey_email_id = 'not a real email id';
22 var $journey_emails_base_route;
23
24 function set_up_inner() {
25 $this->journey_emails_base_route = $this->base_route.'journeys/email/'.$this->journey_email_id.'/';
26 $this->wrapper = new CS_REST_JourneyEmails($this->journey_email_id, $this->auth, $this->protocol, $this->log_level,
27 $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport);
28
29 }
30
31 function testget_journey_recipients() {
32 $raw_result = 'some recipients';
33 $since = '2021';
34 $response_code = 200;
35 $deserialised = array('Recipient 1', 'Recipient 2');
36 $call_options = $this->get_call_options(
37 $this->journey_emails_base_route.'opens.json?date='.$since);
38
39 $transport_result = array (
40 'code' => $response_code,
41 'response' => $raw_result
42 );
43
44 $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code);
45
46 $this->setup_transport_and_serialisation($transport_result, $call_options,
47 $deserialised, $raw_result, NULL, NULL, $response_code);
48
49 $result = $this->wrapper->get_journey_opens($since);
50
51 $this->assertIdentical($expected_result, $result);
52
53
54 }
55
56
57
58 function testget_journey_opens() {
59 $raw_result = 'some journey opens';
60 $since = '2021';
61 $response_code = 200;
62 $deserialised = array('Journey Open 1', 'Journey Open 2');
63 $call_options = $this->get_call_options(
64 $this->journey_emails_base_route.'opens.json?date='.$since);
65
66 $transport_result = array (
67 'code' => $response_code,
68 'response' => $raw_result
69 );
70
71 $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code);
72
73 $this->setup_transport_and_serialisation($transport_result, $call_options,
74 $deserialised, $raw_result, NULL, NULL, $response_code);
75
76 $result = $this->wrapper->get_journey_opens($since);
77
78 $this->assertIdentical($expected_result, $result);
79 }
80
81
82 function testget_journey_clicks() {
83 $raw_result = 'some journey clicks';
84 $since = '2021';
85 $response_code = 200;
86 $deserialised = array('Journey Click 1', 'Journey Click 2');
87 $call_options = $this->get_call_options(
88 $this->journey_emails_base_route.'clicks.json?date='.$since);
89
90 $transport_result = array (
91 'code' => $response_code,
92 'response' => $raw_result
93 );
94
95 $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code);
96
97 $this->setup_transport_and_serialisation($transport_result, $call_options,
98 $deserialised, $raw_result, NULL, NULL, $response_code);
99
100 $result = $this->wrapper->get_journey_clicks($since);
101
102 $this->assertIdentical($expected_result, $result);
103 }
104
105
106 function testget_journey_unsubscribes() {
107 $raw_result = 'some journey clicks';
108 $since = '2021';
109 $response_code = 200;
110 $deserialised = array('Journey Unsub 1','Journey Unsub 2');
111 $call_options = $this->get_call_options(
112 $this->journey_emails_base_route.'unsubscribes.json?date='.$since);
113
114 $transport_result = array (
115 'code' => $response_code,
116 'response' => $raw_result
117 );
118
119 $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code);
120
121 $this->setup_transport_and_serialisation($transport_result, $call_options,
122 $deserialised, $raw_result, NULL, NULL, $response_code);
123
124 $result = $this->wrapper->get_journey_unsubscribes($since);
125
126 $this->assertIdentical($expected_result, $result);
127 }
128
129
130
131 function testget_journey_bounces() {
132 $raw_result = 'some journey bounces';
133 $since = '2021';
134 $response_code = 200;
135 $deserialised = array('Journey Bounce 1','Journey Bounce 2');
136 $call_options = $this->get_call_options(
137 $this->journey_emails_base_route.'bounces.json?date='.$since);
138
139 $transport_result = array (
140 'code' => $response_code,
141 'response' => $raw_result
142 );
143
144 $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code);
145
146 $this->setup_transport_and_serialisation($transport_result, $call_options,
147 $deserialised, $raw_result, NULL, NULL, $response_code);
148
149 $result = $this->wrapper->get_journey_bounces($since);
150
151 $this->assertIdentical($expected_result, $result);
152 }
153
154
155
156
157
158
159 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5
6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser');
8 @Mock::generate('CS_REST_CurlTransport');
9
10 class CS_REST_ApiKeyTestJourneys extends CS_REST_TestJourneys {
11 var $auth = array('api_key' => 'not a real api key');
12 }
13
14 class CS_REST_OAuthTestJourneys extends CS_REST_TestJourneys {
15 var $auth = array(
16 'access_token' => '7y872y3872i3eh',
17 'refresh_token' => 'kjw8qjd9ow8jo');
18 }
19
20 abstract class CS_REST_TestJourneys extends CS_REST_TestBase {
21 var $journey_id = 'not a real journey id';
22 var $journey_base_route;
23
24 function set_up_inner() {
25 $this->journey_base_route = $this->base_route.'journeys/'.$this->journey_id.'/';
26 $this->wrapper = new CS_REST_Journeys($this->journey_id, $this->auth, $this->protocol, $this->log_level,
27 $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport);
28
29 }
30
31 function testget_journey_summary() {
32
33 $raw_result = 'journey details';
34 $deserialised = array(1,23,4,5);
35 $call_options = $this->get_call_options(trim($this->journey_base_route, '/').'.json');
36 $this->general_test('get_journey_summary', $call_options, $raw_result, $deserialised);
37 }
38 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
...@@ -276,6 +276,31 @@ abstract class CS_REST_TestLists extends CS_REST_TestBase { ...@@ -276,6 +276,31 @@ abstract class CS_REST_TestLists extends CS_REST_TestBase {
276 $this->assertIdentical($expected_result, $result); 276 $this->assertIdentical($expected_result, $result);
277 } 277 }
278 278
279 function testget_active_tracking() {
280 $raw_result = 'some subscribers';
281 $since = '2020';
282 $response_code = 200;
283 $deserialised = array('Subscriber 1', 'Subscriber 2');
284 $tracking_pref = 'true';
285
286 $call_options = $this->get_call_options($this->list_base_route.'active.json?date='.$since.'&includeTrackingPreference='.$tracking_pref);
287
288 $transport_result = array (
289 'code' => $response_code,
290 'response' => $raw_result
291 );
292
293 $expected_result = new CS_REST_Wrapper_Result($deserialised, $response_code);
294
295 $this->setup_transport_and_serialisation($transport_result, $call_options,
296 $deserialised, $raw_result, NULL, NULL, $response_code);
297
298 $result = $this->wrapper->get_active_subscribers($since, null, null, null, null, true);
299
300 $this->assertIdentical($expected_result, $result);
301 }
302
303
279 function testget_unconfirmed_subscribers() { 304 function testget_unconfirmed_subscribers() {
280 $raw_result = 'some subscribers'; 305 $raw_result = 'some subscribers';
281 $since = '2020'; 306 $since = '2020';
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
...@@ -120,7 +120,9 @@ abstract class CS_REST_TestSegments extends CS_REST_TestBase { ...@@ -120,7 +120,9 @@ abstract class CS_REST_TestSegments extends CS_REST_TestBase {
120 $segment_id = 'abc123'; 120 $segment_id = 'abc123';
121 $response_code = 200; 121 $response_code = 200;
122 $deserialised = array('Subscriber 1', 'Subscriber 2'); 122 $deserialised = array('Subscriber 1', 'Subscriber 2');
123 $call_options = $this->get_call_options($this->segment_base_route.'/active.json?date='); 123 $tracking_pref = 'false';
124
125 $call_options = $this->get_call_options($this->segment_base_route.'/active.json?date=&includeTrackingPreference='.$tracking_pref);
124 126
125 $transport_result = array ( 127 $transport_result = array (
126 'code' => $response_code, 128 'code' => $response_code,
...@@ -132,7 +134,7 @@ abstract class CS_REST_TestSegments extends CS_REST_TestBase { ...@@ -132,7 +134,7 @@ abstract class CS_REST_TestSegments extends CS_REST_TestBase {
132 $this->setup_transport_and_serialisation($transport_result, $call_options, 134 $this->setup_transport_and_serialisation($transport_result, $call_options,
133 $deserialised, $raw_result, NULL, NULL, $response_code); 135 $deserialised, $raw_result, NULL, NULL, $response_code);
134 136
135 $result = $this->wrapper->get_subscribers(); 137 $result = $this->wrapper->get_subscribers(null, null, null, null, null, false);
136 138
137 $this->assertIdentical($expected_result, $result); 139 $this->assertIdentical($expected_result, $result);
138 } 140 }
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
...@@ -30,18 +30,21 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase { ...@@ -30,18 +30,21 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase {
30 function testadd() { 30 function testadd() {
31 $raw_result = ''; 31 $raw_result = '';
32 32
33
33 $call_options = $this->get_call_options($this->list_base_route.'.json', 'POST'); 34 $call_options = $this->get_call_options($this->list_base_route.'.json', 'POST');
34 35
35 $subscriber = array ( 36 $subscriber = array (
36 'Email' => 'test@test.com', 37 'Email' => 'test@test.com',
37 'Name' => 'Widget Man!', 38 'Name' => 'Widget Man!',
38 'CustomFields' => array(array(1,2), array(3,4)) 39 'CustomFields' => array(array(1,2), array(3,4)),
40 'ConsentToTrack' => 'yes'
39 ); 41 );
40 42
41 $this->general_test_with_argument('add', $subscriber, $call_options, 43 $this->general_test_with_argument('add', $subscriber, $call_options,
42 $raw_result, $raw_result, 'subscriber was serialised to this'); 44 $raw_result, $raw_result, 'subscriber was serialised to this');
43 } 45 }
44 46
47
45 function testupdate() { 48 function testupdate() {
46 $raw_result = ''; 49 $raw_result = '';
47 $email = 'test@test.com'; 50 $email = 'test@test.com';
...@@ -53,7 +56,8 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase { ...@@ -53,7 +56,8 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase {
53 $subscriber = array ( 56 $subscriber = array (
54 'Email' => 'test2@test.com', 57 'Email' => 'test2@test.com',
55 'Name' => 'Widget Man!', 58 'Name' => 'Widget Man!',
56 'CustomFields' => array(array(1,2), array(3,4)) 59 'CustomFields' => array(array(1,2), array(3,4)),
60 'ConsentToTrack' => 'unchanged',
57 ); 61 );
58 62
59 $transport_result = array ( 63 $transport_result = array (
...@@ -86,12 +90,14 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase { ...@@ -86,12 +90,14 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase {
86 array ( 90 array (
87 'Email' => 'test@test.com', 91 'Email' => 'test@test.com',
88 'Name' => 'Widget Man!', 92 'Name' => 'Widget Man!',
89 'CustomFields' => array(array(1,2), array(3,4)) 93 'CustomFields' => array(array(1,2), array(3,4)),
94 'ConsentToTrack' => 'no',
90 ), 95 ),
91 array ( 96 array (
92 'Email' => 'test@test.com', 97 'Email' => 'test@test.com',
93 'Name' => 'Widget Man!', 98 'Name' => 'Widget Man!',
94 'CustomFields' => array(array(1,2), array(3,4)) 99 'CustomFields' => array(array(1,2), array(3,4)),
100 'ConsentToTrack' => 'yes',
95 ) 101 )
96 ); 102 );
97 103
...@@ -124,9 +130,10 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase { ...@@ -124,9 +130,10 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase {
124 $deserialised = array(1,2,34,5); 130 $deserialised = array(1,2,34,5);
125 $response_code = 200; 131 $response_code = 200;
126 $email = 'test@test.com'; 132 $email = 'test@test.com';
133 $tracking_pref = 'true';
127 134
128 $call_options = $this->get_call_options( 135 $call_options = $this->get_call_options(
129 $this->list_base_route.'.json?email='.urlencode($email), 'GET'); 136 $this->list_base_route.'.json?email='.urlencode($email).'&includeTrackingPreference='.$tracking_pref, 'GET');
130 137
131 $transport_result = array ( 138 $transport_result = array (
132 'code' => $response_code, 139 'code' => $response_code,
...@@ -138,7 +145,7 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase { ...@@ -138,7 +145,7 @@ abstract class CS_REST_TestSubscribers extends CS_REST_TestBase {
138 $this->setup_transport_and_serialisation($transport_result, $call_options, 145 $this->setup_transport_and_serialisation($transport_result, $call_options,
139 $deserialised, $raw_result, NULL, NULL, $response_code); 146 $deserialised, $raw_result, NULL, NULL, $response_code);
140 147
141 $result = $this->wrapper->get($email); 148 $result = $this->wrapper->get($email, true);
142 149
143 $this->assertIdentical($expected_result, $result); 150 $this->assertIdentical($expected_result, $result);
144 } 151 }
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
......
1 <?php 1 <?php
2 2
3 require_once __DIR__.'/../vendor/autoload.php'; 3 require_once __DIR__.'/../vendor/autoload.php';
4 require_once __DIR__.'/../vendor/lastcraft/simpletest/autorun.php'; 4 require_once __DIR__.'/../vendor/simpletest/simpletest/autorun.php';
5 5
6 @Mock::generate('CS_REST_Log'); 6 @Mock::generate('CS_REST_Log');
7 @Mock::generate('CS_REST_NativeJsonSerialiser'); 7 @Mock::generate('CS_REST_NativeJsonSerialiser');
...@@ -31,20 +31,21 @@ class CS_REST_TestBase extends UnitTestCase { ...@@ -31,20 +31,21 @@ class CS_REST_TestBase extends UnitTestCase {
31 $this->mock_transport->setReturnValue('get_type', $this->transport_type); 31 $this->mock_transport->setReturnValue('get_type', $this->transport_type);
32 $this->mock_serialiser->setReturnValue('get_type', $this->serialisation_type); 32 $this->mock_serialiser->setReturnValue('get_type', $this->serialisation_type);
33 33
34 $this->base_route = $this->protocol.'://'.$this->api_host.'/api/v3.1/'; 34 $this->base_route = $this->protocol.'://'.$this->api_host.'/api/v3.2/';
35 35
36 $this->set_up_inner(); 36 $this->set_up_inner();
37 } 37 }
38 38
39 function set_up_inner() { 39 function set_up_inner() {
40 $this->wrapper = new CS_REST_General($this->auth, $this->protocol, $this->log_level, 40 $this->wrapper = new CS_REST_General($this->auth, $this->protocol, $this->log_level,
41 $this->api_host, $this->mock_log, $this->mock_serialiser, $this->mock_transport); 41 $this->api_host, $this->mock_log, $this->mock_serialiser,
42 $this->mock_transport);
42 } 43 }
43 44
44 function get_call_options($route, $method = 'GET') { 45 function get_call_options($route, $method = 'GET') {
45 return array ( 46 return array (
46 'authdetails' => $this->auth, 47 'authdetails' => $this->auth,
47 'userAgent' => 'CS_REST_Wrapper v'.CS_REST_WRAPPER_VERSION. 48 'userAgent' => 'createsend-php v'.CS_REST_WRAPPER_VERSION.
48 ' PHPv'.phpversion().' over '.$this->transport_type.' with '.$this->serialisation_type, 49 ' PHPv'.phpversion().' over '.$this->transport_type.' with '.$this->serialisation_type,
49 'contentType' => 'application/json; charset=utf-8', 50 'contentType' => 'application/json; charset=utf-8',
50 'deserialise' => true, 51 'deserialise' => true,
......
1 {
2 "JourneyID": "183e5a8818d6202e95f1fa747b924226",
3 "Name": "welcome active folks",
4 "TriggerType": "Enters Segment",
5 "Status": "Active",
6 "Emails": [
7 {
8 "EmailID": "383ec87ea1129ebc5e539a2db35c3200",
9 "Name": "email",
10 "Bounced": 0,
11 "Clicked": 0,
12 "Opened": 1,
13 "Sent": 14,
14 "UniqueOpened": 1,
15 "Unsubscribed": 0
16 }
17 ]
18 }
...\ No newline at end of file ...\ No newline at end of file
1 [
2 {
3 "ListID": "abcabcabcacbabcabcabcabcabc",
4 "JourneyID": "12345678901234567890",
5 "Name": "Journey One",
6 "Status": "Active"
7 },
8 {
9 "ListID": "defdefdedefdefdefdefdefdefdef",
10 "JourneyID": "09876543210987654321",
11 "Name": "Journey Two",
12 "Status": "Active"
13 }
14 ]
...\ No newline at end of file ...\ No newline at end of file
...@@ -37,56 +37,134 @@ namespace Composer\Autoload; ...@@ -37,56 +37,134 @@ namespace Composer\Autoload;
37 * 37 *
38 * @author Fabien Potencier <fabien@symfony.com> 38 * @author Fabien Potencier <fabien@symfony.com>
39 * @author Jordi Boggiano <j.boggiano@seld.be> 39 * @author Jordi Boggiano <j.boggiano@seld.be>
40 * @see http://www.php-fig.org/psr/psr-0/ 40 * @see https://www.php-fig.org/psr/psr-0/
41 * @see http://www.php-fig.org/psr/psr-4/ 41 * @see https://www.php-fig.org/psr/psr-4/
42 */ 42 */
43 class ClassLoader 43 class ClassLoader
44 { 44 {
45 /** @var \Closure(string):void */
46 private static $includeFile;
47
48 /** @var ?string */
49 private $vendorDir;
50
45 // PSR-4 51 // PSR-4
52 /**
53 * @var array[]
54 * @psalm-var array<string, array<string, int>>
55 */
46 private $prefixLengthsPsr4 = array(); 56 private $prefixLengthsPsr4 = array();
57 /**
58 * @var array[]
59 * @psalm-var array<string, array<int, string>>
60 */
47 private $prefixDirsPsr4 = array(); 61 private $prefixDirsPsr4 = array();
62 /**
63 * @var array[]
64 * @psalm-var array<string, string>
65 */
48 private $fallbackDirsPsr4 = array(); 66 private $fallbackDirsPsr4 = array();
49 67
50 // PSR-0 68 // PSR-0
69 /**
70 * @var array[]
71 * @psalm-var array<string, array<string, string[]>>
72 */
51 private $prefixesPsr0 = array(); 73 private $prefixesPsr0 = array();
74 /**
75 * @var array[]
76 * @psalm-var array<string, string>
77 */
52 private $fallbackDirsPsr0 = array(); 78 private $fallbackDirsPsr0 = array();
53 79
80 /** @var bool */
54 private $useIncludePath = false; 81 private $useIncludePath = false;
82
83 /**
84 * @var string[]
85 * @psalm-var array<string, string>
86 */
55 private $classMap = array(); 87 private $classMap = array();
88
89 /** @var bool */
56 private $classMapAuthoritative = false; 90 private $classMapAuthoritative = false;
91
92 /**
93 * @var bool[]
94 * @psalm-var array<string, bool>
95 */
57 private $missingClasses = array(); 96 private $missingClasses = array();
58 97
98 /** @var ?string */
99 private $apcuPrefix;
100
101 /**
102 * @var self[]
103 */
104 private static $registeredLoaders = array();
105
106 /**
107 * @param ?string $vendorDir
108 */
109 public function __construct($vendorDir = null)
110 {
111 $this->vendorDir = $vendorDir;
112 self::initializeIncludeClosure();
113 }
114
115 /**
116 * @return string[]
117 */
59 public function getPrefixes() 118 public function getPrefixes()
60 { 119 {
61 if (!empty($this->prefixesPsr0)) { 120 if (!empty($this->prefixesPsr0)) {
62 return call_user_func_array('array_merge', $this->prefixesPsr0); 121 return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
63 } 122 }
64 123
65 return array(); 124 return array();
66 } 125 }
67 126
127 /**
128 * @return array[]
129 * @psalm-return array<string, array<int, string>>
130 */
68 public function getPrefixesPsr4() 131 public function getPrefixesPsr4()
69 { 132 {
70 return $this->prefixDirsPsr4; 133 return $this->prefixDirsPsr4;
71 } 134 }
72 135
136 /**
137 * @return array[]
138 * @psalm-return array<string, string>
139 */
73 public function getFallbackDirs() 140 public function getFallbackDirs()
74 { 141 {
75 return $this->fallbackDirsPsr0; 142 return $this->fallbackDirsPsr0;
76 } 143 }
77 144
145 /**
146 * @return array[]
147 * @psalm-return array<string, string>
148 */
78 public function getFallbackDirsPsr4() 149 public function getFallbackDirsPsr4()
79 { 150 {
80 return $this->fallbackDirsPsr4; 151 return $this->fallbackDirsPsr4;
81 } 152 }
82 153
154 /**
155 * @return string[] Array of classname => path
156 * @psalm-return array<string, string>
157 */
83 public function getClassMap() 158 public function getClassMap()
84 { 159 {
85 return $this->classMap; 160 return $this->classMap;
86 } 161 }
87 162
88 /** 163 /**
89 * @param array $classMap Class to filename map 164 * @param string[] $classMap Class to filename map
165 * @psalm-param array<string, string> $classMap
166 *
167 * @return void
90 */ 168 */
91 public function addClassMap(array $classMap) 169 public function addClassMap(array $classMap)
92 { 170 {
...@@ -102,8 +180,10 @@ class ClassLoader ...@@ -102,8 +180,10 @@ class ClassLoader
102 * appending or prepending to the ones previously set for this prefix. 180 * appending or prepending to the ones previously set for this prefix.
103 * 181 *
104 * @param string $prefix The prefix 182 * @param string $prefix The prefix
105 * @param array|string $paths The PSR-0 root directories 183 * @param string[]|string $paths The PSR-0 root directories
106 * @param bool $prepend Whether to prepend the directories 184 * @param bool $prepend Whether to prepend the directories
185 *
186 * @return void
107 */ 187 */
108 public function add($prefix, $paths, $prepend = false) 188 public function add($prefix, $paths, $prepend = false)
109 { 189 {
...@@ -147,10 +227,12 @@ class ClassLoader ...@@ -147,10 +227,12 @@ class ClassLoader
147 * appending or prepending to the ones previously set for this namespace. 227 * appending or prepending to the ones previously set for this namespace.
148 * 228 *
149 * @param string $prefix The prefix/namespace, with trailing '\\' 229 * @param string $prefix The prefix/namespace, with trailing '\\'
150 * @param array|string $paths The PSR-4 base directories 230 * @param string[]|string $paths The PSR-4 base directories
151 * @param bool $prepend Whether to prepend the directories 231 * @param bool $prepend Whether to prepend the directories
152 * 232 *
153 * @throws \InvalidArgumentException 233 * @throws \InvalidArgumentException
234 *
235 * @return void
154 */ 236 */
155 public function addPsr4($prefix, $paths, $prepend = false) 237 public function addPsr4($prefix, $paths, $prepend = false)
156 { 238 {
...@@ -195,7 +277,9 @@ class ClassLoader ...@@ -195,7 +277,9 @@ class ClassLoader
195 * replacing any others previously set for this prefix. 277 * replacing any others previously set for this prefix.
196 * 278 *
197 * @param string $prefix The prefix 279 * @param string $prefix The prefix
198 * @param array|string $paths The PSR-0 base directories 280 * @param string[]|string $paths The PSR-0 base directories
281 *
282 * @return void
199 */ 283 */
200 public function set($prefix, $paths) 284 public function set($prefix, $paths)
201 { 285 {
...@@ -211,9 +295,11 @@ class ClassLoader ...@@ -211,9 +295,11 @@ class ClassLoader
211 * replacing any others previously set for this namespace. 295 * replacing any others previously set for this namespace.
212 * 296 *
213 * @param string $prefix The prefix/namespace, with trailing '\\' 297 * @param string $prefix The prefix/namespace, with trailing '\\'
214 * @param array|string $paths The PSR-4 base directories 298 * @param string[]|string $paths The PSR-4 base directories
215 * 299 *
216 * @throws \InvalidArgumentException 300 * @throws \InvalidArgumentException
301 *
302 * @return void
217 */ 303 */
218 public function setPsr4($prefix, $paths) 304 public function setPsr4($prefix, $paths)
219 { 305 {
...@@ -233,6 +319,8 @@ class ClassLoader ...@@ -233,6 +319,8 @@ class ClassLoader
233 * Turns on searching the include path for class files. 319 * Turns on searching the include path for class files.
234 * 320 *
235 * @param bool $useIncludePath 321 * @param bool $useIncludePath
322 *
323 * @return void
236 */ 324 */
237 public function setUseIncludePath($useIncludePath) 325 public function setUseIncludePath($useIncludePath)
238 { 326 {
...@@ -255,6 +343,8 @@ class ClassLoader ...@@ -255,6 +343,8 @@ class ClassLoader
255 * that have not been registered with the class map. 343 * that have not been registered with the class map.
256 * 344 *
257 * @param bool $classMapAuthoritative 345 * @param bool $classMapAuthoritative
346 *
347 * @return void
258 */ 348 */
259 public function setClassMapAuthoritative($classMapAuthoritative) 349 public function setClassMapAuthoritative($classMapAuthoritative)
260 { 350 {
...@@ -272,36 +362,80 @@ class ClassLoader ...@@ -272,36 +362,80 @@ class ClassLoader
272 } 362 }
273 363
274 /** 364 /**
365 * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
366 *
367 * @param string|null $apcuPrefix
368 *
369 * @return void
370 */
371 public function setApcuPrefix($apcuPrefix)
372 {
373 $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
374 }
375
376 /**
377 * The APCu prefix in use, or null if APCu caching is not enabled.
378 *
379 * @return string|null
380 */
381 public function getApcuPrefix()
382 {
383 return $this->apcuPrefix;
384 }
385
386 /**
275 * Registers this instance as an autoloader. 387 * Registers this instance as an autoloader.
276 * 388 *
277 * @param bool $prepend Whether to prepend the autoloader or not 389 * @param bool $prepend Whether to prepend the autoloader or not
390 *
391 * @return void
278 */ 392 */
279 public function register($prepend = false) 393 public function register($prepend = false)
280 { 394 {
281 spl_autoload_register(array($this, 'loadClass'), true, $prepend); 395 spl_autoload_register(array($this, 'loadClass'), true, $prepend);
396
397 if (null === $this->vendorDir) {
398 return;
399 }
400
401 if ($prepend) {
402 self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
403 } else {
404 unset(self::$registeredLoaders[$this->vendorDir]);
405 self::$registeredLoaders[$this->vendorDir] = $this;
406 }
282 } 407 }
283 408
284 /** 409 /**
285 * Unregisters this instance as an autoloader. 410 * Unregisters this instance as an autoloader.
411 *
412 * @return void
286 */ 413 */
287 public function unregister() 414 public function unregister()
288 { 415 {
289 spl_autoload_unregister(array($this, 'loadClass')); 416 spl_autoload_unregister(array($this, 'loadClass'));
417
418 if (null !== $this->vendorDir) {
419 unset(self::$registeredLoaders[$this->vendorDir]);
420 }
290 } 421 }
291 422
292 /** 423 /**
293 * Loads the given class or interface. 424 * Loads the given class or interface.
294 * 425 *
295 * @param string $class The name of the class 426 * @param string $class The name of the class
296 * @return bool|null True if loaded, null otherwise 427 * @return true|null True if loaded, null otherwise
297 */ 428 */
298 public function loadClass($class) 429 public function loadClass($class)
299 { 430 {
300 if ($file = $this->findFile($class)) { 431 if ($file = $this->findFile($class)) {
301 includeFile($file); 432 $includeFile = self::$includeFile;
433 $includeFile($file);
302 434
303 return true; 435 return true;
304 } 436 }
437
438 return null;
305 } 439 }
306 440
307 /** 441 /**
...@@ -313,11 +447,6 @@ class ClassLoader ...@@ -313,11 +447,6 @@ class ClassLoader
313 */ 447 */
314 public function findFile($class) 448 public function findFile($class)
315 { 449 {
316 // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317 if ('\\' == $class[0]) {
318 $class = substr($class, 1);
319 }
320
321 // class map lookup 450 // class map lookup
322 if (isset($this->classMap[$class])) { 451 if (isset($this->classMap[$class])) {
323 return $this->classMap[$class]; 452 return $this->classMap[$class];
...@@ -325,6 +454,12 @@ class ClassLoader ...@@ -325,6 +454,12 @@ class ClassLoader
325 if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { 454 if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
326 return false; 455 return false;
327 } 456 }
457 if (null !== $this->apcuPrefix) {
458 $file = apcu_fetch($this->apcuPrefix.$class, $hit);
459 if ($hit) {
460 return $file;
461 }
462 }
328 463
329 $file = $this->findFileWithExtension($class, '.php'); 464 $file = $this->findFileWithExtension($class, '.php');
330 465
...@@ -333,6 +468,10 @@ class ClassLoader ...@@ -333,6 +468,10 @@ class ClassLoader
333 $file = $this->findFileWithExtension($class, '.hh'); 468 $file = $this->findFileWithExtension($class, '.hh');
334 } 469 }
335 470
471 if (null !== $this->apcuPrefix) {
472 apcu_add($this->apcuPrefix.$class, $file);
473 }
474
336 if (false === $file) { 475 if (false === $file) {
337 // Remember that this class does not exist. 476 // Remember that this class does not exist.
338 $this->missingClasses[$class] = true; 477 $this->missingClasses[$class] = true;
...@@ -341,6 +480,21 @@ class ClassLoader ...@@ -341,6 +480,21 @@ class ClassLoader
341 return $file; 480 return $file;
342 } 481 }
343 482
483 /**
484 * Returns the currently registered loaders indexed by their corresponding vendor directories.
485 *
486 * @return self[]
487 */
488 public static function getRegisteredLoaders()
489 {
490 return self::$registeredLoaders;
491 }
492
493 /**
494 * @param string $class
495 * @param string $ext
496 * @return string|false
497 */
344 private function findFileWithExtension($class, $ext) 498 private function findFileWithExtension($class, $ext)
345 { 499 {
346 // PSR-4 lookup 500 // PSR-4 lookup
...@@ -348,10 +502,14 @@ class ClassLoader ...@@ -348,10 +502,14 @@ class ClassLoader
348 502
349 $first = $class[0]; 503 $first = $class[0];
350 if (isset($this->prefixLengthsPsr4[$first])) { 504 if (isset($this->prefixLengthsPsr4[$first])) {
351 foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { 505 $subPath = $class;
352 if (0 === strpos($class, $prefix)) { 506 while (false !== $lastPos = strrpos($subPath, '\\')) {
353 foreach ($this->prefixDirsPsr4[$prefix] as $dir) { 507 $subPath = substr($subPath, 0, $lastPos);
354 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { 508 $search = $subPath . '\\';
509 if (isset($this->prefixDirsPsr4[$search])) {
510 $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
511 foreach ($this->prefixDirsPsr4[$search] as $dir) {
512 if (file_exists($file = $dir . $pathEnd)) {
355 return $file; 513 return $file;
356 } 514 }
357 } 515 }
...@@ -402,14 +560,26 @@ class ClassLoader ...@@ -402,14 +560,26 @@ class ClassLoader
402 560
403 return false; 561 return false;
404 } 562 }
405 }
406 563
407 /** 564 /**
565 * @return void
566 */
567 private static function initializeIncludeClosure()
568 {
569 if (self::$includeFile !== null) {
570 return;
571 }
572
573 /**
408 * Scope isolated include. 574 * Scope isolated include.
409 * 575 *
410 * Prevents access to $this/self from included files. 576 * Prevents access to $this/self from included files.
577 *
578 * @param string $file
579 * @return void
411 */ 580 */
412 function includeFile($file) 581 self::$includeFile = \Closure::bind(static function($file) {
413 {
414 include $file; 582 include $file;
583 }, null, null);
584 }
415 } 585 }
......
1 <?php
2
3 /*
4 * This file is part of Composer.
5 *
6 * (c) Nils Adermann <naderman@naderman.de>
7 * Jordi Boggiano <j.boggiano@seld.be>
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13 namespace Composer;
14
15 use Composer\Autoload\ClassLoader;
16 use Composer\Semver\VersionParser;
17
18 /**
19 * This class is copied in every Composer installed project and available to all
20 *
21 * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22 *
23 * To require its presence, you can require `composer-runtime-api ^2.0`
24 *
25 * @final
26 */
27 class InstalledVersions
28 {
29 /**
30 * @var mixed[]|null
31 * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
32 */
33 private static $installed;
34
35 /**
36 * @var bool|null
37 */
38 private static $canGetVendors;
39
40 /**
41 * @var array[]
42 * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
43 */
44 private static $installedByVendor = array();
45
46 /**
47 * Returns a list of all package names which are present, either by being installed, replaced or provided
48 *
49 * @return string[]
50 * @psalm-return list<string>
51 */
52 public static function getInstalledPackages()
53 {
54 $packages = array();
55 foreach (self::getInstalled() as $installed) {
56 $packages[] = array_keys($installed['versions']);
57 }
58
59 if (1 === \count($packages)) {
60 return $packages[0];
61 }
62
63 return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
64 }
65
66 /**
67 * Returns a list of all package names with a specific type e.g. 'library'
68 *
69 * @param string $type
70 * @return string[]
71 * @psalm-return list<string>
72 */
73 public static function getInstalledPackagesByType($type)
74 {
75 $packagesByType = array();
76
77 foreach (self::getInstalled() as $installed) {
78 foreach ($installed['versions'] as $name => $package) {
79 if (isset($package['type']) && $package['type'] === $type) {
80 $packagesByType[] = $name;
81 }
82 }
83 }
84
85 return $packagesByType;
86 }
87
88 /**
89 * Checks whether the given package is installed
90 *
91 * This also returns true if the package name is provided or replaced by another package
92 *
93 * @param string $packageName
94 * @param bool $includeDevRequirements
95 * @return bool
96 */
97 public static function isInstalled($packageName, $includeDevRequirements = true)
98 {
99 foreach (self::getInstalled() as $installed) {
100 if (isset($installed['versions'][$packageName])) {
101 return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
102 }
103 }
104
105 return false;
106 }
107
108 /**
109 * Checks whether the given package satisfies a version constraint
110 *
111 * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
112 *
113 * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
114 *
115 * @param VersionParser $parser Install composer/semver to have access to this class and functionality
116 * @param string $packageName
117 * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
118 * @return bool
119 */
120 public static function satisfies(VersionParser $parser, $packageName, $constraint)
121 {
122 $constraint = $parser->parseConstraints((string) $constraint);
123 $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
124
125 return $provided->matches($constraint);
126 }
127
128 /**
129 * Returns a version constraint representing all the range(s) which are installed for a given package
130 *
131 * It is easier to use this via isInstalled() with the $constraint argument if you need to check
132 * whether a given version of a package is installed, and not just whether it exists
133 *
134 * @param string $packageName
135 * @return string Version constraint usable with composer/semver
136 */
137 public static function getVersionRanges($packageName)
138 {
139 foreach (self::getInstalled() as $installed) {
140 if (!isset($installed['versions'][$packageName])) {
141 continue;
142 }
143
144 $ranges = array();
145 if (isset($installed['versions'][$packageName]['pretty_version'])) {
146 $ranges[] = $installed['versions'][$packageName]['pretty_version'];
147 }
148 if (array_key_exists('aliases', $installed['versions'][$packageName])) {
149 $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
150 }
151 if (array_key_exists('replaced', $installed['versions'][$packageName])) {
152 $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
153 }
154 if (array_key_exists('provided', $installed['versions'][$packageName])) {
155 $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
156 }
157
158 return implode(' || ', $ranges);
159 }
160
161 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
162 }
163
164 /**
165 * @param string $packageName
166 * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
167 */
168 public static function getVersion($packageName)
169 {
170 foreach (self::getInstalled() as $installed) {
171 if (!isset($installed['versions'][$packageName])) {
172 continue;
173 }
174
175 if (!isset($installed['versions'][$packageName]['version'])) {
176 return null;
177 }
178
179 return $installed['versions'][$packageName]['version'];
180 }
181
182 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
183 }
184
185 /**
186 * @param string $packageName
187 * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
188 */
189 public static function getPrettyVersion($packageName)
190 {
191 foreach (self::getInstalled() as $installed) {
192 if (!isset($installed['versions'][$packageName])) {
193 continue;
194 }
195
196 if (!isset($installed['versions'][$packageName]['pretty_version'])) {
197 return null;
198 }
199
200 return $installed['versions'][$packageName]['pretty_version'];
201 }
202
203 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
204 }
205
206 /**
207 * @param string $packageName
208 * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
209 */
210 public static function getReference($packageName)
211 {
212 foreach (self::getInstalled() as $installed) {
213 if (!isset($installed['versions'][$packageName])) {
214 continue;
215 }
216
217 if (!isset($installed['versions'][$packageName]['reference'])) {
218 return null;
219 }
220
221 return $installed['versions'][$packageName]['reference'];
222 }
223
224 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
225 }
226
227 /**
228 * @param string $packageName
229 * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
230 */
231 public static function getInstallPath($packageName)
232 {
233 foreach (self::getInstalled() as $installed) {
234 if (!isset($installed['versions'][$packageName])) {
235 continue;
236 }
237
238 return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
239 }
240
241 throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
242 }
243
244 /**
245 * @return array
246 * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
247 */
248 public static function getRootPackage()
249 {
250 $installed = self::getInstalled();
251
252 return $installed[0]['root'];
253 }
254
255 /**
256 * Returns the raw installed.php data for custom implementations
257 *
258 * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
259 * @return array[]
260 * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
261 */
262 public static function getRawData()
263 {
264 @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
265
266 if (null === self::$installed) {
267 // only require the installed.php file if this file is loaded from its dumped location,
268 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
269 if (substr(__DIR__, -8, 1) !== 'C') {
270 self::$installed = include __DIR__ . '/installed.php';
271 } else {
272 self::$installed = array();
273 }
274 }
275
276 return self::$installed;
277 }
278
279 /**
280 * Returns the raw data of all installed.php which are currently loaded for custom implementations
281 *
282 * @return array[]
283 * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
284 */
285 public static function getAllRawData()
286 {
287 return self::getInstalled();
288 }
289
290 /**
291 * Lets you reload the static array from another file
292 *
293 * This is only useful for complex integrations in which a project needs to use
294 * this class but then also needs to execute another project's autoloader in process,
295 * and wants to ensure both projects have access to their version of installed.php.
296 *
297 * A typical case would be PHPUnit, where it would need to make sure it reads all
298 * the data it needs from this class, then call reload() with
299 * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
300 * the project in which it runs can then also use this class safely, without
301 * interference between PHPUnit's dependencies and the project's dependencies.
302 *
303 * @param array[] $data A vendor/composer/installed.php data set
304 * @return void
305 *
306 * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
307 */
308 public static function reload($data)
309 {
310 self::$installed = $data;
311 self::$installedByVendor = array();
312 }
313
314 /**
315 * @return array[]
316 * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
317 */
318 private static function getInstalled()
319 {
320 if (null === self::$canGetVendors) {
321 self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
322 }
323
324 $installed = array();
325
326 if (self::$canGetVendors) {
327 foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
328 if (isset(self::$installedByVendor[$vendorDir])) {
329 $installed[] = self::$installedByVendor[$vendorDir];
330 } elseif (is_file($vendorDir.'/composer/installed.php')) {
331 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
332 $required = require $vendorDir.'/composer/installed.php';
333 $installed[] = self::$installedByVendor[$vendorDir] = $required;
334 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
335 self::$installed = $installed[count($installed) - 1];
336 }
337 }
338 }
339 }
340
341 if (null === self::$installed) {
342 // only require the installed.php file if this file is loaded from its dumped location,
343 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
344 if (substr(__DIR__, -8, 1) !== 'C') {
345 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
346 $required = require __DIR__ . '/installed.php';
347 self::$installed = $required;
348 } else {
349 self::$installed = array();
350 }
351 }
352
353 if (self::$installed !== array()) {
354 $installed[] = self::$installed;
355 }
356
357 return $installed;
358 }
359 }
1 1
2 Copyright (c) 2016 Nils Adermann, Jordi Boggiano 2 Copyright (c) Nils Adermann, Jordi Boggiano
3 3
4 Permission is hereby granted, free of charge, to any person obtaining a copy 4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal 5 of this software and associated documentation files (the "Software"), to deal
......
...@@ -2,14 +2,17 @@ ...@@ -2,14 +2,17 @@
2 2
3 // autoload_classmap.php @generated by Composer 3 // autoload_classmap.php @generated by Composer
4 4
5 $vendorDir = dirname(dirname(__FILE__)); 5 $vendorDir = dirname(__DIR__);
6 $baseDir = dirname($vendorDir); 6 $baseDir = dirname($vendorDir);
7 7
8 return array( 8 return array(
9 'CS_REST_Administrators' => $vendorDir . '/campaignmonitor/createsend-php/csrest_administrators.php', 9 'CS_REST_Administrators' => $vendorDir . '/campaignmonitor/createsend-php/csrest_administrators.php',
10 'CS_REST_Campaigns' => $vendorDir . '/campaignmonitor/createsend-php/csrest_campaigns.php', 10 'CS_REST_Campaigns' => $vendorDir . '/campaignmonitor/createsend-php/csrest_campaigns.php',
11 'CS_REST_Clients' => $vendorDir . '/campaignmonitor/createsend-php/csrest_clients.php', 11 'CS_REST_Clients' => $vendorDir . '/campaignmonitor/createsend-php/csrest_clients.php',
12 'CS_REST_Events' => $vendorDir . '/campaignmonitor/createsend-php/csrest_events.php',
12 'CS_REST_General' => $vendorDir . '/campaignmonitor/createsend-php/csrest_general.php', 13 'CS_REST_General' => $vendorDir . '/campaignmonitor/createsend-php/csrest_general.php',
14 'CS_REST_JourneyEmails' => $vendorDir . '/campaignmonitor/createsend-php/csrest_journey_emails.php',
15 'CS_REST_Journeys' => $vendorDir . '/campaignmonitor/createsend-php/csrest_journeys.php',
13 'CS_REST_Lists' => $vendorDir . '/campaignmonitor/createsend-php/csrest_lists.php', 16 'CS_REST_Lists' => $vendorDir . '/campaignmonitor/createsend-php/csrest_lists.php',
14 'CS_REST_People' => $vendorDir . '/campaignmonitor/createsend-php/csrest_people.php', 17 'CS_REST_People' => $vendorDir . '/campaignmonitor/createsend-php/csrest_people.php',
15 'CS_REST_Segments' => $vendorDir . '/campaignmonitor/createsend-php/csrest_segments.php', 18 'CS_REST_Segments' => $vendorDir . '/campaignmonitor/createsend-php/csrest_segments.php',
...@@ -18,4 +21,5 @@ return array( ...@@ -18,4 +21,5 @@ return array(
18 'CS_REST_Transactional_ClassicEmail' => $vendorDir . '/campaignmonitor/createsend-php/csrest_transactional_classicemail.php', 21 'CS_REST_Transactional_ClassicEmail' => $vendorDir . '/campaignmonitor/createsend-php/csrest_transactional_classicemail.php',
19 'CS_REST_Transactional_SmartEmail' => $vendorDir . '/campaignmonitor/createsend-php/csrest_transactional_smartemail.php', 22 'CS_REST_Transactional_SmartEmail' => $vendorDir . '/campaignmonitor/createsend-php/csrest_transactional_smartemail.php',
20 'CS_REST_Transactional_Timeline' => $vendorDir . '/campaignmonitor/createsend-php/csrest_transactional_timeline.php', 23 'CS_REST_Transactional_Timeline' => $vendorDir . '/campaignmonitor/createsend-php/csrest_transactional_timeline.php',
24 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
21 ); 25 );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 2
3 // autoload_namespaces.php @generated by Composer 3 // autoload_namespaces.php @generated by Composer
4 4
5 $vendorDir = dirname(dirname(__FILE__)); 5 $vendorDir = dirname(__DIR__);
6 $baseDir = dirname($vendorDir); 6 $baseDir = dirname($vendorDir);
7 7
8 return array( 8 return array(
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 2
3 // autoload_psr4.php @generated by Composer 3 // autoload_psr4.php @generated by Composer
4 4
5 $vendorDir = dirname(dirname(__FILE__)); 5 $vendorDir = dirname(__DIR__);
6 $baseDir = dirname($vendorDir); 6 $baseDir = dirname($vendorDir);
7 7
8 return array( 8 return array(
......
...@@ -13,37 +13,23 @@ class ComposerAutoloaderInite6414526548bbe1d789ba4acd123ef7d ...@@ -13,37 +13,23 @@ class ComposerAutoloaderInite6414526548bbe1d789ba4acd123ef7d
13 } 13 }
14 } 14 }
15 15
16 /**
17 * @return \Composer\Autoload\ClassLoader
18 */
16 public static function getLoader() 19 public static function getLoader()
17 { 20 {
18 if (null !== self::$loader) { 21 if (null !== self::$loader) {
19 return self::$loader; 22 return self::$loader;
20 } 23 }
21 24
25 require __DIR__ . '/platform_check.php';
26
22 spl_autoload_register(array('ComposerAutoloaderInite6414526548bbe1d789ba4acd123ef7d', 'loadClassLoader'), true, true); 27 spl_autoload_register(array('ComposerAutoloaderInite6414526548bbe1d789ba4acd123ef7d', 'loadClassLoader'), true, true);
23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
24 spl_autoload_unregister(array('ComposerAutoloaderInite6414526548bbe1d789ba4acd123ef7d', 'loadClassLoader')); 29 spl_autoload_unregister(array('ComposerAutoloaderInite6414526548bbe1d789ba4acd123ef7d', 'loadClassLoader'));
25 30
26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 31 require __DIR__ . '/autoload_static.php';
27 if ($useStaticLoader) {
28 require_once __DIR__ . '/autoload_static.php';
29
30 call_user_func(\Composer\Autoload\ComposerStaticInite6414526548bbe1d789ba4acd123ef7d::getInitializer($loader)); 32 call_user_func(\Composer\Autoload\ComposerStaticInite6414526548bbe1d789ba4acd123ef7d::getInitializer($loader));
31 } else {
32 $map = require __DIR__ . '/autoload_namespaces.php';
33 foreach ($map as $namespace => $path) {
34 $loader->set($namespace, $path);
35 }
36
37 $map = require __DIR__ . '/autoload_psr4.php';
38 foreach ($map as $namespace => $path) {
39 $loader->setPsr4($namespace, $path);
40 }
41
42 $classMap = require __DIR__ . '/autoload_classmap.php';
43 if ($classMap) {
44 $loader->addClassMap($classMap);
45 }
46 }
47 33
48 $loader->register(true); 34 $loader->register(true);
49 35
......
...@@ -10,7 +10,10 @@ class ComposerStaticInite6414526548bbe1d789ba4acd123ef7d ...@@ -10,7 +10,10 @@ class ComposerStaticInite6414526548bbe1d789ba4acd123ef7d
10 'CS_REST_Administrators' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_administrators.php', 10 'CS_REST_Administrators' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_administrators.php',
11 'CS_REST_Campaigns' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_campaigns.php', 11 'CS_REST_Campaigns' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_campaigns.php',
12 'CS_REST_Clients' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_clients.php', 12 'CS_REST_Clients' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_clients.php',
13 'CS_REST_Events' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_events.php',
13 'CS_REST_General' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_general.php', 14 'CS_REST_General' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_general.php',
15 'CS_REST_JourneyEmails' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_journey_emails.php',
16 'CS_REST_Journeys' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_journeys.php',
14 'CS_REST_Lists' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_lists.php', 17 'CS_REST_Lists' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_lists.php',
15 'CS_REST_People' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_people.php', 18 'CS_REST_People' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_people.php',
16 'CS_REST_Segments' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_segments.php', 19 'CS_REST_Segments' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_segments.php',
...@@ -19,6 +22,7 @@ class ComposerStaticInite6414526548bbe1d789ba4acd123ef7d ...@@ -19,6 +22,7 @@ class ComposerStaticInite6414526548bbe1d789ba4acd123ef7d
19 'CS_REST_Transactional_ClassicEmail' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_transactional_classicemail.php', 22 'CS_REST_Transactional_ClassicEmail' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_transactional_classicemail.php',
20 'CS_REST_Transactional_SmartEmail' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_transactional_smartemail.php', 23 'CS_REST_Transactional_SmartEmail' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_transactional_smartemail.php',
21 'CS_REST_Transactional_Timeline' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_transactional_timeline.php', 24 'CS_REST_Transactional_Timeline' => __DIR__ . '/..' . '/campaignmonitor/createsend-php/csrest_transactional_timeline.php',
25 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
22 ); 26 );
23 27
24 public static function getInitializer(ClassLoader $loader) 28 public static function getInitializer(ClassLoader $loader)
......
1 [ 1 {
2 "packages": [
2 { 3 {
3 "name": "campaignmonitor/createsend-php", 4 "name": "campaignmonitor/createsend-php",
4 "version": "v5.0.2", 5 "version": "v6.1.2",
5 "version_normalized": "5.0.2.0", 6 "version_normalized": "6.1.2.0",
6 "source": { 7 "source": {
7 "type": "git", 8 "type": "git",
8 "url": "https://github.com/campaignmonitor/createsend-php.git", 9 "url": "https://github.com/campaignmonitor/createsend-php.git",
9 "reference": "05407e838eda316709d55011ad7328a679296988" 10 "reference": "922cec7fbc9da1508c18156db7693a6ddad7194e"
10 }, 11 },
11 "dist": { 12 "dist": {
12 "type": "zip", 13 "type": "zip",
13 "url": "https://api.github.com/repos/campaignmonitor/createsend-php/zipball/05407e838eda316709d55011ad7328a679296988", 14 "url": "https://api.github.com/repos/campaignmonitor/createsend-php/zipball/922cec7fbc9da1508c18156db7693a6ddad7194e",
14 "reference": "05407e838eda316709d55011ad7328a679296988", 15 "reference": "922cec7fbc9da1508c18156db7693a6ddad7194e",
15 "shasum": "" 16 "shasum": ""
16 }, 17 },
17 "require": { 18 "require": {
18 "php": ">=5.3.0" 19 "php": ">=5.3.0"
19 }, 20 },
20 "require-dev": { 21 "require-dev": {
21 "lastcraft/simpletest": "~1.1" 22 "simpletest/simpletest": "~1.1.3"
22 }, 23 },
23 "time": "2016-07-19 18:49:32", 24 "time": "2021-10-02T04:57:43+00:00",
24 "type": "library", 25 "type": "library",
25 "installation-source": "dist", 26 "installation-source": "dist",
26 "autoload": { 27 "autoload": {
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
29 "csrest_campaigns.php", 30 "csrest_campaigns.php",
30 "csrest_clients.php", 31 "csrest_clients.php",
31 "csrest_general.php", 32 "csrest_general.php",
33 "csrest_events.php",
32 "csrest_lists.php", 34 "csrest_lists.php",
33 "csrest_people.php", 35 "csrest_people.php",
34 "csrest_segments.php", 36 "csrest_segments.php",
...@@ -36,7 +38,9 @@ ...@@ -36,7 +38,9 @@
36 "csrest_templates.php", 38 "csrest_templates.php",
37 "csrest_transactional_classicemail.php", 39 "csrest_transactional_classicemail.php",
38 "csrest_transactional_smartemail.php", 40 "csrest_transactional_smartemail.php",
39 "csrest_transactional_timeline.php" 41 "csrest_transactional_timeline.php",
42 "csrest_journeys.php",
43 "csrest_journey_emails.php"
40 ] 44 ]
41 }, 45 },
42 "notification-url": "https://packagist.org/downloads/", 46 "notification-url": "https://packagist.org/downloads/",
...@@ -56,6 +60,14 @@ ...@@ -56,6 +60,14 @@
56 "api", 60 "api",
57 "campaign", 61 "campaign",
58 "monitor" 62 "monitor"
59 ] 63 ],
64 "support": {
65 "issues": "https://github.com/campaignmonitor/createsend-php/issues",
66 "source": "https://github.com/campaignmonitor/createsend-php/tree/v6.1.2"
67 },
68 "install-path": "../campaignmonitor/createsend-php"
60 } 69 }
61 ] 70 ],
71 "dev": true,
72 "dev-package-names": []
73 }
......
1 <?php return array(
2 'root' => array(
3 'name' => '__root__',
4 'pretty_version' => 'dev-master',
5 'version' => 'dev-master',
6 'reference' => '734b44a846bc2036531a17291e42e1b8dc4a3266',
7 'type' => 'library',
8 'install_path' => __DIR__ . '/../../',
9 'aliases' => array(),
10 'dev' => true,
11 ),
12 'versions' => array(
13 '__root__' => array(
14 'pretty_version' => 'dev-master',
15 'version' => 'dev-master',
16 'reference' => '734b44a846bc2036531a17291e42e1b8dc4a3266',
17 'type' => 'library',
18 'install_path' => __DIR__ . '/../../',
19 'aliases' => array(),
20 'dev_requirement' => false,
21 ),
22 'campaignmonitor/createsend-php' => array(
23 'pretty_version' => 'v6.1.2',
24 'version' => '6.1.2.0',
25 'reference' => '922cec7fbc9da1508c18156db7693a6ddad7194e',
26 'type' => 'library',
27 'install_path' => __DIR__ . '/../campaignmonitor/createsend-php',
28 'aliases' => array(),
29 'dev_requirement' => false,
30 ),
31 ),
32 );
1 <?php
2
3 // platform_check.php @generated by Composer
4
5 $issues = array();
6
7 if (!(PHP_VERSION_ID >= 50300)) {
8 $issues[] = 'Your Composer dependencies require a PHP version ">= 5.3.0". You are running ' . PHP_VERSION . '.';
9 }
10
11 if ($issues) {
12 if (!headers_sent()) {
13 header('HTTP/1.1 500 Internal Server Error');
14 }
15 if (!ini_get('display_errors')) {
16 if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
17 fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
18 } elseif (!headers_sent()) {
19 echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
20 }
21 }
22 trigger_error(
23 'Composer detected issues in your platform: ' . implode(' ', $issues),
24 E_USER_ERROR
25 );
26 }