@@ 13-55 (lines=43) @@ | ||
10 | /** |
|
11 | * @author Luís Otávio Cobucci Oblonczyk <[email protected]> |
|
12 | */ |
|
13 | class Locator extends Service implements SearchService, NotificationService |
|
14 | { |
|
15 | /** |
|
16 | * @var string |
|
17 | */ |
|
18 | const ENDPOINT = '/v2/pre-approvals'; |
|
19 | ||
20 | /** |
|
21 | * @var Decoder |
|
22 | */ |
|
23 | private $decoder; |
|
24 | ||
25 | /** |
|
26 | * @param Credentials $credentials |
|
27 | * @param Client $client |
|
28 | * @param Decoder $decoder |
|
29 | */ |
|
30 | public function __construct( |
|
31 | Credentials $credentials, |
|
32 | Client $client = null, |
|
33 | Decoder $decoder = null |
|
34 | ) { |
|
35 | parent::__construct($credentials, $client); |
|
36 | ||
37 | $this->decoder = $decoder ?: new Decoder(); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * {@inheritdoc} |
|
42 | */ |
|
43 | public function getByCode($code) |
|
44 | { |
|
45 | return $this->decoder->decode($this->get(static::ENDPOINT . '/' . $code)); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getByNotification($code) |
|
52 | { |
|
53 | return $this->decoder->decode($this->get(static::ENDPOINT . '/notifications/' . $code)); |
|
54 | } |
|
55 | } |
|
56 |
@@ 13-57 (lines=45) @@ | ||
10 | /** |
|
11 | * @author Luís Otávio Cobucci Oblonczyk <[email protected]> |
|
12 | */ |
|
13 | class Locator extends Service implements SearchService, NotificationService |
|
14 | { |
|
15 | /** |
|
16 | * @var string |
|
17 | */ |
|
18 | const ENDPOINT = '/v2/transactions'; |
|
19 | ||
20 | /** |
|
21 | * @var Decoder |
|
22 | */ |
|
23 | private $decoder; |
|
24 | ||
25 | /** |
|
26 | * @param Credentials $credentials |
|
27 | * @param Client $client |
|
28 | * @param Decoder $decoder |
|
29 | */ |
|
30 | public function __construct( |
|
31 | Credentials $credentials, |
|
32 | Client $client = null, |
|
33 | Decoder $decoder = null |
|
34 | ) { |
|
35 | parent::__construct($credentials, $client); |
|
36 | ||
37 | $this->decoder = $decoder ?: new Decoder(); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * @param string $code |
|
42 | * |
|
43 | * @return Transaction |
|
44 | */ |
|
45 | public function getByCode($code) |
|
46 | { |
|
47 | return $this->decoder->decode($this->get(static::ENDPOINT . '/' . $code)); |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * {@inheritdoc} |
|
52 | */ |
|
53 | public function getByNotification($code) |
|
54 | { |
|
55 | return $this->decoder->decode($this->get(static::ENDPOINT . '/notifications/' . $code)); |
|
56 | } |
|
57 | } |
|
58 |