Skip to content

Commit a49a08c

Browse files
committed
Initial commit adding MessageEvent support
1 parent dfd7e0f commit a49a08c

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
test/output/
66
examples/example-config.json
77
.idea
8+
/composer.phar

lib/SparkPost/APIResource.php

+5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public function update( $resourcePath, Array $body=[]) {
112112
* @return array Result of the request
113113
*/
114114
public function get( $resourcePath=null, Array $query=[] ) {
115+
foreach($query as $element) {
116+
if(is_array($element)) {
117+
118+
}
119+
}
115120
return $this->callResource( 'get', $resourcePath, ['query'=>$query] );
116121
}
117122

lib/SparkPost/MessageEvent.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
namespace SparkPost;
3+
4+
5+
class MessageEvent extends APIResource {
6+
public $endpoint = 'message-events';
7+
8+
public function search(Array $queryParams) {
9+
return $this->get(null, $queryParams);
10+
}
11+
}

test/unit/APIResourceTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ public function testGet() {
8484
$this->assertEquals($testBody, $this->resource->get('test'));
8585
}
8686

87+
public function testGetCommaSeparated() {
88+
$testBody = ['results'=>['my'=>'test']];
89+
$responseMock = Mockery::mock();
90+
$this->sparkPostMock->httpAdapter->shouldReceive('send')->
91+
once()->
92+
with('/.*\/test/', 'GET', Mockery::type('array'), null)->
93+
andReturn($responseMock);
94+
$responseMock->shouldReceive('getStatusCode')->andReturn(200);
95+
$responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
96+
97+
$this->assertEquals($testBody, $this->resource->get(
98+
'test', [ "param1" => "param1val", "param2" => ["param2val1", "param2val2"] ]));
99+
}
100+
87101
public function testDelete() {
88102
$responseMock = Mockery::mock();
89103
$this->sparkPostMock->httpAdapter->shouldReceive('send')->

0 commit comments

Comments
 (0)