| @@ 9-38 (lines=30) @@ | ||
| 6 | use Gbowo\Plugin\AbstractPlugin; |
|
| 7 | use function GuzzleHttp\json_decode; |
|
| 8 | ||
| 9 | class GetAllCustomers extends AbstractPlugin |
|
| 10 | { |
|
| 11 | ||
| 12 | use VerifyHttpStatusResponseCode; |
|
| 13 | ||
| 14 | const CUSTOMERS_LINK = "/customer"; |
|
| 15 | ||
| 16 | protected $baseUrl; |
|
| 17 | ||
| 18 | public function __construct(string $baseUrl) |
|
| 19 | { |
|
| 20 | $this->baseUrl = $baseUrl; |
|
| 21 | } |
|
| 22 | ||
| 23 | ||
| 24 | public function getPluginAccessor() : string |
|
| 25 | { |
|
| 26 | return "getAllCustomers"; |
|
| 27 | } |
|
| 28 | ||
| 29 | public function handle() : array |
|
| 30 | { |
|
| 31 | $response = $this->adapter->getHttpClient() |
|
| 32 | ->get($this->baseUrl . self::CUSTOMERS_LINK); |
|
| 33 | ||
| 34 | $this->verifyResponse($response); |
|
| 35 | ||
| 36 | return json_decode($response->getBody(), true)["data"]; |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| @@ 9-37 (lines=29) @@ | ||
| 6 | use Gbowo\Plugin\AbstractPlugin; |
|
| 7 | use function GuzzleHttp\json_decode; |
|
| 8 | ||
| 9 | class GetAllTransactions extends AbstractPlugin |
|
| 10 | { |
|
| 11 | use VerifyHttpStatusResponseCode; |
|
| 12 | ||
| 13 | const TRANSACTION_RELATIVE_LINK = "/transaction"; |
|
| 14 | ||
| 15 | protected $baseUrl ; |
|
| 16 | ||
| 17 | public function __construct(string $baseUrl) |
|
| 18 | { |
|
| 19 | $this->baseUrl = $baseUrl ; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function getPluginAccessor() : string |
|
| 23 | { |
|
| 24 | return "getAllTransactions"; |
|
| 25 | } |
|
| 26 | ||
| 27 | public function handle() : array |
|
| 28 | { |
|
| 29 | ||
| 30 | $response = $this->adapter->getHttpClient() |
|
| 31 | ->get($this->baseUrl . self::TRANSACTION_RELATIVE_LINK); |
|
| 32 | ||
| 33 | $this->verifyResponse($response); |
|
| 34 | ||
| 35 | return json_decode($response->getBody(), true)["data"]; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||