Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ging-dev committed Jul 4, 2024
1 parent 836da67 commit 367c4a7
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor
test.php
*.cache
*.txt
38 changes: 38 additions & 0 deletions src/Api/AuthenticatedApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuthenticatedSession>
Expand All @@ -16,4 +19,39 @@ public function customer(): Customer
$this->post('/getCustomerDetails')['customerInfo'],
);
}

/**
* @return IterableList<Account>
*/
public function accounts(): IterableList
{
return $this->objectMapper->hydrateObjects(
Account::class,
$this->post('/getEntitiesAndAccounts')['accounts'],
);
}

/**
* @return IterableList<Transaction>
*/
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']
);
}
}
28 changes: 28 additions & 0 deletions src/Entity/Account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace IPay\Entity;

readonly class AccountState
{
/**
* @internal
*/
public function __construct(
public int $availableBalance,
public int $balance,
) {
}
}

readonly class Account
{
/**
* @internal
*/
public function __construct(
public string $number,
public string $currencyCode,
public AccountState $accountState,
) {
}
}
21 changes: 21 additions & 0 deletions src/Entity/Transaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace IPay\Entity;

use League\ObjectMapper\PropertyCasters\CastToType;

readonly class Transaction
{
/**
* @internal
*/
public function __construct(
public string $currency,
#[CastToType('integer')]
public int $amount,
public string $remark,
public string $corresponsiveAccount,
public string $corresponsiveName,
) {
}
}

0 comments on commit 367c4a7

Please sign in to comment.