blob: 462599ad26e16ddb3f95a072acbce2d08976b20a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
namespace SparkPost;
use Http\Promise\Promise as HttpPromise;
class SparkPostPromise implements HttpPromise
{
private $promise;
public function __construct(HttpPromise $promise) {
$this->promise = $promise;
}
public function then(callable $onFulfilled = null, callable $onRejected = null) {
$this->promise->then(
function($response) {
$onFulfilled(new SparkPostResponse($response));
},
function(\Exception $exception) {
$onRejected(new SparkPostException($exception));
});
}
public function getState() {
return $this->promise->getState();
}
public function wait($unwrap = true) {
try
{
$response = $this->promise->wait($unwrap);
return new SparkPostResponse($response);
}
catch (\Exception $exception)
{
throw new SparkPostException($exception);
}
}
}
?>
|