summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJames Fellows <james.fellows@finanscapes.com>2016-04-03 21:32:25 +0100
committerJames Fellows <james.fellows@finanscapes.com>2016-04-03 21:32:25 +0100
commitb678bfce586d89077d3cacd5ba8a936667fe96e6 (patch)
tree5dd6ca6eec4febc1a4cfcd38e4571137cd44a8be /lib
parenta49a08ca3cb893e4589c7b925e04a938dfe18c84 (diff)
downloadphp-sparkpost-b678bfce586d89077d3cacd5ba8a936667fe96e6.zip
php-sparkpost-b678bfce586d89077d3cacd5ba8a936667fe96e6.tar.gz
php-sparkpost-b678bfce586d89077d3cacd5ba8a936667fe96e6.tar.bz2
Message Event mocked tests pass
Diffstat (limited to 'lib')
-rw-r--r--lib/SparkPost/APIResource.php14
-rw-r--r--lib/SparkPost/MessageEvent.php28
2 files changed, 30 insertions, 12 deletions
diff --git a/lib/SparkPost/APIResource.php b/lib/SparkPost/APIResource.php
index d0b8a5b..71c6a26 100644
--- a/lib/SparkPost/APIResource.php
+++ b/lib/SparkPost/APIResource.php
@@ -112,11 +112,6 @@ class APIResource {
* @return array Result of the request
*/
public function get( $resourcePath=null, Array $query=[] ) {
- foreach($query as $element) {
- if(is_array($element)) {
-
- }
- }
return $this->callResource( 'get', $resourcePath, ['query'=>$query] );
}
@@ -135,7 +130,8 @@ class APIResource {
/**
* assembles a URL for a request
* @param string $resourcePath path after the initial endpoint
- * @param array $options array with an optional value of query with values to build a querystring from.
+ * @param array $options array with an optional value of query with values to build a querystring from. Any
+ * query elements that are themselves arrays will be imploded into a comma separated list.
* @return string the assembled URL
*/
private function buildUrl($resourcePath, $options) {
@@ -145,6 +141,12 @@ class APIResource {
}
if( !empty($options['query'])) {
+ foreach($options['query'] as &$element) {
+ if(is_array($element)) {
+ $element = implode(",", $element);
+ }
+ }
+
$queryString = http_build_query($options['query']);
$url .= '?'.$queryString;
}
diff --git a/lib/SparkPost/MessageEvent.php b/lib/SparkPost/MessageEvent.php
index a0ab16e..a72fb49 100644
--- a/lib/SparkPost/MessageEvent.php
+++ b/lib/SparkPost/MessageEvent.php
@@ -1,11 +1,27 @@
<?php
namespace SparkPost;
+/**
+ * SDK class for querying message events API
+ * @package SparkPost
+ */
+class MessageEvent extends APIResource
+{
+ public $endpoint = 'message-events';
-class MessageEvent extends APIResource {
- public $endpoint = 'message-events';
-
- public function search(Array $queryParams) {
- return $this->get(null, $queryParams);
- }
+ /**
+ * Method for issuing search requests to the Message Events API.
+ *
+ * The method passes-through all of the query parameters listed at
+ * @link https://developers.sparkpost.com/api/#/reference/message-events/events-documentation/search-for-message-events
+ *
+ * @param array $queryParams The query parameters. Note that a query parameter containing an array
+ * is collapsed into a comma-separated list.
+ *
+ * @return array The result of the query.
+ */
+ public function search(Array $queryParams)
+ {
+ return $this->get(null, $queryParams);
+ }
} \ No newline at end of file