@@ -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 | * [getStates Get States in a country (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 | } |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | * [resolveAccount description] |
| 112 | 112 | * @param array $client_data [description] |
| 113 | 113 | * Required fields - 'settlement_bank', 'account_number' |
| 114 | - */ |
|
| 114 | + */ |
|
| 115 | 115 | public function resolveAccount( array $client_data){ |
| 116 | 116 | // Mandatory fields |
| 117 | 117 | $required_values = ['settlement_bank', 'account_number']; |
| 118 | 118 | |
| 119 | 119 | if(!array_keys_exist($client_data, $required_values)){ |
| 120 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 120 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $url = '/resolve-account'; |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | * @param array $client_data [description] |
| 134 | 134 | * Required fields - 'first_name', 'last_name', 'email', 'phone' |
| 135 | 135 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
| 136 | - */ |
|
| 136 | + */ |
|
| 137 | 137 | public function addClient( array $client_data){ |
| 138 | 138 | // Mandatory fields |
| 139 | 139 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
| 140 | 140 | |
| 141 | 141 | if(!array_keys_exist($client_data, $required_values)){ |
| 142 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 142 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $url = '/clients'; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * [getClient Get client Details] |
| 155 | 155 | * @param string $client_id |
| 156 | 156 | * @return object |
| 157 | - */ |
|
| 157 | + */ |
|
| 158 | 158 | public function getClient($client_id = null){ |
| 159 | 159 | if(!$client_id){ |
| 160 | 160 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
@@ -170,15 +170,15 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | - * [editClient - Edit Existing Client] |
|
| 174 | - * @param string $client_id |
|
| 175 | - * @param array $client_data |
|
| 176 | - * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
| 177 | - * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
| 178 | - */ |
|
| 173 | + * [editClient - Edit Existing Client] |
|
| 174 | + * @param string $client_id |
|
| 175 | + * @param array $client_data |
|
| 176 | + * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
| 177 | + * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
| 178 | + */ |
|
| 179 | 179 | public function editClient( $client_id, array $client_data){ |
| 180 | 180 | if(!$client_id){ |
| 181 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
| 181 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | $url = "/clients/{$client_id}"; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
| 188 | 188 | |
| 189 | 189 | if(!array_keys_exist($client_data, $required_values)){ |
| 190 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 190 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | return $this->sendRequest('put', $url, ['form_params' => $client_data]); |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | - * [getInvoice ] |
|
| 275 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 276 | - * @return object |
|
| 277 | - */ |
|
| 274 | + * [getInvoice ] |
|
| 275 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 276 | + * @return object |
|
| 277 | + */ |
|
| 278 | 278 | public function getInvoice($reference_code){ |
| 279 | 279 | if(!$reference_code){ |
| 280 | 280 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -286,10 +286,10 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | - * [sendInvoice] |
|
| 290 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 291 | - * @return object |
|
| 292 | - */ |
|
| 289 | + * [sendInvoice] |
|
| 290 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 291 | + * @return object |
|
| 292 | + */ |
|
| 293 | 293 | public function sendInvoice($reference_code = null){ |
| 294 | 294 | if(!$reference_code){ |
| 295 | 295 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | - * [getInvoiceHistory] |
|
| 309 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 310 | - * @param string $start [Format - DD/MM/YYYY] |
|
| 311 | - * @param string $end [Format - DD/MM/YYYY] |
|
| 312 | - * @return object |
|
| 313 | - */ |
|
| 308 | + * [getInvoiceHistory] |
|
| 309 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 310 | + * @param string $start [Format - DD/MM/YYYY] |
|
| 311 | + * @param string $end [Format - DD/MM/YYYY] |
|
| 312 | + * @return object |
|
| 313 | + */ |
|
| 314 | 314 | public function getInvoiceHistory($period, $start = null, $end = null){ |
| 315 | 315 | if(!$period){ |
| 316 | 316 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -328,10 +328,10 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | |
| 330 | 330 | /** |
| 331 | - * [deleteInvoice] |
|
| 332 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 333 | - * @return object |
|
| 334 | - */ |
|
| 331 | + * [deleteInvoice] |
|
| 332 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 333 | + * @return object |
|
| 334 | + */ |
|
| 335 | 335 | public function deleteInvoice($reference_code){ |
| 336 | 336 | if(!$reference_code){ |
| 337 | 337 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -380,10 +380,10 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | |
| 382 | 382 | /** |
| 383 | - * [getTransfer ] |
|
| 384 | - * @param string $reference_code [Mandatory - Transfer Reference Code] |
|
| 385 | - * @return object |
|
| 386 | - */ |
|
| 383 | + * [getTransfer ] |
|
| 384 | + * @param string $reference_code [Mandatory - Transfer Reference Code] |
|
| 385 | + * @return object |
|
| 386 | + */ |
|
| 387 | 387 | public function getTransfer($reference_code){ |
| 388 | 388 | if(!$reference_code){ |
| 389 | 389 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -400,12 +400,12 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | |
| 402 | 402 | /** |
| 403 | - * [getTransferHistory] |
|
| 404 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 405 | - * @param string $start [Format - DD/MM/YYYY] |
|
| 406 | - * @param string $end [Format - DD/MM/YYYY] |
|
| 407 | - * @return object |
|
| 408 | - */ |
|
| 403 | + * [getTransferHistory] |
|
| 404 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 405 | + * @param string $start [Format - DD/MM/YYYY] |
|
| 406 | + * @param string $end [Format - DD/MM/YYYY] |
|
| 407 | + * @return object |
|
| 408 | + */ |
|
| 409 | 409 | public function getTransferHistory($period, $start = null, $end = null){ |
| 410 | 410 | if(!$period){ |
| 411 | 411 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -424,10 +424,10 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | - * [deleteTransfer] |
|
| 428 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 429 | - * @return object |
|
| 430 | - */ |
|
| 427 | + * [deleteTransfer] |
|
| 428 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 429 | + * @return object |
|
| 430 | + */ |
|
| 431 | 431 | public function deleteTransfer($reference_code){ |
| 432 | 432 | if(!$reference_code){ |
| 433 | 433 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -444,12 +444,12 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | |
| 446 | 446 | /** |
| 447 | - * [addPayment] |
|
| 448 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 449 | - * @param string $due_date [Mandatory - [Format - DD/MM/YYYY]] |
|
| 450 | - * @param string $amount [Mandatory] |
|
| 451 | - * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
| 452 | - */ |
|
| 447 | + * [addPayment] |
|
| 448 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 449 | + * @param string $due_date [Mandatory - [Format - DD/MM/YYYY]] |
|
| 450 | + * @param string $amount [Mandatory] |
|
| 451 | + * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
| 452 | + */ |
|
| 453 | 453 | public function addPayment(string $reference_code, string $due_date, string $amount, string $channel){ |
| 454 | 454 | if(!$reference_code){ |
| 455 | 455 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -488,9 +488,9 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | |
| 490 | 490 | /** |
| 491 | - * [getPayment] |
|
| 492 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 493 | - */ |
|
| 491 | + * [getPayment] |
|
| 492 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
| 493 | + */ |
|
| 494 | 494 | public function getPayment($reference_code){ |
| 495 | 495 | if(!$reference_code){ |
| 496 | 496 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | |
| 508 | 508 | /** |
| 509 | - * [getPaymentHistory] |
|
| 510 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 511 | - * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
| 512 | - * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
| 513 | - * @return object |
|
| 514 | - */ |
|
| 509 | + * [getPaymentHistory] |
|
| 510 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
| 511 | + * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
| 512 | + * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
| 513 | + * @return object |
|
| 514 | + */ |
|
| 515 | 515 | public function getPaymentHistory(string $period, string $start, string $end){ |
| 516 | 516 | if(!$period){ |
| 517 | 517 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -530,12 +530,12 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | |
| 532 | 532 | /** |
| 533 | - * [addProduct] |
|
| 534 | - * @param string $name [Mandatory - Product's name] |
|
| 535 | - * @param string $description [Mandatory - Product's description] |
|
| 536 | - * @param string $unit_cost [Mandatory - Product's unit cost] |
|
| 537 | - * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
| 538 | - */ |
|
| 533 | + * [addProduct] |
|
| 534 | + * @param string $name [Mandatory - Product's name] |
|
| 535 | + * @param string $description [Mandatory - Product's description] |
|
| 536 | + * @param string $unit_cost [Mandatory - Product's unit cost] |
|
| 537 | + * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
| 538 | + */ |
|
| 539 | 539 | public function addProduct(string $name, string $description, string $unit_cost, string $type){ |
| 540 | 540 | if(!$name){ |
| 541 | 541 | throw new IsNull("Error Processing Request - Null/Invalid name"); |
@@ -575,10 +575,10 @@ discard block |
||
| 575 | 575 | |
| 576 | 576 | |
| 577 | 577 | /** |
| 578 | - * [getProduct] |
|
| 579 | - * @param int $product_id [Mandatory - Product ID] |
|
| 580 | - * @return object |
|
| 581 | - */ |
|
| 578 | + * [getProduct] |
|
| 579 | + * @param int $product_id [Mandatory - Product ID] |
|
| 580 | + * @return object |
|
| 581 | + */ |
|
| 582 | 582 | public function getProduct($product_id){ |
| 583 | 583 | if(!$product_id){ |
| 584 | 584 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); |
@@ -594,14 +594,14 @@ discard block |
||
| 594 | 594 | |
| 595 | 595 | |
| 596 | 596 | /** |
| 597 | - * [editProduct] |
|
| 598 | - * @param string $product_id [Mandatory - Product ID] |
|
| 599 | - * @param array $product_data [description] |
|
| 600 | - * @return object |
|
| 601 | - */ |
|
| 597 | + * [editProduct] |
|
| 598 | + * @param string $product_id [Mandatory - Product ID] |
|
| 599 | + * @param array $product_data [description] |
|
| 600 | + * @return object |
|
| 601 | + */ |
|
| 602 | 602 | public function editProduct($product_id, array $product_data){ |
| 603 | 603 | if(!$product_id){ |
| 604 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
| 604 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | //Validate Type |
@@ -615,13 +615,13 @@ discard block |
||
| 615 | 615 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - $url = "/products/{$product_id}"; |
|
| 618 | + $url = "/products/{$product_id}"; |
|
| 619 | 619 | |
| 620 | - // Mandatory fields |
|
| 621 | - $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
| 620 | + // Mandatory fields |
|
| 621 | + $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
| 622 | 622 | |
| 623 | 623 | if(!array_keys_exist($product_data, $required_values)){ |
| 624 | - throw new RequiredValuesMissing("Missing required values :("); |
|
| 624 | + throw new RequiredValuesMissing("Missing required values :("); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | return $this->sendRequest('put', $url, ['form_params' => $product_data]); |
@@ -631,9 +631,9 @@ discard block |
||
| 631 | 631 | |
| 632 | 632 | |
| 633 | 633 | /** |
| 634 | - * [getProducts] |
|
| 635 | - * @return object |
|
| 636 | - */ |
|
| 634 | + * [getProducts] |
|
| 635 | + * @return object |
|
| 636 | + */ |
|
| 637 | 637 | public function getProducts(){ |
| 638 | 638 | $url = "/products"; |
| 639 | 639 | |
@@ -644,10 +644,10 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | |
| 646 | 646 | /** |
| 647 | - * [deleteProduct] |
|
| 648 | - * @param $product_id [Mandatory - Product ID] |
|
| 649 | - * @return object |
|
| 650 | - */ |
|
| 647 | + * [deleteProduct] |
|
| 648 | + * @param $product_id [Mandatory - Product ID] |
|
| 649 | + * @return object |
|
| 650 | + */ |
|
| 651 | 651 | public function deleteProduct($product_id){ |
| 652 | 652 | if(!$product_id){ |
| 653 | 653 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
@@ -661,11 +661,11 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | |
| 663 | 663 | /** |
| 664 | - * [addPayment] |
|
| 665 | - * @param string $method [Mandatory - request method <get | post | put | delete> ] |
|
| 666 | - * @param string $url [Mandatory - url to send request to] |
|
| 667 | - * @param array $params [data to post to request url] |
|
| 668 | - */ |
|
| 664 | + * [addPayment] |
|
| 665 | + * @param string $method [Mandatory - request method <get | post | put | delete> ] |
|
| 666 | + * @param string $url [Mandatory - url to send request to] |
|
| 667 | + * @param array $params [data to post to request url] |
|
| 668 | + */ |
|
| 669 | 669 | public function sendRequest($method, $url, $params=[]) |
| 670 | 670 | { |
| 671 | 671 | 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 | * [getStates Get States in a country (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 | |
@@ -112,11 +112,11 @@ discard block |
||
| 112 | 112 | * @param array $client_data [description] |
| 113 | 113 | * Required fields - 'settlement_bank', 'account_number' |
| 114 | 114 | */ |
| 115 | - public function resolveAccount( array $client_data){ |
|
| 115 | + public function resolveAccount(array $client_data) { |
|
| 116 | 116 | // Mandatory fields |
| 117 | 117 | $required_values = ['settlement_bank', 'account_number']; |
| 118 | 118 | |
| 119 | - if(!array_keys_exist($client_data, $required_values)){ |
|
| 119 | + if (!array_keys_exist($client_data, $required_values)) { |
|
| 120 | 120 | throw new RequiredValuesMissing("Missing required values :("); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | * Required fields - 'first_name', 'last_name', 'email', 'phone' |
| 135 | 135 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
| 136 | 136 | */ |
| 137 | - public function addClient( array $client_data){ |
|
| 137 | + public function addClient(array $client_data) { |
|
| 138 | 138 | // Mandatory fields |
| 139 | 139 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
| 140 | 140 | |
| 141 | - if(!array_keys_exist($client_data, $required_values)){ |
|
| 141 | + if (!array_keys_exist($client_data, $required_values)) { |
|
| 142 | 142 | throw new RequiredValuesMissing("Missing required values :("); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | * @param string $client_id |
| 156 | 156 | * @return object |
| 157 | 157 | */ |
| 158 | - public function getClient($client_id = null){ |
|
| 159 | - if(!$client_id){ |
|
| 158 | + public function getClient($client_id = null) { |
|
| 159 | + if (!$client_id) { |
|
| 160 | 160 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * Required fields - 'first_name', 'last_name', 'email', 'phone' |
| 177 | 177 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
| 178 | 178 | */ |
| 179 | - public function editClient( $client_id, array $client_data){ |
|
| 180 | - if(!$client_id){ |
|
| 179 | + public function editClient($client_id, array $client_data) { |
|
| 180 | + if (!$client_id) { |
|
| 181 | 181 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | // Mandatory fields |
| 187 | 187 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
| 188 | 188 | |
| 189 | - if(!array_keys_exist($client_data, $required_values)){ |
|
| 189 | + if (!array_keys_exist($client_data, $required_values)) { |
|
| 190 | 190 | throw new RequiredValuesMissing("Missing required values :("); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | * [deleteClient] |
| 202 | 202 | * @param string $client_id [description] |
| 203 | 203 | */ |
| 204 | - public function deleteClient($client_id = null){ |
|
| 205 | - if(!$client_id){ |
|
| 204 | + public function deleteClient($client_id = null) { |
|
| 205 | + if (!$client_id) { |
|
| 206 | 206 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param string $fee_bearer [Mandatory] |
| 226 | 226 | * @param array $items [Mandatory] |
| 227 | 227 | */ |
| 228 | - public function addInvoice($client_id, array $client_data, $due_date, $fee_bearer, array $items){ |
|
| 228 | + public function addInvoice($client_id, array $client_data, $due_date, $fee_bearer, array $items) { |
|
| 229 | 229 | // Mandatory Client fields |
| 230 | 230 | $required_client_values = ['first_name', 'last_name', 'email', 'phone']; |
| 231 | 231 | |
@@ -235,21 +235,21 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | |
| 237 | 237 | // Either the client Id is supplied or a new client data is provided |
| 238 | - if(!$client_id && !array_keys_exist($client_data, $required_client_values)){ |
|
| 238 | + if (!$client_id && !array_keys_exist($client_data, $required_client_values)) { |
|
| 239 | 239 | throw new RequiredValuesMissing("Missing required values :( - Provide client_id or client_data"); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if(!$due_date){ |
|
| 242 | + if (!$due_date) { |
|
| 243 | 243 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Due Date"); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if(!$fee_bearer){ |
|
| 246 | + if (!$fee_bearer) { |
|
| 247 | 247 | throw new IsNull("Error Processing Request - Null Fee Bearer"); |
| 248 | 248 | }elseif (!in_array($fee_bearer, $valid_fee_bearers)) { |
| 249 | 249 | throw new InvalidFeeBearer("Invalid Fee Bearer - Use either 'account' or 'client'"); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if(!is_array($items)){ |
|
| 252 | + if (!is_array($items)) { |
|
| 253 | 253 | throw new IsInvalid("Error Processing Request - Invalid Items"); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -275,8 +275,8 @@ discard block |
||
| 275 | 275 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 276 | 276 | * @return object |
| 277 | 277 | */ |
| 278 | - public function getInvoice($reference_code){ |
|
| 279 | - if(!$reference_code){ |
|
| 278 | + public function getInvoice($reference_code) { |
|
| 279 | + if (!$reference_code) { |
|
| 280 | 280 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 281 | 281 | } |
| 282 | 282 | |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 291 | 291 | * @return object |
| 292 | 292 | */ |
| 293 | - public function sendInvoice($reference_code = null){ |
|
| 294 | - if(!$reference_code){ |
|
| 293 | + public function sendInvoice($reference_code = null) { |
|
| 294 | + if (!$reference_code) { |
|
| 295 | 295 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 296 | 296 | } |
| 297 | 297 | |
@@ -311,8 +311,8 @@ discard block |
||
| 311 | 311 | * @param string $end [Format - DD/MM/YYYY] |
| 312 | 312 | * @return object |
| 313 | 313 | */ |
| 314 | - public function getInvoiceHistory($period, $start = null, $end = null){ |
|
| 315 | - if(!$period){ |
|
| 314 | + public function getInvoiceHistory($period, $start = null, $end = null) { |
|
| 315 | + if (!$period) { |
|
| 316 | 316 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
| 317 | 317 | } |
| 318 | 318 | |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 333 | 333 | * @return object |
| 334 | 334 | */ |
| 335 | - public function deleteInvoice($reference_code){ |
|
| 336 | - if(!$reference_code){ |
|
| 335 | + public function deleteInvoice($reference_code) { |
|
| 336 | + if (!$reference_code) { |
|
| 337 | 337 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 338 | 338 | } |
| 339 | 339 | |
@@ -353,15 +353,15 @@ discard block |
||
| 353 | 353 | * Optional - 'address', 'company_name', 'type', |
| 354 | 354 | * @param string $amount [Mandatory] |
| 355 | 355 | */ |
| 356 | - public function addTransfer(array $client_data, string $amount){ |
|
| 356 | + public function addTransfer(array $client_data, string $amount) { |
|
| 357 | 357 | // Mandatory Client fields |
| 358 | 358 | $required_client_values = ['first_name', 'last_name', 'email', 'phone', 'settlement_bank', 'account_number']; |
| 359 | 359 | |
| 360 | - if(!array_keys_exist($client_data, $required_client_values)){ |
|
| 360 | + if (!array_keys_exist($client_data, $required_client_values)) { |
|
| 361 | 361 | throw new RequiredValuesMissing("Missing required values :( - Provide client_data"); |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if(!$amount){ |
|
| 364 | + if (!$amount) { |
|
| 365 | 365 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount"); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -384,8 +384,8 @@ discard block |
||
| 384 | 384 | * @param string $reference_code [Mandatory - Transfer Reference Code] |
| 385 | 385 | * @return object |
| 386 | 386 | */ |
| 387 | - public function getTransfer($reference_code){ |
|
| 388 | - if(!$reference_code){ |
|
| 387 | + public function getTransfer($reference_code) { |
|
| 388 | + if (!$reference_code) { |
|
| 389 | 389 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 390 | 390 | } |
| 391 | 391 | |
@@ -406,8 +406,8 @@ discard block |
||
| 406 | 406 | * @param string $end [Format - DD/MM/YYYY] |
| 407 | 407 | * @return object |
| 408 | 408 | */ |
| 409 | - public function getTransferHistory($period, $start = null, $end = null){ |
|
| 410 | - if(!$period){ |
|
| 409 | + public function getTransferHistory($period, $start = null, $end = null) { |
|
| 410 | + if (!$period) { |
|
| 411 | 411 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
| 412 | 412 | } |
| 413 | 413 | |
@@ -428,8 +428,8 @@ discard block |
||
| 428 | 428 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 429 | 429 | * @return object |
| 430 | 430 | */ |
| 431 | - public function deleteTransfer($reference_code){ |
|
| 432 | - if(!$reference_code){ |
|
| 431 | + public function deleteTransfer($reference_code) { |
|
| 432 | + if (!$reference_code) { |
|
| 433 | 433 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 434 | 434 | } |
| 435 | 435 | |
@@ -450,22 +450,22 @@ discard block |
||
| 450 | 450 | * @param string $amount [Mandatory] |
| 451 | 451 | * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
| 452 | 452 | */ |
| 453 | - public function addPayment(string $reference_code, string $due_date, string $amount, string $channel){ |
|
| 454 | - if(!$reference_code){ |
|
| 453 | + public function addPayment(string $reference_code, string $due_date, string $amount, string $channel) { |
|
| 454 | + if (!$reference_code) { |
|
| 455 | 455 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if(!$due_date){ |
|
| 458 | + if (!$due_date) { |
|
| 459 | 459 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid date"); |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - if(!$amount){ |
|
| 462 | + if (!$amount) { |
|
| 463 | 463 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount"); |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | $valid_channels = ["Cash", "BankTransfer", "POS", "Cheque"]; |
| 467 | 467 | |
| 468 | - if(!$channel){ |
|
| 468 | + if (!$channel) { |
|
| 469 | 469 | throw new IsNull("Error Processing Request - Null/Invalid amount"); |
| 470 | 470 | }elseif (!in_array(ucfirst($channel), $valid_channels)) { |
| 471 | 471 | throw new IsInvalid("Invalid Channel - Cash, BankTransfer, POS or Cheque"); |
@@ -491,8 +491,8 @@ discard block |
||
| 491 | 491 | * [getPayment] |
| 492 | 492 | * @param string $reference_code [Mandatory - Invoice Reference Code] |
| 493 | 493 | */ |
| 494 | - public function getPayment($reference_code){ |
|
| 495 | - if(!$reference_code){ |
|
| 494 | + public function getPayment($reference_code) { |
|
| 495 | + if (!$reference_code) { |
|
| 496 | 496 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 497 | 497 | } |
| 498 | 498 | |
@@ -512,8 +512,8 @@ discard block |
||
| 512 | 512 | * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
| 513 | 513 | * @return object |
| 514 | 514 | */ |
| 515 | - public function getPaymentHistory(string $period, string $start, string $end){ |
|
| 516 | - if(!$period){ |
|
| 515 | + public function getPaymentHistory(string $period, string $start, string $end) { |
|
| 516 | + if (!$period) { |
|
| 517 | 517 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
| 518 | 518 | } |
| 519 | 519 | |
@@ -536,23 +536,23 @@ discard block |
||
| 536 | 536 | * @param string $unit_cost [Mandatory - Product's unit cost] |
| 537 | 537 | * @param string $type [Mandatory - Product type 'product' or 'service'] |
| 538 | 538 | */ |
| 539 | - public function addProduct(string $name, string $description, string $unit_cost, string $type){ |
|
| 540 | - if(!$name){ |
|
| 539 | + public function addProduct(string $name, string $description, string $unit_cost, string $type) { |
|
| 540 | + if (!$name) { |
|
| 541 | 541 | throw new IsNull("Error Processing Request - Null/Invalid name"); |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - if(!$description){ |
|
| 544 | + if (!$description) { |
|
| 545 | 545 | throw new IsNull("Error Processing Request - Null/Invalid description"); |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - if(!$unit_cost){ |
|
| 548 | + if (!$unit_cost) { |
|
| 549 | 549 | throw new IsNull("Error Processing Request - Null/Invalid unit_cost"); |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | //Validate Product Type |
| 553 | 553 | $valid_product_type = ["product", "service"]; |
| 554 | 554 | |
| 555 | - if(!$type){ |
|
| 555 | + if (!$type) { |
|
| 556 | 556 | throw new IsNull("Error Processing Request - Null/Invalid type"); |
| 557 | 557 | }elseif (!in_array(strtolower($type), $valid_product_type)) { |
| 558 | 558 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
@@ -579,8 +579,8 @@ discard block |
||
| 579 | 579 | * @param int $product_id [Mandatory - Product ID] |
| 580 | 580 | * @return object |
| 581 | 581 | */ |
| 582 | - public function getProduct($product_id){ |
|
| 583 | - if(!$product_id){ |
|
| 582 | + public function getProduct($product_id) { |
|
| 583 | + if (!$product_id) { |
|
| 584 | 584 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); |
| 585 | 585 | } |
| 586 | 586 | |
@@ -599,8 +599,8 @@ discard block |
||
| 599 | 599 | * @param array $product_data [description] |
| 600 | 600 | * @return object |
| 601 | 601 | */ |
| 602 | - public function editProduct($product_id, array $product_data){ |
|
| 603 | - if(!$product_id){ |
|
| 602 | + public function editProduct($product_id, array $product_data) { |
|
| 603 | + if (!$product_id) { |
|
| 604 | 604 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
| 605 | 605 | } |
| 606 | 606 | |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | |
| 610 | 610 | $valid_product_type = ["product", "service"]; |
| 611 | 611 | |
| 612 | - if(!$product_type){ |
|
| 612 | + if (!$product_type) { |
|
| 613 | 613 | throw new IsNull("Error Processing Request - Null/Invalid type"); |
| 614 | 614 | }elseif (!in_array($product_type, $valid_product_type)) { |
| 615 | 615 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | // Mandatory fields |
| 621 | 621 | $required_values = ['name', 'description', 'unit_cost', 'type']; |
| 622 | 622 | |
| 623 | - if(!array_keys_exist($product_data, $required_values)){ |
|
| 623 | + if (!array_keys_exist($product_data, $required_values)) { |
|
| 624 | 624 | throw new RequiredValuesMissing("Missing required values :("); |
| 625 | 625 | } |
| 626 | 626 | |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | * [getProducts] |
| 635 | 635 | * @return object |
| 636 | 636 | */ |
| 637 | - public function getProducts(){ |
|
| 637 | + public function getProducts() { |
|
| 638 | 638 | $url = "/products"; |
| 639 | 639 | |
| 640 | 640 | return $this->sendRequest('get', $url); |
@@ -648,8 +648,8 @@ discard block |
||
| 648 | 648 | * @param $product_id [Mandatory - Product ID] |
| 649 | 649 | * @return object |
| 650 | 650 | */ |
| 651 | - public function deleteProduct($product_id){ |
|
| 652 | - if(!$product_id){ |
|
| 651 | + public function deleteProduct($product_id) { |
|
| 652 | + if (!$product_id) { |
|
| 653 | 653 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
| 654 | 654 | } |
| 655 | 655 | |
@@ -666,22 +666,22 @@ discard block |
||
| 666 | 666 | * @param string $url [Mandatory - url to send request to] |
| 667 | 667 | * @param array $params [data to post to request url] |
| 668 | 668 | */ |
| 669 | - public function sendRequest($method, $url, $params=[]) |
|
| 669 | + public function sendRequest($method, $url, $params = []) |
|
| 670 | 670 | { |
| 671 | - try{ |
|
| 672 | - if (strtolower($method) == 'get'){ |
|
| 671 | + try { |
|
| 672 | + if (strtolower($method) == 'get') { |
|
| 673 | 673 | $result = $this->client->request('GET', $url); |
| 674 | - }elseif (strtolower($method) == 'post'){ |
|
| 674 | + }elseif (strtolower($method) == 'post') { |
|
| 675 | 675 | $result = $this->client->request('POST', $url, $params); |
| 676 | - }elseif (strtolower($method) == 'put'){ |
|
| 676 | + }elseif (strtolower($method) == 'put') { |
|
| 677 | 677 | $result = $this->client->request('PUT', $url, $params); |
| 678 | - }elseif (strtolower($method) == 'delete'){ |
|
| 678 | + }elseif (strtolower($method) == 'delete') { |
|
| 679 | 679 | $result = $this->client->request('DELETE', $url); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | return cleanResponse($result); |
| 683 | 683 | } |
| 684 | - catch( Exception $e){ |
|
| 684 | + catch (Exception $e) { |
|
| 685 | 685 | throw $e; |
| 686 | 686 | } |
| 687 | 687 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | use \Exception as phpException; |
| 25 | 25 | |
| 26 | -if (! function_exists('array_get')) |
|
| 26 | +if (!function_exists('array_get')) |
|
| 27 | 27 | { |
| 28 | 28 | /* |
| 29 | 29 | * |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | if (!is_array($data)) { |
| 38 | 38 | return $default; |
| 39 | 39 | } |
| 40 | - return isset($data[$key]) ? $data[$key]: $default; |
|
| 40 | + return isset($data[$key]) ? $data[$key] : $default; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -if(!function_exists('array_keys_exist')){ |
|
| 44 | +if (!function_exists('array_keys_exist')) { |
|
| 45 | 45 | /** |
| 46 | 46 | * Checks if multiple keys exist in an array |
| 47 | 47 | * |
@@ -50,23 +50,23 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return bool |
| 52 | 52 | */ |
| 53 | - function array_keys_exist( array $array, $keys ) { |
|
| 53 | + function array_keys_exist(array $array, $keys) { |
|
| 54 | 54 | $count = 0; |
| 55 | - if ( ! is_array( $keys ) ) { |
|
| 55 | + if (!is_array($keys)) { |
|
| 56 | 56 | $keys = func_get_args(); |
| 57 | - array_shift( $keys ); |
|
| 57 | + array_shift($keys); |
|
| 58 | 58 | } |
| 59 | - foreach ( $keys as $key ) { |
|
| 60 | - if ( array_key_exists( $key, $array ) ) { |
|
| 61 | - $count ++; |
|
| 59 | + foreach ($keys as $key) { |
|
| 60 | + if (array_key_exists($key, $array)) { |
|
| 61 | + $count++; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - return count( $keys ) === $count; |
|
| 65 | + return count($keys) === $count; |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | -function checkHistory($period, $start, $end){ |
|
| 69 | +function checkHistory($period, $start, $end) { |
|
| 70 | 70 | //Validate Period |
| 71 | 71 | $valid_period_options = ["today", "week", "month", "30", "90", "year", "custom"]; |
| 72 | 72 | |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | 'period' => $period |
| 79 | 79 | ]; |
| 80 | 80 | |
| 81 | - if ($period == 'custom'){ |
|
| 82 | - if (!$start || !$end){ |
|
| 81 | + if ($period == 'custom') { |
|
| 82 | + if (!$start || !$end) { |
|
| 83 | 83 | throw new IsNull("Invalid custom Start or End date"); |
| 84 | 84 | } |
| 85 | 85 | $post_data['start'] = $start; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | -function cleanResponse($response){ |
|
| 90 | +function cleanResponse($response) { |
|
| 91 | 91 | $result = $response->getBody(); |
| 92 | 92 | return $result; |
| 93 | 93 | } |
| 94 | 94 | \ No newline at end of file |