summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Fellows <james.fellows@finanscapes.com>2016-03-31 23:19:53 +0100
committerJames Fellows <james.fellows@finanscapes.com>2016-03-31 23:19:53 +0100
commita49a08ca3cb893e4589c7b925e04a938dfe18c84 (patch)
treea452d1e6f5e8269f2ee65fbe5dae1b57ba95ef4c
parentdfd7e0f7d41e13d5bd0a84779c8756ae63523a0d (diff)
downloadphp-sparkpost-a49a08ca3cb893e4589c7b925e04a938dfe18c84.zip
php-sparkpost-a49a08ca3cb893e4589c7b925e04a938dfe18c84.tar.gz
php-sparkpost-a49a08ca3cb893e4589c7b925e04a938dfe18c84.tar.bz2
Initial commit adding MessageEvent support
-rw-r--r--.gitignore1
-rw-r--r--lib/SparkPost/APIResource.php5
-rw-r--r--lib/SparkPost/MessageEvent.php11
-rw-r--r--test/unit/APIResourceTest.php14
4 files changed, 31 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index dae14ef..0a84bbb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
test/output/
examples/example-config.json
.idea
+/composer.phar
diff --git a/lib/SparkPost/APIResource.php b/lib/SparkPost/APIResource.php
index 20e7b19..d0b8a5b 100644
--- a/lib/SparkPost/APIResource.php
+++ b/lib/SparkPost/APIResource.php
@@ -112,6 +112,11 @@ 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] );
}
diff --git a/lib/SparkPost/MessageEvent.php b/lib/SparkPost/MessageEvent.php
new file mode 100644
index 0000000..a0ab16e
--- /dev/null
+++ b/lib/SparkPost/MessageEvent.php
@@ -0,0 +1,11 @@
+<?php
+namespace SparkPost;
+
+
+class MessageEvent extends APIResource {
+ public $endpoint = 'message-events';
+
+ public function search(Array $queryParams) {
+ return $this->get(null, $queryParams);
+ }
+} \ No newline at end of file
diff --git a/test/unit/APIResourceTest.php b/test/unit/APIResourceTest.php
index 0baef41..7163255 100644
--- a/test/unit/APIResourceTest.php
+++ b/test/unit/APIResourceTest.php
@@ -84,6 +84,20 @@ class APIResourceTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($testBody, $this->resource->get('test'));
}
+ public function testGetCommaSeparated() {
+ $testBody = ['results'=>['my'=>'test']];
+ $responseMock = Mockery::mock();
+ $this->sparkPostMock->httpAdapter->shouldReceive('send')->
+ once()->
+ with('/.*\/test/', 'GET', Mockery::type('array'), null)->
+ andReturn($responseMock);
+ $responseMock->shouldReceive('getStatusCode')->andReturn(200);
+ $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
+
+ $this->assertEquals($testBody, $this->resource->get(
+ 'test', [ "param1" => "param1val", "param2" => ["param2val1", "param2val2"] ]));
+ }
+
public function testDelete() {
$responseMock = Mockery::mock();
$this->sparkPostMock->httpAdapter->shouldReceive('send')->