diff --git a/README.md b/README.md index 5a5f35c..ba5f0d6 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ # CNGnManager -CNGnManager is a PHP library for interacting with a CNGN API. It provides a simple interface for various operations such as checking balance, swapping between chains, depositing for redemption, creating virtual accounts, and more. +CNGnManager is a PHP library for interacting with the CNGN API. It provides a simple interface for various operations such as checking balance, bridging between chains, depositing for redemption, managing virtual accounts, and more. ## Table of Contents - [Installation](#installation) - [Usage](#usage) +- [Networks](#networks) - [Available Methods](#available-methods) - [Testing](#testing) +- [Return Values](#return-values) - [Error Handling](#error-handling) - [Types](#types) - [Security](#security) @@ -25,7 +27,7 @@ composer require wrappedcbdc/cngn-php-library ## Usage -First, import the `CNGnManager` class using it namespace WrappedCBDC\CNGNManager: and all necessary constants. +First, import the `CNGnManager` class using its namespace and all necessary constants. ```php getBalance(); echo $balance; ``` + ## Networks The library supports multiple blockchain networks: -- `Network.BSC` - Binance Smart Chain -- `Network.ATC` - Asset Chain -- `Network.XBN` - Bantu Chain -- `Network.ETTH` - Ethereum -- `Network.MATIC` - Polygon (Matic) -- `Network.TRX` - Tron -- `Network.BASE` - Base - +- `Network::BSC` - Binance Smart Chain +- `Network::ATC` - Asset Chain +- `Network::XBN` - Bantu Chain +- `Network::ETH` - Ethereum +- `Network::MATIC` - Polygon (Matic) +- `Network::TRX` - Tron +- `Network::BASE` - Base ## Available Methods -### cNGNManager Methods +### CNGnManager Methods #### Get Balance @@ -82,167 +84,224 @@ echo $balance; $page = 1; $limit = 10; $transactions = $manager->getTransactionHistory($page, $limit); -echo $transaction; +echo $transactions; ``` -#### Withdraw from chains +#### Get Banks ```php -$swapParams = [ - "amount"=> 100, - "address" => '0x1234...', - "network" => Network::BSC, - "shouldSaveAddress" => true -]; +$bankList = $manager->getBanks(); +echo $bankList; +``` -$swapResult = $manager->withdraw($swapParams); -echo $swapResult; +#### Get Virtual Account + +```php +$virtualAccount = $manager->getVirtualAccount(); +echo $virtualAccount; ``` -#### Redeem Asset +#### Withdraw from Chains ```php -$depositParams = [ - "amount"=> 1000, - "bankCode"=> '011', - "accountNumber"=> '1234567890' - "saveDetails" => true +/** + * @param array{amount: int, address: string, network: string, shouldSaveAddress?: bool} $data + */ +$withdrawParams = [ + "amount" => 100, + "address" => '0x1234...', + "network" => Network::BSC, + "shouldSaveAddress" => true, ]; -$depositResult = $manager->redeemAssets($depositParams); -echo $depositResult; +$withdrawResult = $manager->withdraw($withdrawParams); +echo $withdrawResult; ``` -NOTE: to get bank codes please use the getBanks method to fetch the list of banks and ther codes -#### Create Virtual Account +#### Redeem Asset ```php -$mintParams = [ - "provider"=> ProviderType::KORAPAY, - "bank_code" => '011' +/** + * @param array{amount: int, bankCode: string, accountNumber: string, saveDetails?: bool} $data + */ +$redeemParams = [ + "amount" => 1000, + "bankCode" => '011', + "accountNumber" => '1234567890', + "saveDetails" => true, ]; -$virtualAccount = $manager->createVirtualAccount($mintParams); -echo $virtualAccount; +$redeemResult = $manager->redeemAssets($redeemParams); +echo $redeemResult; ``` -NOTE: before creating the virtual account you need to have updated your BVN on the dashboard +> **NOTE:** Use the `getBanks()` method to fetch the list of banks and their codes. -#### Bridge Assets +#### Bridge Assets (Swap) ```php +/** + * @param array{destinationNetwork: string, destinationAddress: string, originNetwork: string, callbackUrl: string} $data + */ $swapData = [ - "destinationNetwork"=> Network::BSC, + "destinationNetwork" => Network::BSC, "destinationAddress" => "0x123....", - "originNetwork" => Network::ETH - "callbackUrl" => 'https://your-callback-url.com' + "originNetwork" => Network::ETH, + "callbackUrl" => 'https://your-callback-url.com', ]; -$swapResult = $manager->swapAsset($swapData); +$swapResult = $manager->swapAssets($swapData); echo $swapResult; ``` -NOTE: before creating the virtual account you need to have updated your BVN on the dashboard +#### Swap Quote + +```php +/** + * @param array{destinationNetwork: string, originNetwork: string} $data + */ +$quoteData = [ + "destinationNetwork" => Network::BSC, + "originNetwork" => Network::ETH, +]; +$quote = $manager->swapQuote($quoteData); +echo $quote; +``` -#### Update Business +#### Update External Accounts -Address Options: -- "xbnAddress": "string"; -- "bscAddress": "string"; -- "atcAddress": "string"; -- "polygonAddress": "string"; -- "ethAddress": "string"; -- "tronAddress": "string"; -- "baseAddress": "string"; -- "bantuUserId": "string"; +Address options: +- `bscAddress`, `atcAddress`, `xbnAddress`, `ethAddress`, `polygonAddress`, `tronAddress`, `baseAddress`, `bantuUserId` ```php -$updateData: [ +/** + * @param array{walletAddress?: array{bscAddress?: string, ...}, bankDetails?: array{bankName: string, bankAccountName: string, bankAccountNumber: string}} $data + */ +$updateData = [ "walletAddress" => [ "bscAddress" => '0x1234...', ], "bankDetails" => [ "bankName" => 'Example Bank', "bankAccountName" => 'Test Account', - "bankAccountNumber" => '1234567890' - ] + "bankAccountNumber" => '1234567890', + ], ]; $updateResult = $manager->updateExternalAccounts($updateData); echo $updateResult; ``` -#### Get banks +#### Whitelist Address + ```php +/** + * @param array{address: string, network: string} $data + */ +$whitelistData = [ + "address" => '0x1234...', + "network" => Network::BSC, +]; -$banklist = $manager->getBanks(); -print($banklist) +$result = $manager->whitelistAddress($whitelistData); +echo $result; +``` + +#### Get Whitelisted Addresses +```php +$addresses = $manager->getWhitelistedAddresses(); +echo $addresses; ``` -### WalletManager Methods +#### Get Supported Networks -#### Generate Wallet Address -Not Available a the moment - +/** + * @param array{bankCode: string, accountNumber: string} $data + */ +$accountData = [ + "bankCode" => '011', + "accountNumber" => '1234567890', +]; +$validation = $manager->validateAccount($accountData); +echo $validation; +``` -## Testing +#### Verify Withdrawal -This project uses Jest for testing. To run the tests, follow these steps: +```php +$verification = $manager->verifyWithdraw('your-transaction-reference'); +echo $verification; +``` -1. Run the test command: +## Testing - ```bash - composer run test - ``` +This project uses PHPUnit for testing. To run the tests: - This will run all tests in the `__tests__` directory. +```bash +composer run test +``` + +This will run all tests in the `__test__` directory. ### Test Structure -The tests are located in the `__tests__` directory. They cover various aspects of the CNGnManager class, including: +The tests are located in the `__test__` directory and cover: -- API calls for different endpoints (GET and POST requests) -- Encryption and decryption of data -- Error handling for various scenarios +- All GET and POST/PUT endpoint calls +- Encryption and decryption (AESCrypto round-trip) +- Error handling (client exceptions, network errors, unexpected errors) +- JSON return format validation for all methods ## Return Values -All responses are returned as a Json string you have to decode it to an object with; `$data = json_decode($response)` or to an array with; `$data = json_decode($response, true)` . +All responses are returned as JSON strings. Decode them with: + +```php +$data = json_decode($response); // as object +$data = json_decode($response, true); // as array +``` ## Error Handling -The library uses a custom error handling mechanism. All API errors are caught and thrown as `Error` objects with descriptive messages. +The library catches all API errors and returns them as JSON strings with error details instead of throwing exceptions: + +```json +{ + "success": false, + "error": "API request failed", + "message": "Error description", + "status_code": 400 +} +``` ## Types -The library includes python constant classes for all parameters: +The library includes PHP constant classes for all parameters: -- `Network` - token network -- `AssetType` - Asset constants -- `ProviderType` - provider constants +- `Network` - blockchain network constants +- `AssetType` - asset type constants (`FIAT`, `WRAPPED`, `ENAIRA`) +- `ProviderType` - provider constants (`KORAPAY`, `BUDPAY`) + +All methods accepting `array $data` include PHPDoc `@param` annotations with typed array shapes for IDE autocompletion. ## Security -This library uses AES encryption for request payloads and Ed25519 decryption for response data. Ensure that your `encryptionKey` and `privateKey` are kept secure. +This library uses AES-256-CBC encryption for request payloads and Ed25519 (Curve25519) decryption for response data. Ensure that your `encryptionKey` and `privateKey` are kept secure. ## Contributing -Contributions, issues, and feature requests are welcome. Feel free to check [issues page](https://github.com/wrappedcbdc/cngn-php-library/issues) if you want to contribute. +Contributions, issues, and feature requests are welcome. Feel free to check the [issues page](https://github.com/wrappedcbdc/cngn-php-library/issues) if you want to contribute. To contribute: 1. Fork the repository @@ -250,7 +309,6 @@ To contribute: 3. Commit your changes 4. Create a Pull Request - ## Support For support, please: diff --git a/__test__/CNGnManagerTest.php b/__test__/CNGnManagerTest.php index d394885..7f09061 100644 --- a/__test__/CNGnManagerTest.php +++ b/__test__/CNGnManagerTest.php @@ -1,15 +1,411 @@ -client = $client; + } +} final class CNGnManagerTest extends TestCase { - public function testThatTrueIsTrue(): void + private TestableCNGnManager $manager; + private string $apiKey = 'test_api_key'; + private string $privateKey = 'test_private_key'; + private string $encryptionKey = 'test_encryption_key'; + + protected function setUp(): void + { + $this->manager = new TestableCNGnManager( + $this->apiKey, + $this->privateKey, + $this->encryptionKey + ); + } + + private function managerWithMockResponses(array $responses): TestableCNGnManager + { + $mock = new MockHandler($responses); + $handlerStack = HandlerStack::create($mock); + $client = new Client(['handler' => $handlerStack]); + $this->manager->setClient($client); + return $this->manager; + } + + // ─── Constructor ──────────────────────────────────────────────── + + #[Test] + public function it_instantiates_with_required_credentials(): void + { + $manager = new CNGnManager($this->apiKey, $this->privateKey, $this->encryptionKey); + $this->assertInstanceOf(CNGnManager::class, $manager); + } + + // ─── GET Endpoints ────────────────────────────────────────────── + + #[Test] + public function getBalance_makes_GET_request_and_returns_json(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('Connection error', new Request('GET', '/v1/api/balance')), + ]); + + $result = json_decode($manager->getBalance(), true); + $this->assertFalse($result['success']); + $this->assertEquals('API request failed', $result['error']); + } + + #[Test] + public function getTransactionHistory_uses_default_pagination(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('GET', '/v1/api/transactions')), + ]); + + $result = json_decode($manager->getTransactionHistory(), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function getTransactionHistory_accepts_custom_pagination(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('GET', '/v1/api/transactions')), + ]); + + $result = json_decode($manager->getTransactionHistory(2, 5), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function getBanks_makes_GET_request(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('GET', '/v1/api/banks')), + ]); + + $result = json_decode($manager->getBanks(), true); + $this->assertFalse($result['success']); + $this->assertArrayHasKey('message', $result); + } + + #[Test] + public function getVirtualAccount_makes_GET_request(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('GET', '/v1/api/virtual-account')), + ]); + + $result = json_decode($manager->getVirtualAccount(), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function verifyWithdraw_includes_tnxRef_in_url(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('GET', '/v1/api/withdraw/verify/TXN123')), + ]); + + $result = json_decode($manager->verifyWithdraw('TXN123'), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function getWhitelistedAddresses_makes_GET_request(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('GET', '/v1/api/whitelist-address')), + ]); + + $result = json_decode($manager->getWhitelistedAddresses(), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function getSupportedNetworks_makes_GET_request(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('GET', '/v1/api/supported-networks')), + ]); + + $result = json_decode($manager->getSupportedNetworks(), true); + $this->assertFalse($result['success']); + } + + // ─── POST / PUT Endpoints ─────────────────────────────────────── + + #[Test] + public function withdraw_sends_POST_with_data(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('POST', '/v1/api/withdraw')), + ]); + + $data = [ + 'amount' => 100, + 'address' => '0x1234abcd', + 'network' => 'bsc', + 'shouldSaveAddress' => true, + ]; + + $result = json_decode($manager->withdraw($data), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function redeemAssets_sends_POST_with_data(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('POST', '/v1/api/redeemAsset')), + ]); + + $data = [ + 'amount' => 1000, + 'bankCode' => '011', + 'accountNumber' => '1234567890', + 'saveDetails' => true, + ]; + + $result = json_decode($manager->redeemAssets($data), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function swapAssets_sends_POST_with_data(): void { - $this->assertTrue(true); + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('POST', '/v1/api/swap')), + ]); + + $data = [ + 'destinationNetwork' => 'bsc', + 'destinationAddress' => '0x1234', + 'originNetwork' => 'eth', + 'callbackUrl' => 'https://example.com/callback', + ]; + + $result = json_decode($manager->swapAssets($data), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function swapQuote_sends_POST_with_data(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('POST', '/v1/api/swap-quote')), + ]); + + $data = [ + 'destinationNetwork' => 'bsc', + 'originNetwork' => 'eth', + ]; + + $result = json_decode($manager->swapQuote($data), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function updateExternalAccounts_sends_PUT_with_data(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('PUT', '/v1/api/bank-account')), + ]); + + $data = [ + 'walletAddress' => ['bscAddress' => '0x1234'], + 'bankDetails' => [ + 'bankName' => 'Test Bank', + 'bankAccountName' => 'John Doe', + 'bankAccountNumber' => '1234567890', + ], + ]; + + $result = json_decode($manager->updateExternalAccounts($data), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function whitelistAddress_sends_POST_with_data(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('POST', '/v1/api/whitelist-address')), + ]); + + $data = ['address' => '0xabcdef', 'network' => 'bsc']; + + $result = json_decode($manager->whitelistAddress($data), true); + $this->assertFalse($result['success']); + } + + #[Test] + public function validateAccount_sends_POST_with_data(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('POST', '/v1/api/account/verify')), + ]); + + $data = ['bankCode' => '011', 'accountNumber' => '1234567890']; + + $result = json_decode($manager->validateAccount($data), true); + $this->assertFalse($result['success']); + } + + // ─── Error Handling ───────────────────────────────────────────── + + #[Test] + public function it_handles_client_exception_with_response_body(): void + { + $responseBody = json_encode([ + 'success' => false, + 'message' => json_encode(['error' => 'Unauthorized']), + ]); + + $manager = $this->managerWithMockResponses([ + new RequestException( + 'Client error', + new Request('GET', '/v1/api/balance'), + new Response(401, [], $responseBody) + ), + ]); + + $result = json_decode($manager->getBalance(), true); + $this->assertFalse($result['success']); + $this->assertEquals(['error' => 'Unauthorized'], $result['message']); + } + + #[Test] + public function it_handles_client_exception_without_response(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('Network timeout', new Request('GET', '/v1/api/balance')), + ]); + + $result = json_decode($manager->getBalance(), true); + $this->assertFalse($result['success']); + $this->assertEquals('API request failed', $result['error']); + $this->assertStringContainsString('Network timeout', $result['message']); + } + + #[Test] + public function it_handles_generic_exceptions(): void + { + $mock = new MockHandler([new \RuntimeException('Something broke')]); + $handlerStack = HandlerStack::create($mock); + $client = new Client(['handler' => $handlerStack]); + $this->manager->setClient($client); + + $result = json_decode($this->manager->getBalance(), true); + $this->assertFalse($result['success']); + $this->assertEquals('An unexpected error occurred', $result['error']); + $this->assertStringContainsString('Something broke', $result['message']); + } + + // ─── Return Format ────────────────────────────────────────────── + + #[Test] + public function all_methods_return_valid_json_strings(): void + { + $manager = $this->managerWithMockResponses([ + new RequestException('fail', new Request('GET', '/test')), + new RequestException('fail', new Request('GET', '/test')), + new RequestException('fail', new Request('GET', '/test')), + new RequestException('fail', new Request('GET', '/test')), + new RequestException('fail', new Request('GET', '/test')), + new RequestException('fail', new Request('GET', '/test')), + new RequestException('fail', new Request('POST', '/test')), + new RequestException('fail', new Request('POST', '/test')), + new RequestException('fail', new Request('POST', '/test')), + new RequestException('fail', new Request('POST', '/test')), + new RequestException('fail', new Request('PUT', '/test')), + new RequestException('fail', new Request('POST', '/test')), + new RequestException('fail', new Request('POST', '/test')), + ]); + + $methods = [ + fn() => $manager->getBalance(), + fn() => $manager->getTransactionHistory(), + fn() => $manager->getBanks(), + fn() => $manager->getWhitelistedAddresses(), + fn() => $manager->getSupportedNetworks(), + fn() => $manager->getVirtualAccount(), + fn() => $manager->withdraw(['amount' => 1, 'address' => '0x', 'network' => 'bsc']), + fn() => $manager->redeemAssets(['amount' => 1, 'bankCode' => '011', 'accountNumber' => '123']), + fn() => $manager->swapAssets(['destinationNetwork' => 'bsc', 'destinationAddress' => '0x', 'originNetwork' => 'eth', 'callbackUrl' => 'https://x.com']), + fn() => $manager->swapQuote(['destinationNetwork' => 'bsc', 'originNetwork' => 'eth']), + fn() => $manager->updateExternalAccounts(['walletAddress' => ['bscAddress' => '0x']]), + fn() => $manager->whitelistAddress(['address' => '0x', 'network' => 'bsc']), + fn() => $manager->validateAccount(['bankCode' => '011', 'accountNumber' => '123']), + ]; + + foreach ($methods as $method) { + $result = $method(); + $this->assertIsString($result); + $decoded = json_decode($result, true); + $this->assertNotNull($decoded, "Method returned invalid JSON: $result"); + } + } + + // ─── AESCrypto Unit Tests ─────────────────────────────────────── + + #[Test] + public function AESCrypto_encrypt_returns_content_and_iv(): void + { + $encrypted = AESCrypto::encrypt('hello world', 'test-key'); + $this->assertArrayHasKey('content', $encrypted); + $this->assertArrayHasKey('iv', $encrypted); + $this->assertNotEmpty($encrypted['content']); + $this->assertNotEmpty($encrypted['iv']); + } + + #[Test] + public function AESCrypto_decrypt_reverses_encrypt(): void + { + $plaintext = '{"amount":100,"address":"0x1234"}'; + $key = 'my-secret-encryption-key'; + + $encrypted = AESCrypto::encrypt($plaintext, $key); + $decrypted = AESCrypto::decrypt($encrypted, $key); + + $this->assertEquals($plaintext, $decrypted); + } + + #[Test] + public function AESCrypto_decrypt_with_wrong_key_throws(): void + { + $encrypted = AESCrypto::encrypt('test data', 'correct-key'); + + $this->expectException(\Exception::class); + AESCrypto::decrypt($encrypted, 'wrong-key'); + } + + #[Test] + public function AESCrypto_produces_different_iv_each_time(): void + { + $a = AESCrypto::encrypt('same data', 'same-key'); + $b = AESCrypto::encrypt('same data', 'same-key'); + + $this->assertNotEquals($a['iv'], $b['iv']); } } \ No newline at end of file diff --git a/src/CNGnManager.php b/src/CNGnManager.php index 887b6f5..d640435 100644 --- a/src/CNGnManager.php +++ b/src/CNGnManager.php @@ -102,34 +102,76 @@ public function getTransactionHistory(int $page = 1, int $limit = 10): string{ return $this->__makeCalls("GET", "/".self::API_CURRENT_VERSION."/api/transactions?page=$page&limit=$limit"); } - public function withdraw(array $data): string{ - return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/withdraw", $data); + /** + * @param array{provider: string, bank_code: string} $data + */ + public function getVirtualAccount(): string{ + return $this->__makeCalls("GET", "/".self::API_CURRENT_VERSION."/api/virtual-account"); } + /** + * @param array{amount: int, bankCode: string, accountNumber: string, saveDetails?: bool} $data + */ public function redeemAssets(array $data): string { return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/redeemAsset", $data); } - public function createVirtualAccount(array $data): string{ - return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/createVirtualAccount", $data); + public function verifyWithdraw(string $tnxRef): string{ + return $this->__makeCalls("GET", "/".self::API_CURRENT_VERSION."/api/withdraw/verify/$tnxRef"); } - public function updateExternalAccounts(array $data): string{ - return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/updateBusiness", $data); + /** + * @param array{amount: int, address: string, network: string, shouldSaveAddress?: bool} $data + */ + public function withdraw(array $data): string{ + return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/withdraw", $data); } public function getBanks(): string{ return $this->__makeCalls("GET", "/".self::API_CURRENT_VERSION."/api/banks"); } + /** + * @param array{destinationNetwork: string, destinationAddress: string, originNetwork: string, callbackUrl: string} $data + */ public function swapAssets(array $data): string{ return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/swap", $data); } + /** + * @param array{destinationNetwork: string, originNetwork: string} $data + */ public function swapQuote(array $data): string{ return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/swap-quote", $data); } + /** + * @param array{walletAddress?: array{bscAddress?: string, atcAddress?: string, xbnAddress?: string, ethAddress?: string, polygonAddress?: string, tronAddress?: string, baseAddress?: string, bantuUserId?: string}, bankDetails?: array{bankName: string, bankAccountName: string, bankAccountNumber: string}} $data + */ + public function updateExternalAccounts(array $data): string{ + return $this->__makeCalls("PUT", "/".self::API_CURRENT_VERSION."/api/bank-account", $data); + } + + /** + * @param array{address: string, network: string} $data + */ + public function whitelistAddress(array $data): string{ + return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/whitelist-address", $data); + } + + public function getWhitelistedAddresses(): string{ + return $this->__makeCalls("GET", "/".self::API_CURRENT_VERSION."/api/whitelist-address"); + } + public function getSupportedNetworks(): string{ + return $this->__makeCalls("GET", "/".self::API_CURRENT_VERSION."/api/supported-networks"); + } + + /** + * @param array{bankCode: string, accountNumber: string} $data + */ + public function validateAccount(array $data): string{ + return $this->__makeCalls("POST", "/".self::API_CURRENT_VERSION."/api/account/verify", $data); + } } diff --git a/src/types/ICNGnManager.php b/src/types/ICNGnManager.php index 889d3cb..8281a17 100644 --- a/src/types/ICNGnManager.php +++ b/src/types/ICNGnManager.php @@ -2,16 +2,58 @@ declare(strict_types=1); namespace WrappedCBDC\types; -use WrappedCBDC\constants\AssetType; - interface ICNGnManager { public function getBalance(): string; + public function getTransactionHistory(int $page, int $limit): string; + + /** + * @param array{amount: int, address: string, networkId: string, shouldSaveAddress?: bool} $data + */ public function withdraw(array $data): string; + public function getBanks(): string; + + /** + * @param array{amount: int, bankCode: string, accountNumber: string, saveDetails?: bool} $data + */ public function redeemAssets(array $data): string; - public function createVirtualAccount(array $data): string; + + public function getVirtualAccount(): string; + + /** + * @param array{walletAddress?: array{bscAddress?: string, atcAddress?: string, xbnAddress?: string, ethAddress?: string, polygonAddress?: string, tronAddress?: string, baseAddress?: string, bantuUserId?: string}, bankDetails?: array{bankName: string, bankAccountName: string, bankAccountNumber: string}} $data + */ public function updateExternalAccounts(array $data): string; + + /** + * @param array{destinationNetworkId: string, destinationAddress: string, originNetworkId: string, callbackUrl: string} $data + */ public function swapAssets(array $data): string; + + /** + * @param array{amount: int, originNetworkId: string, destinationNetworkId: string, destinationAddress: string} $data + */ + public function swapQuote(array $data): string; + + /** + * @param string $tnxRef + */ + public function verifyWithdraw(string $tnxRef): string; + + public function getWhitelistedAddresses(): string; + + public function getSupportedNetworks(): string; + + /** + * @param array{bankCode: string, accountNumber: string} $data + */ + public function validateAccount(array $data): string; + + /** + * @param array{address: string, network: string} $data + */ + public function whitelistAddress(array $data): string; }; +