Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Whitespace coding standards cleanup #8

Merged
merged 1 commit into from over 2 years ago

2 participants

Andy Stanberry Prajwal Tuladhar
Andy Stanberry

NOTE: I'm not sure which coding standard to adhere to, so I brought things largely into compliance with themselves

  • removed all tabs
  • removed random/trailing whitespace
  • removed closing ?>
  • put 2 line breaks between every function definition
Andy Stanberry cranberyxl Whitespace coding standards cleanup
* removed all tabs
* removed random/trailing whitespace
* removed closing ?>
* put 2 line breaks between every function definition
ce3ea5b
Prajwal Tuladhar infynyxx merged commit ce3ea5b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 03, 2012
Andy Stanberry cranberyxl Whitespace coding standards cleanup
* removed all tabs
* removed random/trailing whitespace
* removed closing ?>
* put 2 line breaks between every function definition
ce3ea5b
This page is out of date. Refresh to see the latest.
207 sailthru/Sailthru_Client.php
@@ -17,7 +17,7 @@ class Sailthru_Client {
17 17
18 18 /**
19 19 *
20   - * SAilthru Secret
  20 + * Sailthru Secret
21 21 * @var string
22 22 */
23 23 private $secret;
@@ -43,14 +43,14 @@ class Sailthru_Client {
43 43 * @var String
44 44 */
45 45 protected $user_agent_string;
46   -
  46 +
47 47 /**
48 48 * Get information regarding last response from server
49   - * @var type
  49 + * @var type
50 50 */
51 51 private $lastResponseInfo = null;
52   -
53   -
  52 +
  53 +
54 54 /**
55 55 * File Upload Flag variable
56 56 */
@@ -177,7 +177,6 @@ public function getEmail($email) {
177 177 * @param string $email
178 178 * @param array $vars
179 179 * @param array $lists
180   -
181 180 * @param array $templates
182 181 * @param integer $verified 1 or 0
183 182 * @param string $optout
@@ -210,6 +209,7 @@ public function setEmail($email, $vars = array(), $lists = array(), $templates =
210 209 return $this->apiPost('email', $data);
211 210 }
212 211
  212 +
213 213 /**
214 214 * Update / add email address
215 215 *
@@ -233,32 +233,25 @@ public function setEmail2($email, array $options = array()) {
233 233 * @param string $content_html the HTML-format version of the email
234 234 * @param string $content_text the text-format version of the email
235 235 * @param array $options associative array
236   - * blast_id
237   - * copy_blast
238   - * copy_template
239   - * replyto
240   - * report_email
241   - * is_link_tracking
242   - * is_google_analytics
243   - * is_public
244   - * suppress_list
245   - * test_vars
246   - * email_hour_range
247   - * abtest
248   - * test_percent
249   - * data_feed_url
  236 + * blast_id
  237 + * copy_blast
  238 + * copy_template
  239 + * replyto
  240 + * report_email
  241 + * is_link_tracking
  242 + * is_google_analytics
  243 + * is_public
  244 + * suppress_list
  245 + * test_vars
  246 + * email_hour_range
  247 + * abtest
  248 + * test_percent
  249 + * data_feed_url
250 250 * @link http://docs.sailthru.com/api/blast
251 251 */
252   - public function scheduleBlast($name,
253   - $list,
254   - $schedule_time,
255   - $from_name,
256   - $from_email,
257   - $subject,
258   - $content_html,
259   - $content_text,
260   - $options = array()) {
261   -
  252 + public function scheduleBlast($name, $list, $schedule_time, $from_name,
  253 + $from_email, $subject, $content_html, $content_text, $options = array()
  254 + ) {
262 255 $data = $options;
263 256 $data['name'] = $name;
264 257 $data['list'] = $list;
@@ -272,6 +265,7 @@ public function scheduleBlast($name,
272 265 return $this->apiPost('blast', $data);
273 266 }
274 267
  268 +
275 269 /**
276 270 * Schedule a mass mail from a template
277 271 *
@@ -289,6 +283,7 @@ public function scheduleBlastFromTemplate($template, $list, $schedule_time, $opt
289 283 return $this->apiPost('blast', $data);
290 284 }
291 285
  286 +
292 287 /**
293 288 * Schedule a mass mail blast from previous blast
294 289 *
@@ -304,6 +299,7 @@ public function scheduleBlastFromBlast($blast_id, $schedule_time, $options = arr
304 299 return $this->apiPost('blast', $data);
305 300 }
306 301
  302 +
307 303 /**
308 304 * updates existing blast
309 305 *
@@ -317,32 +313,27 @@ public function scheduleBlastFromBlast($blast_id, $schedule_time, $options = arr
317 313 * @param string $content_html
318 314 * @param string $content_text
319 315 * @param array $options associative array
320   - * blast_id
321   - * copy_blast
322   - * copy_template
323   - * replyto
324   - * report_email
325   - * is_link_tracking
326   - * is_google_analytics
327   - * is_public
328   - * suppress_list
329   - * test_vars
330   - * email_hour_range
331   - * abtest
332   - * test_percent
333   - * data_feed_url
  316 + * blast_id
  317 + * copy_blast
  318 + * copy_template
  319 + * replyto
  320 + * report_email
  321 + * is_link_tracking
  322 + * is_google_analytics
  323 + * is_public
  324 + * suppress_list
  325 + * test_vars
  326 + * email_hour_range
  327 + * abtest
  328 + * test_percent
  329 + * data_feed_url
334 330 * @link http://docs.sailthru.com/api/blast
335 331 */
336   - public function updateBlast($blast_id,
337   - $name = null,
338   - $list = null,
339   - $schedule_time = null,
340   - $from_name = null,
341   - $from_email = null,
342   - $subject = null,
343   - $content_html = null,
344   - $content_text = null,
345   - $options = array()) {
  332 + public function updateBlast($blast_id, $name = null, $list = null,
  333 + $schedule_time = null, $from_name = null, $from_email = null,
  334 + $subject = null, $content_html = null, $content_text = null,
  335 + $options = array()
  336 + ) {
346 337 $data = $options;
347 338 $data['blast_id'] = $blast_id;
348 339 if (!is_null($name)) {
@@ -382,7 +373,7 @@ public function updateBlast($blast_id,
382 373 public function getBlast($blast_id) {
383 374 return $this->apiGet('blast', array('blast_id' => $blast_id));
384 375 }
385   -
  376 +
386 377 /**
387 378 * Get info on multiple blasts
388 379 * @param array $options associative array
@@ -419,6 +410,7 @@ public function cancelBlast($blast_id) {
419 410 return $this->apiPost('blast', $data);
420 411 }
421 412
  413 +
422 414 /**
423 415 * Fetch information about a template
424 416 *
@@ -429,8 +421,8 @@ public function getTemplate($template_name, array $options = array()) {
429 421 $options['template'] = $template_name;
430 422 return $this->apiGet('template', $options);
431 423 }
432   -
433   -
  424 +
  425 +
434 426 /**
435 427 * Fetch name of all existing templates
436 428 * @link http://docs.sailthru.com/api/template
@@ -438,12 +430,13 @@ public function getTemplate($template_name, array $options = array()) {
438 430 public function getTemplates() {
439 431 return $this->apiGet('template', array());
440 432 }
441   -
442   -
  433 +
  434 +
443 435 public function getTemplateFromRevision($revision_id) {
444 436 return $this->apiGet('template', array('revision' => (int)$revision_id));
445 437 }
446 438
  439 +
447 440 /**
448 441 * Save a template.
449 442 *
@@ -456,7 +449,8 @@ public function saveTemplate($template_name, array $template_fields = array()) {
456 449 $data['template'] = $template_name;
457 450 return $this->apiPost('template', $data);
458 451 }
459   -
  452 +
  453 +
460 454 /**
461 455 * Save a template from revision
462 456 *
@@ -465,10 +459,10 @@ public function saveTemplate($template_name, array $template_fields = array()) {
465 459 * @link http://docs.sailthru.com/api/template
466 460 */
467 461 public function saveTemplateFromRevision($template_name, $revision_id) {
468   - $revision_id = (int)$revision_id;
  462 + $revision_id = (int)$revision_id;
469 463 return $this->saveTemplate($template_name, array('revision' => $revision_id));
470 464 }
471   -
  465 +
472 466
473 467 /**
474 468 * Delete a template.
@@ -498,10 +492,10 @@ public function getList($list, $format = "txt") {
498 492 return $this->apiGet('list', $data);
499 493 }
500 494
501   -
  495 +
502 496 /**
503 497 * Get all lists metadata of a user
504   - **/
  498 + */
505 499 public function getLists() {
506 500 return $this->apiGet('list', array('list' => ""));
507 501 }
@@ -525,7 +519,7 @@ public function saveList($list, $emails) {
525 519 /**
526 520 * Deletes a list
527 521 * @param String $list
528   - * @link http://docs.sailthru.com/api/list
  522 + * @link http://docs.sailthru.com/api/list
529 523 */
530 524 public function deleteList($list) {
531 525 $data = array(
@@ -606,14 +600,11 @@ public function getAlert($email) {
606 600 * <code>
607 601 * <?php
608 602 * $options = array(
609   - * 'match' => array(
610   - * 'type' => array(
611   - * 'shoes', 'shirts'
612   - * ),
613   - * 'min' => array(
614   - * 'price' => 3000
615   - * ),
616   - * 'tags' => array('blue', 'red')
  603 + * 'match' => array(
  604 + * 'type' => array('shoes', 'shirts'),
  605 + * 'min' => array('price' => 3000),
  606 + * 'tags' => array('blue', 'red'),
  607 + * )
617 608 * );
618 609 * $response = $sailthruClient->saveAlert("praj@sailthru.com", 'realtime', 'default', null, $options);
619 610 * ?>
@@ -625,10 +616,10 @@ public function getAlert($email) {
625 616 * @param String $template
626 617 * @param String $when
627 618 * @param array $options Associative array of additive nature
628   - * match Exact-match a custom variable match[type]=shoes
629   - * min Minimum-value variables min[price]=30000
630   - * max Maximum-value match max[price]=50000
631   - * tags Tag-match tags[]=blue
  619 + * match Exact-match a custom variable match[type]=shoes
  620 + * min Minimum-value variables min[price]=30000
  621 + * max Maximum-value match max[price]=50000
  622 + * tags Tag-match tags[]=blue
632 623 */
633 624 public function saveAlert($email, $type, $template, $when = null, $options = array()) {
634 625 $data = $options;
@@ -674,10 +665,11 @@ public function purchase($email, array $items, $incomplete = null, $message_id =
674 665 return $this->apiPost('purchase', $data);
675 666 }
676 667
  668 +
677 669 /**
678 670 * Make a purchase API call with incomplete flag
679 671 * @link http://docs.sailthru.com/api/purchase
680   - */
  672 + */
681 673 public function purchaseIncomplete($email, array $items, $message_id, array $options = array()) {
682 674 return $this->purchase($email, $items, 1, $message_id, $options);
683 675 }
@@ -789,6 +781,7 @@ public function receiveOptoutPost() {
789 781 return true;
790 782 }
791 783
  784 +
792 785 /**
793 786 *
794 787 * Hard bounce postbacks
@@ -857,7 +850,8 @@ public function setHorizon($email, $tags = null) {
857 850 }
858 851 return $this->apiPost('horizon', $data);
859 852 }
860   -
  853 +
  854 +
861 855 /**
862 856 * Get status of a job
863 857 * @param String $job_id
@@ -865,7 +859,8 @@ public function setHorizon($email, $tags = null) {
865 859 public function getJobStatus($job_id) {
866 860 return $this->apiGet('job', array('job_id' => $job_id));
867 861 }
868   -
  862 +
  863 +
869 864 /**
870 865 * process job api call
871 866 * @param String $job
@@ -885,8 +880,8 @@ protected function processJob($job, array $options = array(), $report_email = fa
885 880 }
886 881 return $this->apiPost('job', $data, $binary_data_param);
887 882 }
888   -
889   -
  883 +
  884 +
890 885 /**
891 886 * Process import job from given email string CSV
892 887 * @param String $list
@@ -896,16 +891,16 @@ protected function processJob($job, array $options = array(), $report_email = fa
896 891 */
897 892 public function processImportJob($list, $emails, $report_email = false, $postback_url = false) {
898 893 $data = array(
899   - 'emails' => $emails,
  894 + 'emails' => $emails,
900 895 'list' => $list
901 896 );
902 897 return $this->processJob('import', $data, $report_email, $postback_url);
903 898 }
904   -
905   -
  899 +
  900 +
906 901 /**
907 902 * Process import job from given file path of a CSV or email per line file
908   - *
  903 + *
909 904 * @param String $list
910 905 * @param String $emails
911 906 * @param String $report_email
@@ -914,16 +909,16 @@ public function processImportJob($list, $emails, $report_email = false, $postbac
914 909 */
915 910 public function processImportJobFromFile($list, $file_path, $report_email = false, $postback_url = false) {
916 911 $data = array(
917   - 'file' => $file_path,
  912 + 'file' => $file_path,
918 913 'list' => $list
919 914 );
920 915 return $this->processJob('import', $data, $report_email, $postback_url, array('file'));
921 916 }
922   -
923   -
  917 +
  918 +
924 919 /**
925 920 * Process a snapshot job
926   - *
  921 + *
927 922 * @param array $query
928 923 * @param String $report_email
929 924 * @param String $postback_url
@@ -932,7 +927,8 @@ public function processSnapshotJob(array $query, $report_email = false, $postbac
932 927 $data = array('query' => $query);
933 928 return $this->processJob('snaphot', $data, $report_email, $postback_url);
934 929 }
935   -
  930 +
  931 +
936 932 /**
937 933 * Process a export list job
938 934 * @param String $list
@@ -943,7 +939,8 @@ public function processExportListJob($list, $report_email = false, $postback_url
943 939 $data = array('list' => $list);
944 940 return $this->processJob('export_list_data', $data, $report_email, $postback_url);
945 941 }
946   -
  942 +
  943 +
947 944 /**
948 945 * Export blast data in CSV format
949 946 * @param integer $blast_id
@@ -954,6 +951,7 @@ public function processBlastQueryJob($blast_id, $report_email = false, $postback
954 951 return $this->processJob('blast_query', array('blast_id' => $blast_id), $report_email, $postback_url);
955 952 }
956 953
  954 +
957 955 /**
958 956 * Perform a bulk update of any number of user profiles from given context: String CSV, file, URL or query
959 957 * @param String $context
@@ -971,6 +969,7 @@ public function processUpdateJob($context, $value, array $update = array(), $re
971 969 return $this->processJob('update', $data, $report_email, $postback_url, $file_params);
972 970 }
973 971
  972 +
974 973 /**
975 974 * Perform a bulk update of any number of user profiles from given URL
976 975 * @param String $url
@@ -981,7 +980,8 @@ public function processUpdateJob($context, $value, array $update = array(), $re
981 980 public function processUpdateJobFromUrl($url, array $update = array(), $report_email = false, $postback_url = false) {
982 981 return $this->processUpdateJob('url', $url, $update, $report_email, $postback_url);
983 982 }
984   -
  983 +
  984 +
985 985 /**
986 986 * Perform a bulk update of any number of user profiles from given file
987 987 * @param String $url
@@ -993,6 +993,7 @@ public function processUpdateJobFromFile($file, array $update = array(), $report
993 993 return $this->processUpdateJob('file', $file, $update, $report_email, $postback_url, array('file'));
994 994 }
995 995
  996 +
996 997 /**
997 998 * Perform a bulk update of any number of user profiles from a query
998 999 * @param Array $query
@@ -1004,6 +1005,7 @@ public function processUpdateJobFromQuery($query, array $update = array(), $repo
1004 1005 return $this->processUpdateJob('query', $query, $update, $report_email, $postback_url);
1005 1006 }
1006 1007
  1008 +
1007 1009 /**
1008 1010 * Perform a bulk update of any number of user profiles from emails CSV
1009 1011 * @param String $emails
@@ -1015,6 +1017,7 @@ public function processUpdateJobFromEmails($emails, array $update = array(), $re
1015 1017 return $this->processUpdateJob('emails', $emails, $update, $report_email, $postback_url);
1016 1018 }
1017 1019
  1020 +
1018 1021 /**
1019 1022 *
1020 1023 * Set Horizon cookie
@@ -1063,7 +1066,7 @@ private function httpRequestCurl($url, array $data, $method = 'POST') {
1063 1066 }
1064 1067 else {
1065 1068 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));
1066   - }
  1069 + }
1067 1070 } else {
1068 1071 $url .= '?' . http_build_query($data, '', '&');
1069 1072 if ($method != 'GET') {
@@ -1130,6 +1133,7 @@ protected function httpRequest($url, $data, $method = 'POST') {
1130 1133 return $this->{$this->http_request_type}($url, $data, $method);
1131 1134 }
1132 1135
  1136 +
1133 1137 /**
1134 1138 * Perform an API POST (or other) request, using the shared-secret auth hash.
1135 1139 * if binary_data_param is set, its appends '@' so that cURL can make binary POST request
@@ -1146,7 +1150,7 @@ public function apiPost($action, $data, array $binary_data_param = array()) {
1146 1150 unset($data[$param]);
1147 1151 $this->fileUpload = true;
1148 1152 }
1149   - }
  1153 + }
1150 1154 }
1151 1155 $payload = $this->prepareJsonPayload($data, $binary_data);
1152 1156 $result = $this->httpRequest("$this->api_uri/$action", $payload, 'POST');
@@ -1163,34 +1167,34 @@ public function apiPost($action, $data, array $binary_data_param = array()) {
1163 1167 * @param array $data
1164 1168 * @return array
1165 1169 */
1166   - public function apiGet($action, $data, $method = 'GET') {
  1170 + public function apiGet($action, $data, $method = 'GET') {
1167 1171 $result = $this->httpRequest("{$this->api_uri}/{$action}", $this->prepareJsonPayload($data), $method);
1168 1172 return json_decode($result, true);
1169 1173 }
1170 1174
1171 1175
1172   - /**
  1176 + /**
1173 1177 * Perform an API DELETE request, using the shared-secret auth hash.
1174 1178 *
1175 1179 * @param string $action
1176 1180 * @param array $data
1177 1181 * @return array
1178   -
1179 1182 */
1180 1183 public function apiDelete($action, $data) {
1181 1184 return $this->apiGet($action, $data, 'DELETE');
1182 1185 }
1183   -
1184   -
  1186 +
  1187 +
1185 1188 /**
1186 1189 * get information from last server response when used with cURL
1187 1190 * returns associative array as per http://us.php.net/curl_getinfo
1188   - * @return array or null
  1191 + * @return array or null
1189 1192 */
1190 1193 public function getLastResponseInfo() {
1191 1194 return $this->lastResponseInfo;
1192 1195 }
1193 1196
  1197 +
1194 1198 /**
1195 1199 * Prepare JSON payload
1196 1200 */
@@ -1207,4 +1211,3 @@ protected function prepareJsonPayload(array $data, array $binary_data = array())
1207 1211 return $payload;
1208 1212 }
1209 1213 }
1210   -?>
4 sailthru/Sailthru_Client_Exception.php
... ... @@ -1,5 +1,5 @@
1 1 <?php
2 2
3   -class Sailthru_Client_Exception extends Exception {
4   -
  3 +class Sailthru_Client_Exception extends Exception {
  4 +
5 5 }
6 sailthru/Sailthru_Util.php
... ... @@ -1,4 +1,5 @@
1 1 <?php
  2 +
2 3 class Sailthru_Util {
3 4 /**
4 5 * Returns an MD5 hash of the signature string for an API call.
@@ -13,6 +14,7 @@ public static function getSignatureHash($params, $secret) {
13 14 return md5(self::getSignatureString($params, $secret));
14 15 }
15 16
  17 +
16 18 /**
17 19 * Returns the unhashed signature string (secret + sorted list of param values) for an API call.
18 20 *
@@ -30,6 +32,7 @@ public static function getSignatureString($params, $secret) {
30 32 return $string;
31 33 }
32 34
  35 +
33 36 /**
34 37 * Extracts the values of a set of parameters, recursing into nested assoc arrays.
35 38 *
@@ -50,5 +53,4 @@ public static function extractParamValues($params, &$values) {
50 53 }
51 54 }
52 55 }
53   -}
54   -?>
  56 +}

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.