From 367c4a7b0f404e445a72a70f83dce52d95ccbd9f Mon Sep 17 00:00:00 2001 From: ging-dev Date: Thu, 4 Jul 2024 23:32:13 +0700 Subject: [PATCH] wip --- .gitignore | 1 + src/Api/AuthenticatedApi.php | 38 ++++++++++++++++++++++++++++++++++++ src/Entity/Account.php | 28 ++++++++++++++++++++++++++ src/Entity/Transaction.php | 21 ++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 src/Entity/Account.php create mode 100644 src/Entity/Transaction.php diff --git a/.gitignore b/.gitignore index b840dac..0df0b70 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor test.php *.cache +*.txt diff --git a/src/Api/AuthenticatedApi.php b/src/Api/AuthenticatedApi.php index bb142a1..3fa2adb 100644 --- a/src/Api/AuthenticatedApi.php +++ b/src/Api/AuthenticatedApi.php @@ -2,7 +2,10 @@ namespace IPay\Api; +use IPay\Entity\Account; use IPay\Entity\Customer; +use IPay\Entity\Transaction; +use League\ObjectMapper\IterableList; /** * @extends AbstractApi @@ -16,4 +19,39 @@ public function customer(): Customer $this->post('/getCustomerDetails')['customerInfo'], ); } + + /** + * @return IterableList + */ + public function accounts(): IterableList + { + return $this->objectMapper->hydrateObjects( + Account::class, + $this->post('/getEntitiesAndAccounts')['accounts'], + ); + } + + /** + * @return IterableList + */ + public function historyTransactions( + string $accountNumber, + \DateTimeInterface $startDate, + \DateTimeInterface $endDate = new \DateTime(), + int $pageNumber = 0, + int $maxResult = 999999999, + ): IterableList { + $parameters = get_defined_vars(); + + foreach ($parameters as &$value) { + if ($value instanceof \DateTimeInterface) { + $value = $value->format('Y-m-d'); + } + } + + return $this->objectMapper->hydrateObjects( + Transaction::class, + $this->post('/getHistTransactions', $parameters)['transactions'] + ); + } } diff --git a/src/Entity/Account.php b/src/Entity/Account.php new file mode 100644 index 0000000..f96e1c8 --- /dev/null +++ b/src/Entity/Account.php @@ -0,0 +1,28 @@ +