@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @var $private_key |
| 31 | - */ |
|
| 31 | + */ |
|
| 32 | 32 | protected $private_key; |
| 33 | 33 | |
| 34 | 34 | |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @var $base_uri |
| 38 | 38 | * |
| 39 | - */ |
|
| 39 | + */ |
|
| 40 | 40 | protected $base_uri = 'https://api.demo.payant.ng'; |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @var $client |
| 45 | 45 | * |
| 46 | - */ |
|
| 46 | + */ |
|
| 47 | 47 | protected $client; |
| 48 | 48 | |
| 49 | 49 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | - * Get Base Url from Payant config file |
|
| 62 | - */ |
|
| 61 | + * Get Base Url from Payant config file |
|
| 62 | + */ |
|
| 63 | 63 | public function setBaseUrl() |
| 64 | 64 | { |
| 65 | 65 | if(Config::get('payant.mode') == 'LIVE') |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private function setRequestOptions() |
| 84 | 84 | { |
| 85 | - $authorization_string = 'Bearer '. $this->private_key; |
|
| 85 | + $authorization_string = 'Bearer '. $this->private_key; |
|
| 86 | 86 | |
| 87 | 87 | //Set up Guzzle |
| 88 | 88 | $this->client = new Client( [ |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | /** |
| 101 | 101 | * [getBanks Get Banks and their ids (Nigeria)] |
| 102 | 102 | * @return object [list of banks and their respective bank_ids] |
| 103 | - */ |
|
| 103 | + */ |
|
| 104 | 104 | public function getBanks(){ |
| 105 | 105 | return $this->sendRequest('get', '/banks'); |
| 106 | 106 | } |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | * @param array $client_data [description] |
| 113 | 113 | * Required fields - 'settlement_bank', 'account_number' |
| 114 | 114 | * @return object |
| 115 | - */ |
|
| 115 | + */ |
|
| 116 | 116 | public function resolveAccount( array $client_data){ |
| 117 | 117 | // Mandatory fields |
| 118 | 118 | $required_values = ['settlement_bank', 'account_number']; |
| 119 | 119 | |
| 120 | 120 | if(!array_keys_exist($client_data, $required_values)){ |
| 121 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 121 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $url = '/resolve-account'; |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | * Required fields - 'first_name', 'last_name', 'email', 'phone' |
| 136 | 136 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
| 137 | 137 | * @return object |
| 138 | - */ |
|
| 138 | + */ |
|
| 139 | 139 | public function addClient( array $client_data){ |
| 140 | 140 | // Mandatory fields |
| 141 | 141 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
| 142 | 142 | |
| 143 | 143 | if(!array_keys_exist($client_data, $required_values)){ |
| 144 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 144 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $url = '/clients'; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * [getClient Get client Details] |
| 157 | 157 | * @param string $client_id |
| 158 | 158 | * @return object |
| 159 | - */ |
|
| 159 | + */ |
|
| 160 | 160 | public function getClient($client_id = null){ |
| 161 | 161 | if(!$client_id){ |
| 162 | 162 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | - * [editClient - Edit Existing Client] |
|
| 176 | - * @param string $client_id |
|
| 177 | - * @param array $client_data |
|
| 178 | - * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
| 179 | - * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
| 180 | - */ |
|
| 175 | + * [editClient - Edit Existing Client] |
|
| 176 | + * @param string $client_id |
|
| 177 | + * @param array $client_data |
|
| 178 | + * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
| 179 | + * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
| 180 | + */ |
|
| 181 | 181 | public function editClient( $client_id, array $client_data){ |
| 182 | 182 | if(!$client_id){ |
| 183 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
| 183 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | $url = "/clients/{$client_id}"; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
| 190 | 190 | |
| 191 | 191 | if(!array_keys_exist($client_data, $required_values)){ |
| 192 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 192 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | return $this->sendRequest('put', $url, ['form_params' => $client_data]); |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * [getInvoice ] |
|
| 277 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 278 | - * @return object |
|
| 279 | - */ |
|
| 276 | + * [getInvoice ] |
|
| 277 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 278 | + * @return object |
|
| 279 | + */ |
|
| 280 | 280 | public function getInvoice(string $reference_code){ |
| 281 | 281 | if(!$reference_code){ |
| 282 | 282 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -292,10 +292,10 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | - * [sendInvoice] |
|
| 296 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 297 | - * @return object |
|
| 298 | - */ |
|
| 295 | + * [sendInvoice] |
|
| 296 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 297 | + * @return object |
|
| 298 | + */ |
|
| 299 | 299 | public function sendInvoice(string $reference_code = null){ |
| 300 | 300 | if(!$reference_code){ |
| 301 | 301 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | /** |
| 314 | - * [getInvoiceHistory] |
|
| 315 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 316 | - * @param string $start [Format - DD/MM/YYYY] |
|
| 317 | - * @param string $end [Format - DD/MM/YYYY] |
|
| 318 | - * @return object |
|
| 319 | - */ |
|
| 314 | + * [getInvoiceHistory] |
|
| 315 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 316 | + * @param string $start [Format - DD/MM/YYYY] |
|
| 317 | + * @param string $end [Format - DD/MM/YYYY] |
|
| 318 | + * @return object |
|
| 319 | + */ |
|
| 320 | 320 | public function getInvoiceHistory($period, $start = null, $end = null){ |
| 321 | 321 | if(!$period){ |
| 322 | 322 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -334,10 +334,10 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | - * [deleteInvoice] |
|
| 338 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 339 | - * @return object |
|
| 340 | - */ |
|
| 337 | + * [deleteInvoice] |
|
| 338 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 339 | + * @return object |
|
| 340 | + */ |
|
| 341 | 341 | public function deleteInvoice(string $reference_code){ |
| 342 | 342 | if(!$reference_code){ |
| 343 | 343 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -387,10 +387,10 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | - * [getTransfer ] |
|
| 391 | - * @param string $reference_code [Mandatory - Transfer Reference Code] |
|
| 392 | - * @return object |
|
| 393 | - */ |
|
| 390 | + * [getTransfer ] |
|
| 391 | + * @param string $reference_code [Mandatory - Transfer Reference Code] |
|
| 392 | + * @return object |
|
| 393 | + */ |
|
| 394 | 394 | public function getTransfer(string $reference_code){ |
| 395 | 395 | if(!$reference_code){ |
| 396 | 396 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -407,12 +407,12 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | |
| 409 | 409 | /** |
| 410 | - * [getTransferHistory] |
|
| 411 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 412 | - * @param string $start [Format - DD/MM/YYYY] |
|
| 413 | - * @param string $end [Format - DD/MM/YYYY] |
|
| 414 | - * @return object |
|
| 415 | - */ |
|
| 410 | + * [getTransferHistory] |
|
| 411 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 412 | + * @param string $start [Format - DD/MM/YYYY] |
|
| 413 | + * @param string $end [Format - DD/MM/YYYY] |
|
| 414 | + * @return object |
|
| 415 | + */ |
|
| 416 | 416 | public function getTransferHistory($period, $start = null, $end = null){ |
| 417 | 417 | if(!$period){ |
| 418 | 418 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | - * [deleteTransfer] |
|
| 435 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 436 | - * @return object |
|
| 437 | - */ |
|
| 434 | + * [deleteTransfer] |
|
| 435 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 436 | + * @return object |
|
| 437 | + */ |
|
| 438 | 438 | public function deleteTransfer(string $reference_code){ |
| 439 | 439 | if(!$reference_code){ |
| 440 | 440 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -451,13 +451,13 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | - * [addPayment] |
|
| 455 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 456 | - * @param string $due_date [Mandatory - [Format - DD/MM/YYYY]] |
|
| 457 | - * @param string $amount [Mandatory] |
|
| 458 | - * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
| 459 | - * @return object |
|
| 460 | - */ |
|
| 454 | + * [addPayment] |
|
| 455 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 456 | + * @param string $due_date [Mandatory - [Format - DD/MM/YYYY]] |
|
| 457 | + * @param string $amount [Mandatory] |
|
| 458 | + * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
| 459 | + * @return object |
|
| 460 | + */ |
|
| 461 | 461 | public function addPayment(string $reference_code, string $due_date, string $amount, string $channel){ |
| 462 | 462 | if(!$reference_code){ |
| 463 | 463 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | |
| 498 | 498 | /** |
| 499 | - * [getPayment] |
|
| 500 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 501 | - * @return object |
|
| 502 | - */ |
|
| 499 | + * [getPayment] |
|
| 500 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 501 | + * @return object |
|
| 502 | + */ |
|
| 503 | 503 | public function getPayment(string $reference_code){ |
| 504 | 504 | if(!$reference_code){ |
| 505 | 505 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -515,12 +515,12 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | |
| 517 | 517 | /** |
| 518 | - * [getPaymentHistory] |
|
| 519 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 520 | - * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
| 521 | - * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
| 522 | - * @return object |
|
| 523 | - */ |
|
| 518 | + * [getPaymentHistory] |
|
| 519 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 520 | + * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
| 521 | + * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
| 522 | + * @return object |
|
| 523 | + */ |
|
| 524 | 524 | public function getPaymentHistory(string $period, string $start, string $end){ |
| 525 | 525 | if(!$period){ |
| 526 | 526 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -539,11 +539,11 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | |
| 541 | 541 | /** |
| 542 | - * [addWallet] |
|
| 543 | - * @param string $name [Mandatory - Wallet's name] |
|
| 544 | - * @param string $passcode [Mandatory - Wallet's passcode] |
|
| 545 | - * @return object |
|
| 546 | - */ |
|
| 542 | + * [addWallet] |
|
| 543 | + * @param string $name [Mandatory - Wallet's name] |
|
| 544 | + * @param string $passcode [Mandatory - Wallet's passcode] |
|
| 545 | + * @return object |
|
| 546 | + */ |
|
| 547 | 547 | public function addWallet(string $name, string $passcode){ |
| 548 | 548 | if(!$name){ |
| 549 | 549 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid name"); |
@@ -568,10 +568,10 @@ discard block |
||
| 568 | 568 | |
| 569 | 569 | |
| 570 | 570 | /** |
| 571 | - * [getWallet] |
|
| 572 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 573 | - * @return object |
|
| 574 | - */ |
|
| 571 | + * [getWallet] |
|
| 572 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 573 | + * @return object |
|
| 574 | + */ |
|
| 575 | 575 | public function getWallet(string $reference_code){ |
| 576 | 576 | if(!$reference_code){ |
| 577 | 577 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -587,12 +587,12 @@ discard block |
||
| 587 | 587 | |
| 588 | 588 | |
| 589 | 589 | /** |
| 590 | - * [changeWalletPasscode] |
|
| 591 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 592 | - * @param string $old_passcode [Mandatory - Wallet's Old Passcode] |
|
| 593 | - * @param string $passcode [Mandatory - Wallet's Passcode] |
|
| 594 | - * @return object |
|
| 595 | - */ |
|
| 590 | + * [changeWalletPasscode] |
|
| 591 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 592 | + * @param string $old_passcode [Mandatory - Wallet's Old Passcode] |
|
| 593 | + * @param string $passcode [Mandatory - Wallet's Passcode] |
|
| 594 | + * @return object |
|
| 595 | + */ |
|
| 596 | 596 | public function changeWalletPasscode(string $reference_code, string $old_passcode, string $passcode){ |
| 597 | 597 | if(!$reference_code){ |
| 598 | 598 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -621,9 +621,9 @@ discard block |
||
| 621 | 621 | |
| 622 | 622 | |
| 623 | 623 | /** |
| 624 | - * [getWallets] |
|
| 625 | - * @return object |
|
| 626 | - */ |
|
| 624 | + * [getWallets] |
|
| 625 | + * @return object |
|
| 626 | + */ |
|
| 627 | 627 | public function getWallets(){ |
| 628 | 628 | |
| 629 | 629 | $url = "/wallets"; |
@@ -636,10 +636,10 @@ discard block |
||
| 636 | 636 | |
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | - * [setWalletStatus] |
|
| 640 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 641 | - * @return object |
|
| 642 | - */ |
|
| 639 | + * [setWalletStatus] |
|
| 640 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 641 | + * @return object |
|
| 642 | + */ |
|
| 643 | 643 | public function setWalletStatus(string $reference_code){ |
| 644 | 644 | if(!$reference_code){ |
| 645 | 645 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -655,14 +655,14 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | |
| 657 | 657 | /** |
| 658 | - * [withdrawFromWallet] |
|
| 659 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 660 | - * @param array $client_data [Mandatory - Client Data] |
|
| 661 | - * Required fields - 'settlement_bank', 'account_number' |
|
| 662 | - * @param string $amount [Mandatory - Amount to send] |
|
| 663 | - * @param string $passcode [Mandatory - Wallet's Passcode] |
|
| 664 | - * @return object |
|
| 665 | - */ |
|
| 658 | + * [withdrawFromWallet] |
|
| 659 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 660 | + * @param array $client_data [Mandatory - Client Data] |
|
| 661 | + * Required fields - 'settlement_bank', 'account_number' |
|
| 662 | + * @param string $amount [Mandatory - Amount to send] |
|
| 663 | + * @param string $passcode [Mandatory - Wallet's Passcode] |
|
| 664 | + * @return object |
|
| 665 | + */ |
|
| 666 | 666 | public function withdrawFromWallet(string $reference_code, array $client_data, string $amount, string $passcode){ |
| 667 | 667 | if(!$reference_code){ |
| 668 | 668 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | $required_values = ['settlement_bank', 'account_number']; |
| 673 | 673 | |
| 674 | 674 | if(!array_keys_exist($client_data, $required_values)){ |
| 675 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 675 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | if(!$amount){ |
@@ -700,13 +700,13 @@ discard block |
||
| 700 | 700 | |
| 701 | 701 | |
| 702 | 702 | /** |
| 703 | - * [getWalletTransactions] |
|
| 704 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 705 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 706 | - * @param string $start [Format - DD/MM/YYYY] |
|
| 707 | - * @param string $end [Format - DD/MM/YYYY] |
|
| 708 | - * @return object |
|
| 709 | - */ |
|
| 703 | + * [getWalletTransactions] |
|
| 704 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
| 705 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 706 | + * @param string $start [Format - DD/MM/YYYY] |
|
| 707 | + * @param string $end [Format - DD/MM/YYYY] |
|
| 708 | + * @return object |
|
| 709 | + */ |
|
| 710 | 710 | public function getWalletTransactions(string $reference_code, $period, $start = null, $end = null){ |
| 711 | 711 | if(!$reference_code){ |
| 712 | 712 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -728,13 +728,13 @@ discard block |
||
| 728 | 728 | |
| 729 | 729 | |
| 730 | 730 | /** |
| 731 | - * [addProduct] |
|
| 732 | - * @param string $name [Mandatory - Product's name] |
|
| 733 | - * @param string $description [Mandatory - Product's description] |
|
| 734 | - * @param string $unit_cost [Mandatory - Product's unit cost] |
|
| 735 | - * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
| 736 | - * @return object |
|
| 737 | - */ |
|
| 731 | + * [addProduct] |
|
| 732 | + * @param string $name [Mandatory - Product's name] |
|
| 733 | + * @param string $description [Mandatory - Product's description] |
|
| 734 | + * @param string $unit_cost [Mandatory - Product's unit cost] |
|
| 735 | + * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
| 736 | + * @return object |
|
| 737 | + */ |
|
| 738 | 738 | public function addProduct(string $name, string $description, string $unit_cost, string $type){ |
| 739 | 739 | if(!$name){ |
| 740 | 740 | throw new IsNull("Error Processing Request - Null/Invalid name"); |
@@ -774,10 +774,10 @@ discard block |
||
| 774 | 774 | |
| 775 | 775 | |
| 776 | 776 | /** |
| 777 | - * [getProduct] |
|
| 778 | - * @param int $product_id [Mandatory - Product ID] |
|
| 779 | - * @return object |
|
| 780 | - */ |
|
| 777 | + * [getProduct] |
|
| 778 | + * @param int $product_id [Mandatory - Product ID] |
|
| 779 | + * @return object |
|
| 780 | + */ |
|
| 781 | 781 | public function getProduct($product_id){ |
| 782 | 782 | if(!$product_id){ |
| 783 | 783 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); |
@@ -793,14 +793,14 @@ discard block |
||
| 793 | 793 | |
| 794 | 794 | |
| 795 | 795 | /** |
| 796 | - * [editProduct] |
|
| 797 | - * @param string $product_id [Mandatory - Product ID] |
|
| 798 | - * @param array $product_data [description] |
|
| 799 | - * @return object |
|
| 800 | - */ |
|
| 796 | + * [editProduct] |
|
| 797 | + * @param string $product_id [Mandatory - Product ID] |
|
| 798 | + * @param array $product_data [description] |
|
| 799 | + * @return object |
|
| 800 | + */ |
|
| 801 | 801 | public function editProduct($product_id, array $product_data){ |
| 802 | 802 | if(!$product_id){ |
| 803 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
| 803 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | //Validate Type |
@@ -814,13 +814,13 @@ discard block |
||
| 814 | 814 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - $url = "/products/{$product_id}"; |
|
| 817 | + $url = "/products/{$product_id}"; |
|
| 818 | 818 | |
| 819 | - // Mandatory fields |
|
| 820 | - $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
| 819 | + // Mandatory fields |
|
| 820 | + $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
| 821 | 821 | |
| 822 | 822 | if(!array_keys_exist($product_data, $required_values)){ |
| 823 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 823 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | return $this->sendRequest('put', $url, ['form_params' => $product_data]); |
@@ -830,9 +830,9 @@ discard block |
||
| 830 | 830 | |
| 831 | 831 | |
| 832 | 832 | /** |
| 833 | - * [getProducts] |
|
| 834 | - * @return object |
|
| 835 | - */ |
|
| 833 | + * [getProducts] |
|
| 834 | + * @return object |
|
| 835 | + */ |
|
| 836 | 836 | public function getProducts(){ |
| 837 | 837 | $url = "/products"; |
| 838 | 838 | |
@@ -843,10 +843,10 @@ discard block |
||
| 843 | 843 | |
| 844 | 844 | |
| 845 | 845 | /** |
| 846 | - * [deleteProduct] |
|
| 847 | - * @param $product_id [Mandatory - Product ID] |
|
| 848 | - * @return object |
|
| 849 | - */ |
|
| 846 | + * [deleteProduct] |
|
| 847 | + * @param $product_id [Mandatory - Product ID] |
|
| 848 | + * @return object |
|
| 849 | + */ |
|
| 850 | 850 | public function deleteProduct($product_id){ |
| 851 | 851 | if(!$product_id){ |
| 852 | 852 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
@@ -860,12 +860,12 @@ discard block |
||
| 860 | 860 | |
| 861 | 861 | |
| 862 | 862 | /** |
| 863 | - * [sendRequest] |
|
| 864 | - * @param string $method [Mandatory - request method <get | post | put | delete> ] |
|
| 865 | - * @param string $url [Mandatory - url to send request to] |
|
| 866 | - * @param array $params [data to post to request url] |
|
| 867 | - * @return object |
|
| 868 | - */ |
|
| 863 | + * [sendRequest] |
|
| 864 | + * @param string $method [Mandatory - request method <get | post | put | delete> ] |
|
| 865 | + * @param string $url [Mandatory - url to send request to] |
|
| 866 | + * @param array $params [data to post to request url] |
|
| 867 | + * @return object |
|
| 868 | + */ |
|
| 869 | 869 | public function sendRequest($method, $url, $params=[]) |
| 870 | 870 | { |
| 871 | 871 | try{ |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function setBaseUrl() |
| 64 | 64 | { |
| 65 | - if(Config::get('payant.mode') == 'LIVE') |
|
| 65 | + if (Config::get('payant.mode') == 'LIVE') |
|
| 66 | 66 | { |
| 67 | 67 | $this->base_uri = "https://api.payant.ng"; |
| 68 | 68 | } |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private function setRequestOptions() |
| 84 | 84 | { |
| 85 | - $authorization_string = 'Bearer '. $this->private_key; |
|
| 85 | + $authorization_string = 'Bearer '.$this->private_key; |
|
| 86 | 86 | |
| 87 | 87 | //Set up Guzzle |
| 88 | - $this->client = new Client( [ |
|
| 88 | + $this->client = new Client([ |
|
| 89 | 89 | 'base_uri' => $this->base_uri, |
| 90 | 90 | 'protocols' => ['https'], |
| 91 | 91 | 'headers' => [ |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * [getBanks Get Banks and their ids (Nigeria)] |
| 102 | 102 | * @return object [list of banks and their respective bank_ids] |
| 103 | 103 | */ |
| 104 | - public function getBanks(){ |
|
| 104 | + public function getBanks() { |
|
| 105 | 105 | return $this->sendRequest('get', '/banks'); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | * Required fields - 'settlement_bank', 'account_number' |
| 114 | 114 | * @return object |
| 115 | 115 | */ |
| 116 | - public function resolveAccount( array $client_data){ |
|
| 116 | + public function resolveAccount(array $client_data) { |
|
| 117 | 117 | // Mandatory fields |
| 118 | 118 | $required_values = ['settlement_bank', 'account_number']; |
| 119 | 119 | |
| 120 | - if(!array_keys_exist($client_data, $required_values)){ |
|
| 120 | + if (!array_keys_exist($client_data, $required_values)) { |
|
| 121 | 121 | throw new RequiredValuesMissing("Missing required values :("); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
| 137 | 137 | * @return object |
| 138 | 138 | */ |
| 139 | - public function addClient( array $client_data){ |
|
| 139 | + public function addClient(array $client_data) { |
|
| 140 | 140 | // Mandatory fields |
| 141 | 141 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
| 142 | 142 | |
| 143 | - if(!array_keys_exist($client_data, $required_values)){ |
|
| 143 | + if (!array_keys_exist($client_data, $required_values)) { |
|
| 144 | 144 | throw new RequiredValuesMissing("Missing required values :("); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | * @param string $client_id |
| 158 | 158 | * @return object |
| 159 | 159 | */ |
| 160 | - public function getClient($client_id = null){ |
|
| 161 | - if(!$client_id){ |
|
| 160 | + public function getClient($client_id = null) { |
|
| 161 | + if (!$client_id) { |
|
| 162 | 162 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | * Required fields - 'first_name', 'last_name', 'email', 'phone' |
| 179 | 179 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
| 180 | 180 | */ |
| 181 | - public function editClient( $client_id, array $client_data){ |
|
| 182 | - if(!$client_id){ |
|
| 181 | + public function editClient($client_id, array $client_data) { |
|
| 182 | + if (!$client_id) { |
|
| 183 | 183 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | // Mandatory fields |
| 189 | 189 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
| 190 | 190 | |
| 191 | - if(!array_keys_exist($client_data, $required_values)){ |
|
| 191 | + if (!array_keys_exist($client_data, $required_values)) { |
|
| 192 | 192 | throw new RequiredValuesMissing("Missing required values :("); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | * [deleteClient] |
| 204 | 204 | * @param string $client_id [description] |
| 205 | 205 | */ |
| 206 | - public function deleteClient($client_id = null){ |
|
| 207 | - if(!$client_id){ |
|
| 206 | + public function deleteClient($client_id = null) { |
|
| 207 | + if (!$client_id) { |
|
| 208 | 208 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
| 209 | 209 | } |
| 210 | 210 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @param string $fee_bearer [Mandatory] |
| 228 | 228 | * @param array $items [Mandatory] |
| 229 | 229 | */ |
| 230 | - public function addInvoice($client_id, array $client_data, $due_date, $fee_bearer, array $items){ |
|
| 230 | + public function addInvoice($client_id, array $client_data, $due_date, $fee_bearer, array $items) { |
|
| 231 | 231 | // Mandatory Client fields |
| 232 | 232 | $required_client_values = ['first_name', 'last_name', 'email', 'phone']; |
| 233 | 233 | |
@@ -237,21 +237,21 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | // Either the client Id is supplied or a new client data is provided |
| 240 | - if(!$client_id && !array_keys_exist($client_data, $required_client_values)){ |
|
| 240 | + if (!$client_id && !array_keys_exist($client_data, $required_client_values)) { |
|
| 241 | 241 | throw new RequiredValuesMissing("Missing required values :( - Provide client_id or client_data"); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if(!$due_date){ |
|
| 244 | + if (!$due_date) { |
|
| 245 | 245 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Due Date"); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if(!$fee_bearer){ |
|
| 248 | + if (!$fee_bearer) { |
|
| 249 | 249 | throw new IsNull("Error Processing Request - Null Fee Bearer"); |
| 250 | 250 | }elseif (!in_array($fee_bearer, $valid_fee_bearers)) { |
| 251 | 251 | throw new InvalidFeeBearer("Invalid Fee Bearer - Use either 'account' or 'client'"); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if(!is_array($items)){ |
|
| 254 | + if (!is_array($items)) { |
|
| 255 | 255 | throw new IsInvalid("Error Processing Request - Invalid Items"); |
| 256 | 256 | } |
| 257 | 257 | |
@@ -277,8 +277,8 @@ discard block |
||
| 277 | 277 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 278 | 278 | * @return object |
| 279 | 279 | */ |
| 280 | - public function getInvoice(string $reference_code){ |
|
| 281 | - if(!$reference_code){ |
|
| 280 | + public function getInvoice(string $reference_code) { |
|
| 281 | + if (!$reference_code) { |
|
| 282 | 282 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 283 | 283 | } |
| 284 | 284 | |
@@ -296,8 +296,8 @@ discard block |
||
| 296 | 296 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 297 | 297 | * @return object |
| 298 | 298 | */ |
| 299 | - public function sendInvoice(string $reference_code = null){ |
|
| 300 | - if(!$reference_code){ |
|
| 299 | + public function sendInvoice(string $reference_code = null) { |
|
| 300 | + if (!$reference_code) { |
|
| 301 | 301 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 302 | 302 | } |
| 303 | 303 | |
@@ -317,8 +317,8 @@ discard block |
||
| 317 | 317 | * @param string $end [Format - DD/MM/YYYY] |
| 318 | 318 | * @return object |
| 319 | 319 | */ |
| 320 | - public function getInvoiceHistory($period, $start = null, $end = null){ |
|
| 321 | - if(!$period){ |
|
| 320 | + public function getInvoiceHistory($period, $start = null, $end = null) { |
|
| 321 | + if (!$period) { |
|
| 322 | 322 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -338,8 +338,8 @@ discard block |
||
| 338 | 338 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 339 | 339 | * @return object |
| 340 | 340 | */ |
| 341 | - public function deleteInvoice(string $reference_code){ |
|
| 342 | - if(!$reference_code){ |
|
| 341 | + public function deleteInvoice(string $reference_code) { |
|
| 342 | + if (!$reference_code) { |
|
| 343 | 343 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 344 | 344 | } |
| 345 | 345 | |
@@ -360,15 +360,15 @@ discard block |
||
| 360 | 360 | * @param string $amount [Mandatory] |
| 361 | 361 | * @return object |
| 362 | 362 | */ |
| 363 | - public function addTransfer(array $client_data, string $amount){ |
|
| 363 | + public function addTransfer(array $client_data, string $amount) { |
|
| 364 | 364 | // Mandatory Client fields |
| 365 | 365 | $required_client_values = ['first_name', 'last_name', 'email', 'phone', 'settlement_bank', 'account_number']; |
| 366 | 366 | |
| 367 | - if(!array_keys_exist($client_data, $required_client_values)){ |
|
| 367 | + if (!array_keys_exist($client_data, $required_client_values)) { |
|
| 368 | 368 | throw new RequiredValuesMissing("Missing required values :( - Provide client_data"); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if(!$amount){ |
|
| 371 | + if (!$amount) { |
|
| 372 | 372 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount"); |
| 373 | 373 | } |
| 374 | 374 | |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | * @param string $reference_code [Mandatory - Transfer Reference Code] |
| 392 | 392 | * @return object |
| 393 | 393 | */ |
| 394 | - public function getTransfer(string $reference_code){ |
|
| 395 | - if(!$reference_code){ |
|
| 394 | + public function getTransfer(string $reference_code) { |
|
| 395 | + if (!$reference_code) { |
|
| 396 | 396 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 397 | 397 | } |
| 398 | 398 | |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | * @param string $end [Format - DD/MM/YYYY] |
| 414 | 414 | * @return object |
| 415 | 415 | */ |
| 416 | - public function getTransferHistory($period, $start = null, $end = null){ |
|
| 417 | - if(!$period){ |
|
| 416 | + public function getTransferHistory($period, $start = null, $end = null) { |
|
| 417 | + if (!$period) { |
|
| 418 | 418 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
| 419 | 419 | } |
| 420 | 420 | |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 436 | 436 | * @return object |
| 437 | 437 | */ |
| 438 | - public function deleteTransfer(string $reference_code){ |
|
| 439 | - if(!$reference_code){ |
|
| 438 | + public function deleteTransfer(string $reference_code) { |
|
| 439 | + if (!$reference_code) { |
|
| 440 | 440 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 441 | 441 | } |
| 442 | 442 | |
@@ -458,22 +458,22 @@ discard block |
||
| 458 | 458 | * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
| 459 | 459 | * @return object |
| 460 | 460 | */ |
| 461 | - public function addPayment(string $reference_code, string $due_date, string $amount, string $channel){ |
|
| 462 | - if(!$reference_code){ |
|
| 461 | + public function addPayment(string $reference_code, string $due_date, string $amount, string $channel) { |
|
| 462 | + if (!$reference_code) { |
|
| 463 | 463 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - if(!$due_date){ |
|
| 466 | + if (!$due_date) { |
|
| 467 | 467 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid date"); |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - if(!$amount){ |
|
| 470 | + if (!$amount) { |
|
| 471 | 471 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount"); |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | $valid_channels = ["Cash", "BankTransfer", "POS", "Cheque"]; |
| 475 | 475 | |
| 476 | - if(!$channel){ |
|
| 476 | + if (!$channel) { |
|
| 477 | 477 | throw new IsNull("Error Processing Request - Null/Invalid amount"); |
| 478 | 478 | }elseif (!in_array(ucfirst($channel), $valid_channels)) { |
| 479 | 479 | throw new IsInvalid("Invalid Channel - Cash, BankTransfer, POS or Cheque"); |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 501 | 501 | * @return object |
| 502 | 502 | */ |
| 503 | - public function getPayment(string $reference_code){ |
|
| 504 | - if(!$reference_code){ |
|
| 503 | + public function getPayment(string $reference_code) { |
|
| 504 | + if (!$reference_code) { |
|
| 505 | 505 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 506 | 506 | } |
| 507 | 507 | |
@@ -521,8 +521,8 @@ discard block |
||
| 521 | 521 | * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
| 522 | 522 | * @return object |
| 523 | 523 | */ |
| 524 | - public function getPaymentHistory(string $period, string $start, string $end){ |
|
| 525 | - if(!$period){ |
|
| 524 | + public function getPaymentHistory(string $period, string $start, string $end) { |
|
| 525 | + if (!$period) { |
|
| 526 | 526 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
| 527 | 527 | } |
| 528 | 528 | |
@@ -544,12 +544,12 @@ discard block |
||
| 544 | 544 | * @param string $passcode [Mandatory - Wallet's passcode] |
| 545 | 545 | * @return object |
| 546 | 546 | */ |
| 547 | - public function addWallet(string $name, string $passcode){ |
|
| 548 | - if(!$name){ |
|
| 547 | + public function addWallet(string $name, string $passcode) { |
|
| 548 | + if (!$name) { |
|
| 549 | 549 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid name"); |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - if(!$passcode || strlen($passcode) < 6){ |
|
| 552 | + if (!$passcode || strlen($passcode) < 6) { |
|
| 553 | 553 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid passcode/ length"); |
| 554 | 554 | } |
| 555 | 555 | |
@@ -572,8 +572,8 @@ discard block |
||
| 572 | 572 | * @param string $reference_code [Mandatory - Wallet's Reference Code] |
| 573 | 573 | * @return object |
| 574 | 574 | */ |
| 575 | - public function getWallet(string $reference_code){ |
|
| 576 | - if(!$reference_code){ |
|
| 575 | + public function getWallet(string $reference_code) { |
|
| 576 | + if (!$reference_code) { |
|
| 577 | 577 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 578 | 578 | } |
| 579 | 579 | |
@@ -593,16 +593,16 @@ discard block |
||
| 593 | 593 | * @param string $passcode [Mandatory - Wallet's Passcode] |
| 594 | 594 | * @return object |
| 595 | 595 | */ |
| 596 | - public function changeWalletPasscode(string $reference_code, string $old_passcode, string $passcode){ |
|
| 597 | - if(!$reference_code){ |
|
| 596 | + public function changeWalletPasscode(string $reference_code, string $old_passcode, string $passcode) { |
|
| 597 | + if (!$reference_code) { |
|
| 598 | 598 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - if(!$old_passcode){ |
|
| 601 | + if (!$old_passcode) { |
|
| 602 | 602 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid old_passcode"); |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - if(!$passcode || strlen($passcode) < 6){ |
|
| 605 | + if (!$passcode || strlen($passcode) < 6) { |
|
| 606 | 606 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid passcode"); |
| 607 | 607 | } |
| 608 | 608 | |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | * [getWallets] |
| 625 | 625 | * @return object |
| 626 | 626 | */ |
| 627 | - public function getWallets(){ |
|
| 627 | + public function getWallets() { |
|
| 628 | 628 | |
| 629 | 629 | $url = "/wallets"; |
| 630 | 630 | |
@@ -640,8 +640,8 @@ discard block |
||
| 640 | 640 | * @param string $reference_code [Mandatory - Wallet's Reference Code] |
| 641 | 641 | * @return object |
| 642 | 642 | */ |
| 643 | - public function setWalletStatus(string $reference_code){ |
|
| 644 | - if(!$reference_code){ |
|
| 643 | + public function setWalletStatus(string $reference_code) { |
|
| 644 | + if (!$reference_code) { |
|
| 645 | 645 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 646 | 646 | } |
| 647 | 647 | |
@@ -663,23 +663,23 @@ discard block |
||
| 663 | 663 | * @param string $passcode [Mandatory - Wallet's Passcode] |
| 664 | 664 | * @return object |
| 665 | 665 | */ |
| 666 | - public function withdrawFromWallet(string $reference_code, array $client_data, string $amount, string $passcode){ |
|
| 667 | - if(!$reference_code){ |
|
| 666 | + public function withdrawFromWallet(string $reference_code, array $client_data, string $amount, string $passcode) { |
|
| 667 | + if (!$reference_code) { |
|
| 668 | 668 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | // Mandatory fields |
| 672 | 672 | $required_values = ['settlement_bank', 'account_number']; |
| 673 | 673 | |
| 674 | - if(!array_keys_exist($client_data, $required_values)){ |
|
| 674 | + if (!array_keys_exist($client_data, $required_values)) { |
|
| 675 | 675 | throw new RequiredValuesMissing("Missing required values :("); |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - if(!$amount){ |
|
| 678 | + if (!$amount) { |
|
| 679 | 679 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount"); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - if(!$passcode){ |
|
| 682 | + if (!$passcode) { |
|
| 683 | 683 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid passcode"); |
| 684 | 684 | } |
| 685 | 685 | |
@@ -707,12 +707,12 @@ discard block |
||
| 707 | 707 | * @param string $end [Format - DD/MM/YYYY] |
| 708 | 708 | * @return object |
| 709 | 709 | */ |
| 710 | - public function getWalletTransactions(string $reference_code, $period, $start = null, $end = null){ |
|
| 711 | - if(!$reference_code){ |
|
| 710 | + public function getWalletTransactions(string $reference_code, $period, $start = null, $end = null) { |
|
| 711 | + if (!$reference_code) { |
|
| 712 | 712 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | - if(!$period){ |
|
| 715 | + if (!$period) { |
|
| 716 | 716 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
| 717 | 717 | } |
| 718 | 718 | |
@@ -735,23 +735,23 @@ discard block |
||
| 735 | 735 | * @param string $type [Mandatory - Product type 'product' or 'service'] |
| 736 | 736 | * @return object |
| 737 | 737 | */ |
| 738 | - public function addProduct(string $name, string $description, string $unit_cost, string $type){ |
|
| 739 | - if(!$name){ |
|
| 738 | + public function addProduct(string $name, string $description, string $unit_cost, string $type) { |
|
| 739 | + if (!$name) { |
|
| 740 | 740 | throw new IsNull("Error Processing Request - Null/Invalid name"); |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - if(!$description){ |
|
| 743 | + if (!$description) { |
|
| 744 | 744 | throw new IsNull("Error Processing Request - Null/Invalid description"); |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - if(!$unit_cost){ |
|
| 747 | + if (!$unit_cost) { |
|
| 748 | 748 | throw new IsNull("Error Processing Request - Null/Invalid unit_cost"); |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | //Validate Product Type |
| 752 | 752 | $valid_product_type = ["product", "service"]; |
| 753 | 753 | |
| 754 | - if(!$type){ |
|
| 754 | + if (!$type) { |
|
| 755 | 755 | throw new IsNull("Error Processing Request - Null/Invalid type"); |
| 756 | 756 | }elseif (!in_array(strtolower($type), $valid_product_type)) { |
| 757 | 757 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
@@ -778,8 +778,8 @@ discard block |
||
| 778 | 778 | * @param int $product_id [Mandatory - Product ID] |
| 779 | 779 | * @return object |
| 780 | 780 | */ |
| 781 | - public function getProduct($product_id){ |
|
| 782 | - if(!$product_id){ |
|
| 781 | + public function getProduct($product_id) { |
|
| 782 | + if (!$product_id) { |
|
| 783 | 783 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); |
| 784 | 784 | } |
| 785 | 785 | |
@@ -798,8 +798,8 @@ discard block |
||
| 798 | 798 | * @param array $product_data [description] |
| 799 | 799 | * @return object |
| 800 | 800 | */ |
| 801 | - public function editProduct($product_id, array $product_data){ |
|
| 802 | - if(!$product_id){ |
|
| 801 | + public function editProduct($product_id, array $product_data) { |
|
| 802 | + if (!$product_id) { |
|
| 803 | 803 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
| 804 | 804 | } |
| 805 | 805 | |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | $valid_product_type = ["product", "service"]; |
| 810 | 810 | |
| 811 | - if(!$product_type){ |
|
| 811 | + if (!$product_type) { |
|
| 812 | 812 | throw new IsNull("Error Processing Request - Null/Invalid type"); |
| 813 | 813 | }elseif (!in_array($product_type, $valid_product_type)) { |
| 814 | 814 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | // Mandatory fields |
| 820 | 820 | $required_values = ['name', 'description', 'unit_cost', 'type']; |
| 821 | 821 | |
| 822 | - if(!array_keys_exist($product_data, $required_values)){ |
|
| 822 | + if (!array_keys_exist($product_data, $required_values)) { |
|
| 823 | 823 | throw new RequiredValuesMissing("Missing required values :("); |
| 824 | 824 | } |
| 825 | 825 | |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | * [getProducts] |
| 834 | 834 | * @return object |
| 835 | 835 | */ |
| 836 | - public function getProducts(){ |
|
| 836 | + public function getProducts() { |
|
| 837 | 837 | $url = "/products"; |
| 838 | 838 | |
| 839 | 839 | return $this->sendRequest('get', $url); |
@@ -847,8 +847,8 @@ discard block |
||
| 847 | 847 | * @param $product_id [Mandatory - Product ID] |
| 848 | 848 | * @return object |
| 849 | 849 | */ |
| 850 | - public function deleteProduct($product_id){ |
|
| 851 | - if(!$product_id){ |
|
| 850 | + public function deleteProduct($product_id) { |
|
| 851 | + if (!$product_id) { |
|
| 852 | 852 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
| 853 | 853 | } |
| 854 | 854 | |
@@ -866,22 +866,22 @@ discard block |
||
| 866 | 866 | * @param array $params [data to post to request url] |
| 867 | 867 | * @return object |
| 868 | 868 | */ |
| 869 | - public function sendRequest($method, $url, $params=[]) |
|
| 869 | + public function sendRequest($method, $url, $params = []) |
|
| 870 | 870 | { |
| 871 | - try{ |
|
| 872 | - if (strtolower($method) == 'get'){ |
|
| 871 | + try { |
|
| 872 | + if (strtolower($method) == 'get') { |
|
| 873 | 873 | $result = $this->client->request('GET', $url); |
| 874 | - }elseif (strtolower($method) == 'post'){ |
|
| 874 | + }elseif (strtolower($method) == 'post') { |
|
| 875 | 875 | $result = $this->client->request('POST', $url, $params); |
| 876 | - }elseif (strtolower($method) == 'put'){ |
|
| 876 | + }elseif (strtolower($method) == 'put') { |
|
| 877 | 877 | $result = $this->client->request('PUT', $url, $params); |
| 878 | - }elseif (strtolower($method) == 'delete'){ |
|
| 878 | + }elseif (strtolower($method) == 'delete') { |
|
| 879 | 879 | $result = $this->client->request('DELETE', $url); |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | return cleanResponse($result); |
| 883 | 883 | } |
| 884 | - catch( Exception $e){ |
|
| 884 | + catch (Exception $e) { |
|
| 885 | 885 | throw $e; |
| 886 | 886 | } |
| 887 | 887 | } |