| @@ -29,7 +29,7 @@ discard block | ||
| 29 | 29 | |
| 30 | 30 | /** | 
| 31 | 31 | * @var $private_key | 
| 32 | - */ | |
| 32 | + */ | |
| 33 | 33 | protected $private_key; | 
| 34 | 34 | |
| 35 | 35 | |
| @@ -37,14 +37,14 @@ discard block | ||
| 37 | 37 | * | 
| 38 | 38 | * @var $base_uri | 
| 39 | 39 | * | 
| 40 | - */ | |
| 40 | + */ | |
| 41 | 41 | protected $base_uri = 'https://api.demo.payant.ng'; | 
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** | 
| 45 | 45 | * @var $client | 
| 46 | 46 | * | 
| 47 | - */ | |
| 47 | + */ | |
| 48 | 48 | protected $client; | 
| 49 | 49 | |
| 50 | 50 | |
| @@ -59,8 +59,8 @@ discard block | ||
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | 61 | /** | 
| 62 | - * Get Base Url from Payant config file | |
| 63 | - */ | |
| 62 | + * Get Base Url from Payant config file | |
| 63 | + */ | |
| 64 | 64 | public function setBaseUrl() | 
| 65 | 65 |      { | 
| 66 | 66 |          if(Config::get('payant.mode') == 'LIVE') | 
| @@ -83,7 +83,7 @@ discard block | ||
| 83 | 83 | */ | 
| 84 | 84 | private function setRequestOptions() | 
| 85 | 85 |      {        | 
| 86 | - $authorization_string = 'Bearer '. $this->private_key; | |
| 86 | + $authorization_string = 'Bearer '. $this->private_key; | |
| 87 | 87 | |
| 88 | 88 | //Set up Guzzle | 
| 89 | 89 | $this->client = new Client( [ | 
| @@ -101,7 +101,7 @@ discard block | ||
| 101 | 101 | /** | 
| 102 | 102 | * [getStates Get States in a country (Nigeria)] | 
| 103 | 103 | * @return object [list of banks and their respective bank_ids] | 
| 104 | - */ | |
| 104 | + */ | |
| 105 | 105 |      public function getBanks(){ | 
| 106 | 106 |          return $this->sendRequest('get', '/banks'); | 
| 107 | 107 | } | 
| @@ -112,13 +112,13 @@ discard block | ||
| 112 | 112 | * [resolveAccount description] | 
| 113 | 113 | * @param array $client_data [description] | 
| 114 | 114 | * Required fields - 'settlement_bank', 'account_number' | 
| 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'; | 
| @@ -134,13 +134,13 @@ discard block | ||
| 134 | 134 | * @param array $client_data [description] | 
| 135 | 135 | * Required fields - 'first_name', 'last_name', 'email', 'phone' | 
| 136 | 136 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' | 
| 137 | - */ | |
| 137 | + */ | |
| 138 | 138 |      public function addClient( array $client_data){ | 
| 139 | 139 | // Mandatory fields | 
| 140 | 140 | $required_values = ['first_name', 'last_name', 'email', 'phone']; | 
| 141 | 141 | |
| 142 | 142 |          if(!array_keys_exist($client_data, $required_values)){ | 
| 143 | -         throw new RequiredValuesMissing("Missing required values :("); | |
| 143 | +            throw new RequiredValuesMissing("Missing required values :("); | |
| 144 | 144 | } | 
| 145 | 145 | |
| 146 | 146 | $url = '/clients'; | 
| @@ -155,7 +155,7 @@ discard block | ||
| 155 | 155 | * [getClient Get client Details] | 
| 156 | 156 | * @param string $client_id | 
| 157 | 157 | * @return object | 
| 158 | - */ | |
| 158 | + */ | |
| 159 | 159 |      public function getClient($client_id = null){ | 
| 160 | 160 |          if(!$client_id){ | 
| 161 | 161 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); | 
| @@ -171,15 +171,15 @@ discard block | ||
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | /** | 
| 174 | - * [editClient - Edit Existing Client] | |
| 175 | - * @param string $client_id | |
| 176 | - * @param array $client_data | |
| 177 | - * Required fields - 'first_name', 'last_name', 'email', 'phone' | |
| 178 | - * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' | |
| 179 | - */ | |
| 174 | + * [editClient - Edit Existing Client] | |
| 175 | + * @param string $client_id | |
| 176 | + * @param array $client_data | |
| 177 | + * Required fields - 'first_name', 'last_name', 'email', 'phone' | |
| 178 | + * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' | |
| 179 | + */ | |
| 180 | 180 |      public function editClient( $client_id, array $client_data){ | 
| 181 | 181 |          if(!$client_id){ | 
| 182 | -           throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); | |
| 182 | +            throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); | |
| 183 | 183 | } | 
| 184 | 184 | |
| 185 | 185 |          $url = "/clients/{$client_id}"; | 
| @@ -188,7 +188,7 @@ discard block | ||
| 188 | 188 | $required_values = ['first_name', 'last_name', 'email', 'phone']; | 
| 189 | 189 | |
| 190 | 190 |          if(!array_keys_exist($client_data, $required_values)){ | 
| 191 | -             throw new RequiredValuesMissing("Missing required values :("); | |
| 191 | +                throw new RequiredValuesMissing("Missing required values :("); | |
| 192 | 192 | } | 
| 193 | 193 | |
| 194 | 194 |          return $this->sendRequest('put', $url, ['form_params' => $client_data]); | 
| @@ -272,10 +272,10 @@ discard block | ||
| 272 | 272 | |
| 273 | 273 | |
| 274 | 274 | /** | 
| 275 | - * [getInvoice ] | |
| 276 | - * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 277 | - * @return object | |
| 278 | - */ | |
| 275 | + * [getInvoice ] | |
| 276 | + * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 277 | + * @return object | |
| 278 | + */ | |
| 279 | 279 |      public function getInvoice($reference_code){ | 
| 280 | 280 |          if(!$reference_code){ | 
| 281 | 281 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| @@ -287,10 +287,10 @@ discard block | ||
| 287 | 287 | } | 
| 288 | 288 | |
| 289 | 289 | /** | 
| 290 | - * [sendInvoice] | |
| 291 | - * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 292 | - * @return object | |
| 293 | - */ | |
| 290 | + * [sendInvoice] | |
| 291 | + * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 292 | + * @return object | |
| 293 | + */ | |
| 294 | 294 |      public function sendInvoice($reference_code = null){ | 
| 295 | 295 |          if(!$reference_code){ | 
| 296 | 296 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| @@ -306,12 +306,12 @@ discard block | ||
| 306 | 306 | |
| 307 | 307 | |
| 308 | 308 | /** | 
| 309 | - * [getInvoiceHistory] | |
| 310 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] | |
| 311 | - * @param string $start [Format - DD/MM/YYYY] | |
| 312 | - * @param string $end [Format - DD/MM/YYYY] | |
| 313 | - * @return object | |
| 314 | - */ | |
| 309 | + * [getInvoiceHistory] | |
| 310 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] | |
| 311 | + * @param string $start [Format - DD/MM/YYYY] | |
| 312 | + * @param string $end [Format - DD/MM/YYYY] | |
| 313 | + * @return object | |
| 314 | + */ | |
| 315 | 315 |      public function getInvoiceHistory($period, $start = null, $end = null){ | 
| 316 | 316 |          if(!$period){ | 
| 317 | 317 |              throw new RequiredValueMissing("Error Processing Request - period Missing"); | 
| @@ -346,10 +346,10 @@ discard block | ||
| 346 | 346 | |
| 347 | 347 | |
| 348 | 348 | /** | 
| 349 | - * [deleteInvoice] | |
| 350 | - * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 351 | - * @return object | |
| 352 | - */ | |
| 349 | + * [deleteInvoice] | |
| 350 | + * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 351 | + * @return object | |
| 352 | + */ | |
| 353 | 353 |      public function deleteInvoice($reference_code){ | 
| 354 | 354 |          if(!$reference_code){ | 
| 355 | 355 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| @@ -398,10 +398,10 @@ discard block | ||
| 398 | 398 | |
| 399 | 399 | |
| 400 | 400 | /** | 
| 401 | - * [getTransfer ] | |
| 402 | - * @param string $reference_code [Mandatory - Transfer Reference Code] | |
| 403 | - * @return object | |
| 404 | - */ | |
| 401 | + * [getTransfer ] | |
| 402 | + * @param string $reference_code [Mandatory - Transfer Reference Code] | |
| 403 | + * @return object | |
| 404 | + */ | |
| 405 | 405 |      public function getTransfer($reference_code){ | 
| 406 | 406 |          if(!$reference_code){ | 
| 407 | 407 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| @@ -418,12 +418,12 @@ discard block | ||
| 418 | 418 | |
| 419 | 419 | |
| 420 | 420 | /** | 
| 421 | - * [getTransferHistory] | |
| 422 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] | |
| 423 | - * @param string $start [Format - DD/MM/YYYY] | |
| 424 | - * @param string $end [Format - DD/MM/YYYY] | |
| 425 | - * @return object | |
| 426 | - */ | |
| 421 | + * [getTransferHistory] | |
| 422 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] | |
| 423 | + * @param string $start [Format - DD/MM/YYYY] | |
| 424 | + * @param string $end [Format - DD/MM/YYYY] | |
| 425 | + * @return object | |
| 426 | + */ | |
| 427 | 427 |      public function getTransferHistory($period, $start = null, $end = null){ | 
| 428 | 428 |          if(!$period){ | 
| 429 | 429 |              throw new RequiredValueMissing("Error Processing Request - period Missing"); | 
| @@ -458,10 +458,10 @@ discard block | ||
| 458 | 458 | |
| 459 | 459 | |
| 460 | 460 | /** | 
| 461 | - * [deleteTransfer] | |
| 462 | - * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 463 | - * @return object | |
| 464 | - */ | |
| 461 | + * [deleteTransfer] | |
| 462 | + * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 463 | + * @return object | |
| 464 | + */ | |
| 465 | 465 |      public function deleteTransfer($reference_code){ | 
| 466 | 466 |          if(!$reference_code){ | 
| 467 | 467 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| @@ -478,12 +478,12 @@ discard block | ||
| 478 | 478 | |
| 479 | 479 | |
| 480 | 480 | /** | 
| 481 | - * [addPayment] | |
| 482 | - * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 483 | - * @param string $date [Mandatory - [Format - DD/MM/YYYY]] | |
| 484 | - * @param string $amount [Mandatory] | |
| 485 | - * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] | |
| 486 | - */ | |
| 481 | + * [addPayment] | |
| 482 | + * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 483 | + * @param string $date [Mandatory - [Format - DD/MM/YYYY]] | |
| 484 | + * @param string $amount [Mandatory] | |
| 485 | + * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] | |
| 486 | + */ | |
| 487 | 487 |      public function addPayment(string $reference_code, string $date, string $amount, string $channel){ | 
| 488 | 488 |          if(!$reference_code){ | 
| 489 | 489 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| @@ -522,9 +522,9 @@ discard block | ||
| 522 | 522 | |
| 523 | 523 | |
| 524 | 524 | /** | 
| 525 | - * [getPayment] | |
| 526 | - * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 527 | - */ | |
| 525 | + * [getPayment] | |
| 526 | + * @param string $reference_code [Mandatory - Invoice Reference Code] | |
| 527 | + */ | |
| 528 | 528 |      public function getPayment($reference_code){ | 
| 529 | 529 |          if(!$reference_code){ | 
| 530 | 530 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| @@ -540,12 +540,12 @@ discard block | ||
| 540 | 540 | |
| 541 | 541 | |
| 542 | 542 | /** | 
| 543 | - * [getPaymentHistory] | |
| 544 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] | |
| 545 | - * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] | |
| 546 | - * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] | |
| 547 | - * @return object | |
| 548 | - */ | |
| 543 | + * [getPaymentHistory] | |
| 544 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] | |
| 545 | + * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] | |
| 546 | + * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] | |
| 547 | + * @return object | |
| 548 | + */ | |
| 549 | 549 |      public function getPaymentHistory(string $period, string $start, string $end){ | 
| 550 | 550 |          if(!$period){ | 
| 551 | 551 |              throw new RequiredValueMissing("Error Processing Request - period Missing"); | 
| @@ -580,12 +580,12 @@ discard block | ||
| 580 | 580 | |
| 581 | 581 | |
| 582 | 582 | /** | 
| 583 | - * [addProduct] | |
| 584 | - * @param string $name [Mandatory - Product's name] | |
| 585 | - * @param string $description [Mandatory - Product's description] | |
| 586 | - * @param string $unit_cost [Mandatory - Product's unit cost] | |
| 587 | - * @param string $type [Mandatory - Product type 'product' or 'service'] | |
| 588 | - */ | |
| 583 | + * [addProduct] | |
| 584 | + * @param string $name [Mandatory - Product's name] | |
| 585 | + * @param string $description [Mandatory - Product's description] | |
| 586 | + * @param string $unit_cost [Mandatory - Product's unit cost] | |
| 587 | + * @param string $type [Mandatory - Product type 'product' or 'service'] | |
| 588 | + */ | |
| 589 | 589 |      public function addProduct(string $name, string $description, string $unit_cost, string $type){ | 
| 590 | 590 |          if(!$name){ | 
| 591 | 591 |              throw new IsNull("Error Processing Request - Null/Invalid name"); | 
| @@ -625,10 +625,10 @@ discard block | ||
| 625 | 625 | |
| 626 | 626 | |
| 627 | 627 | /** | 
| 628 | - * [getProduct] | |
| 629 | - * @param int $product_id [Mandatory - Product ID] | |
| 630 | - * @return object | |
| 631 | - */ | |
| 628 | + * [getProduct] | |
| 629 | + * @param int $product_id [Mandatory - Product ID] | |
| 630 | + * @return object | |
| 631 | + */ | |
| 632 | 632 |      public function getProduct($product_id){ | 
| 633 | 633 |          if(!$product_id){ | 
| 634 | 634 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); | 
| @@ -644,14 +644,14 @@ discard block | ||
| 644 | 644 | |
| 645 | 645 | |
| 646 | 646 | /** | 
| 647 | - * [editProduct] | |
| 648 | - * @param string $product_id [Mandatory - Product ID] | |
| 649 | - * @param array $product_data [description] | |
| 650 | - * @return object | |
| 651 | - */ | |
| 647 | + * [editProduct] | |
| 648 | + * @param string $product_id [Mandatory - Product ID] | |
| 649 | + * @param array $product_data [description] | |
| 650 | + * @return object | |
| 651 | + */ | |
| 652 | 652 |      public function editProduct($product_id, array $product_data){ | 
| 653 | 653 |          if(!$product_id){ | 
| 654 | -               throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); | |
| 654 | +                throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); | |
| 655 | 655 | } | 
| 656 | 656 | |
| 657 | 657 | //Validate Type | 
| @@ -665,13 +665,13 @@ discard block | ||
| 665 | 665 |              throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); | 
| 666 | 666 | } | 
| 667 | 667 | |
| 668 | -       $url = "/products/{$product_id}"; | |
| 668 | +        $url = "/products/{$product_id}"; | |
| 669 | 669 | |
| 670 | - // Mandatory fields | |
| 671 | - $required_values = ['name', 'description', 'unit_cost', 'type']; | |
| 670 | + // Mandatory fields | |
| 671 | + $required_values = ['name', 'description', 'unit_cost', 'type']; | |
| 672 | 672 | |
| 673 | 673 |          if(!array_keys_exist($client_data, $required_values)){ | 
| 674 | -             throw new RequiredValuesMissing("Missing required values :("); | |
| 674 | +                throw new RequiredValuesMissing("Missing required values :("); | |
| 675 | 675 | } | 
| 676 | 676 | |
| 677 | 677 |          return $this->sendRequest('put', $url, ['form_params' => $post_data]); | 
| @@ -681,9 +681,9 @@ discard block | ||
| 681 | 681 | |
| 682 | 682 | |
| 683 | 683 | /** | 
| 684 | - * [getProducts] | |
| 685 | - * @return object | |
| 686 | - */ | |
| 684 | + * [getProducts] | |
| 685 | + * @return object | |
| 686 | + */ | |
| 687 | 687 |      public function getProducts(){ | 
| 688 | 688 | $url = "/products"; | 
| 689 | 689 | |
| @@ -694,10 +694,10 @@ discard block | ||
| 694 | 694 | |
| 695 | 695 | |
| 696 | 696 | /** | 
| 697 | - * [deleteProduct] | |
| 698 | - * @param $product_id [Mandatory - Product ID] | |
| 699 | - * @return object | |
| 700 | - */ | |
| 697 | + * [deleteProduct] | |
| 698 | + * @param $product_id [Mandatory - Product ID] | |
| 699 | + * @return object | |
| 700 | + */ | |
| 701 | 701 |      public function deleteProduct($product_id){ | 
| 702 | 702 |          if(!$product_id){ | 
| 703 | 703 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); | 
| @@ -711,11 +711,11 @@ discard block | ||
| 711 | 711 | |
| 712 | 712 | |
| 713 | 713 | /** | 
| 714 | - * [addPayment] | |
| 715 | - * @param string $method [Mandatory - request method <get | post | put | delete> ] | |
| 716 | - * @param string $url [Mandatory - url to send request to] | |
| 717 | - * @param array $params [data to post to request url] | |
| 718 | - */ | |
| 714 | + * [addPayment] | |
| 715 | + * @param string $method [Mandatory - request method <get | post | put | delete> ] | |
| 716 | + * @param string $url [Mandatory - url to send request to] | |
| 717 | + * @param array $params [data to post to request url] | |
| 718 | + */ | |
| 719 | 719 | public function sendRequest($method, $url, $params=[]) | 
| 720 | 720 |      { | 
| 721 | 721 |          try{ | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | */ | 
| 64 | 64 | public function setBaseUrl() | 
| 65 | 65 |      { | 
| 66 | -        if(Config::get('payant.mode') == 'LIVE') | |
| 66 | +        if (Config::get('payant.mode') == 'LIVE') | |
| 67 | 67 |          { | 
| 68 | 68 | $this->base_uri = "https://api.payant.ng"; | 
| 69 | 69 | } | 
| @@ -83,10 +83,10 @@ discard block | ||
| 83 | 83 | */ | 
| 84 | 84 | private function setRequestOptions() | 
| 85 | 85 |      {        | 
| 86 | - $authorization_string = 'Bearer '. $this->private_key; | |
| 86 | + $authorization_string = 'Bearer '.$this->private_key; | |
| 87 | 87 | |
| 88 | 88 | //Set up Guzzle | 
| 89 | - $this->client = new Client( [ | |
| 89 | + $this->client = new Client([ | |
| 90 | 90 | 'base_uri' => $this->base_uri, | 
| 91 | 91 | 'protocols' => ['https'], | 
| 92 | 92 | 'headers' => [ | 
| @@ -102,7 +102,7 @@ discard block | ||
| 102 | 102 | * [getStates Get States in a country (Nigeria)] | 
| 103 | 103 | * @return object [list of banks and their respective bank_ids] | 
| 104 | 104 | */ | 
| 105 | -    public function getBanks(){ | |
| 105 | +    public function getBanks() { | |
| 106 | 106 |          return $this->sendRequest('get', '/banks'); | 
| 107 | 107 | } | 
| 108 | 108 | |
| @@ -113,11 +113,11 @@ discard block | ||
| 113 | 113 | * @param array $client_data [description] | 
| 114 | 114 | * Required fields - 'settlement_bank', 'account_number' | 
| 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 | |
| @@ -135,11 +135,11 @@ 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 | */ | 
| 138 | -    public function addClient( array $client_data){ | |
| 138 | +    public function addClient(array $client_data) { | |
| 139 | 139 | // Mandatory fields | 
| 140 | 140 | $required_values = ['first_name', 'last_name', 'email', 'phone']; | 
| 141 | 141 | |
| 142 | -        if(!array_keys_exist($client_data, $required_values)){ | |
| 142 | +        if (!array_keys_exist($client_data, $required_values)) { | |
| 143 | 143 |           throw new RequiredValuesMissing("Missing required values :("); | 
| 144 | 144 | } | 
| 145 | 145 | |
| @@ -156,8 +156,8 @@ discard block | ||
| 156 | 156 | * @param string $client_id | 
| 157 | 157 | * @return object | 
| 158 | 158 | */ | 
| 159 | -    public function getClient($client_id = null){ | |
| 160 | -        if(!$client_id){ | |
| 159 | +    public function getClient($client_id = null) { | |
| 160 | +        if (!$client_id) { | |
| 161 | 161 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); | 
| 162 | 162 | } | 
| 163 | 163 | |
| @@ -177,8 +177,8 @@ discard block | ||
| 177 | 177 | * Required fields - 'first_name', 'last_name', 'email', 'phone' | 
| 178 | 178 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' | 
| 179 | 179 | */ | 
| 180 | -    public function editClient( $client_id, array $client_data){ | |
| 181 | -        if(!$client_id){ | |
| 180 | +    public function editClient($client_id, array $client_data) { | |
| 181 | +        if (!$client_id) { | |
| 182 | 182 |             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); | 
| 183 | 183 | } | 
| 184 | 184 | |
| @@ -187,7 +187,7 @@ discard block | ||
| 187 | 187 | // Mandatory fields | 
| 188 | 188 | $required_values = ['first_name', 'last_name', 'email', 'phone']; | 
| 189 | 189 | |
| 190 | -        if(!array_keys_exist($client_data, $required_values)){ | |
| 190 | +        if (!array_keys_exist($client_data, $required_values)) { | |
| 191 | 191 |               throw new RequiredValuesMissing("Missing required values :("); | 
| 192 | 192 | } | 
| 193 | 193 | |
| @@ -202,8 +202,8 @@ discard block | ||
| 202 | 202 | * [deleteClient] | 
| 203 | 203 | * @param string $client_id [description] | 
| 204 | 204 | */ | 
| 205 | -    public function deleteClient($client_id = null){ | |
| 206 | -        if(!$client_id){ | |
| 205 | +    public function deleteClient($client_id = null) { | |
| 206 | +        if (!$client_id) { | |
| 207 | 207 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); | 
| 208 | 208 | } | 
| 209 | 209 | |
| @@ -226,7 +226,7 @@ discard block | ||
| 226 | 226 | * @param string $fee_bearer [Mandatory] | 
| 227 | 227 | * @param array $items [Mandatory] | 
| 228 | 228 | */ | 
| 229 | -    public function addInvoice($client_id, array $client_data, $due_date, $fee_bearer, array $items){ | |
| 229 | +    public function addInvoice($client_id, array $client_data, $due_date, $fee_bearer, array $items) { | |
| 230 | 230 | // Mandatory Client fields | 
| 231 | 231 | $required_client_values = ['first_name', 'last_name', 'email', 'phone']; | 
| 232 | 232 | |
| @@ -236,21 +236,21 @@ discard block | ||
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | // Either the client Id is supplied or a new client data is provided | 
| 239 | -        if(!$client_id && !array_keys_exist($client_data, $required_client_values)){ | |
| 239 | +        if (!$client_id && !array_keys_exist($client_data, $required_client_values)) { | |
| 240 | 240 |              throw new RequiredValuesMissing("Missing required values :( - Provide client_id or client_data"); | 
| 241 | 241 | } | 
| 242 | 242 | |
| 243 | -        if(!$due_date){ | |
| 243 | +        if (!$due_date) { | |
| 244 | 244 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Due Date"); | 
| 245 | 245 | } | 
| 246 | 246 | |
| 247 | -        if(!$fee_bearer){ | |
| 247 | +        if (!$fee_bearer) { | |
| 248 | 248 |              throw new IsNull("Error Processing Request - Null Fee Bearer"); | 
| 249 | 249 |          }elseif (!in_array($fee_bearer, $valid_fee_bearers)) { | 
| 250 | 250 |              throw new InvalidFeeBearer("Invalid Fee Bearer - Use either 'account' or 'client'"); | 
| 251 | 251 | } | 
| 252 | 252 | |
| 253 | -        if(!is_array($items)){ | |
| 253 | +        if (!is_array($items)) { | |
| 254 | 254 |              throw new IsInvalid("Error Processing Request - Invalid Items"); | 
| 255 | 255 | } | 
| 256 | 256 | |
| @@ -276,8 +276,8 @@ discard block | ||
| 276 | 276 | * @param string $reference_code [Mandatory - Invoice Reference Code] | 
| 277 | 277 | * @return object | 
| 278 | 278 | */ | 
| 279 | -    public function getInvoice($reference_code){ | |
| 280 | -        if(!$reference_code){ | |
| 279 | +    public function getInvoice($reference_code) { | |
| 280 | +        if (!$reference_code) { | |
| 281 | 281 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| 282 | 282 | } | 
| 283 | 283 | |
| @@ -291,8 +291,8 @@ discard block | ||
| 291 | 291 | * @param string $reference_code [Mandatory - Invoice Reference Code] | 
| 292 | 292 | * @return object | 
| 293 | 293 | */ | 
| 294 | -    public function sendInvoice($reference_code = null){ | |
| 295 | -        if(!$reference_code){ | |
| 294 | +    public function sendInvoice($reference_code = null) { | |
| 295 | +        if (!$reference_code) { | |
| 296 | 296 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| 297 | 297 | } | 
| 298 | 298 | |
| @@ -312,8 +312,8 @@ discard block | ||
| 312 | 312 | * @param string $end [Format - DD/MM/YYYY] | 
| 313 | 313 | * @return object | 
| 314 | 314 | */ | 
| 315 | -    public function getInvoiceHistory($period, $start = null, $end = null){ | |
| 316 | -        if(!$period){ | |
| 315 | +    public function getInvoiceHistory($period, $start = null, $end = null) { | |
| 316 | +        if (!$period) { | |
| 317 | 317 |              throw new RequiredValueMissing("Error Processing Request - period Missing"); | 
| 318 | 318 | } | 
| 319 | 319 | |
| @@ -328,8 +328,8 @@ discard block | ||
| 328 | 328 | 'period' => $period | 
| 329 | 329 | ]; | 
| 330 | 330 | |
| 331 | -        if ($period == 'custom'){ | |
| 332 | -            if (!$start || !$end){ | |
| 331 | +        if ($period == 'custom') { | |
| 332 | +            if (!$start || !$end) { | |
| 333 | 333 |                  throw new IsNull("Invalid custom Start or End date"); | 
| 334 | 334 | } | 
| 335 | 335 | $post_data['start'] = $start; | 
| @@ -350,8 +350,8 @@ discard block | ||
| 350 | 350 | * @param string $reference_code [Mandatory - Invoice Reference Code] | 
| 351 | 351 | * @return object | 
| 352 | 352 | */ | 
| 353 | -    public function deleteInvoice($reference_code){ | |
| 354 | -        if(!$reference_code){ | |
| 353 | +    public function deleteInvoice($reference_code) { | |
| 354 | +        if (!$reference_code) { | |
| 355 | 355 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| 356 | 356 | } | 
| 357 | 357 | |
| @@ -371,15 +371,15 @@ discard block | ||
| 371 | 371 | * Optional - 'address', 'company_name', 'type', | 
| 372 | 372 | * @param string $amount [Mandatory] | 
| 373 | 373 | */ | 
| 374 | -    public function addTransfer(array $client_data, string $amount){ | |
| 374 | +    public function addTransfer(array $client_data, string $amount) { | |
| 375 | 375 | // Mandatory Client fields | 
| 376 | 376 | $required_client_values = ['first_name', 'last_name', 'email', 'phone', 'settlement_bank', 'account_number']; | 
| 377 | 377 | |
| 378 | -        if(!array_keys_exist($client_data, $required_client_values)){ | |
| 378 | +        if (!array_keys_exist($client_data, $required_client_values)) { | |
| 379 | 379 |              throw new RequiredValuesMissing("Missing required values :( - Provide client_data"); | 
| 380 | 380 | } | 
| 381 | 381 | |
| 382 | -        if(!$amount){ | |
| 382 | +        if (!$amount) { | |
| 383 | 383 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount"); | 
| 384 | 384 | } | 
| 385 | 385 | |
| @@ -402,8 +402,8 @@ discard block | ||
| 402 | 402 | * @param string $reference_code [Mandatory - Transfer Reference Code] | 
| 403 | 403 | * @return object | 
| 404 | 404 | */ | 
| 405 | -    public function getTransfer($reference_code){ | |
| 406 | -        if(!$reference_code){ | |
| 405 | +    public function getTransfer($reference_code) { | |
| 406 | +        if (!$reference_code) { | |
| 407 | 407 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| 408 | 408 | } | 
| 409 | 409 | |
| @@ -424,8 +424,8 @@ discard block | ||
| 424 | 424 | * @param string $end [Format - DD/MM/YYYY] | 
| 425 | 425 | * @return object | 
| 426 | 426 | */ | 
| 427 | -    public function getTransferHistory($period, $start = null, $end = null){ | |
| 428 | -        if(!$period){ | |
| 427 | +    public function getTransferHistory($period, $start = null, $end = null) { | |
| 428 | +        if (!$period) { | |
| 429 | 429 |              throw new RequiredValueMissing("Error Processing Request - period Missing"); | 
| 430 | 430 | } | 
| 431 | 431 | |
| @@ -440,8 +440,8 @@ discard block | ||
| 440 | 440 | 'period' => $period | 
| 441 | 441 | ]; | 
| 442 | 442 | |
| 443 | -        if ($period == 'custom'){ | |
| 444 | -            if (!$start || !$end){ | |
| 443 | +        if ($period == 'custom') { | |
| 444 | +            if (!$start || !$end) { | |
| 445 | 445 |                  throw new IsNull("Invalid custom Start or End date"); | 
| 446 | 446 | } | 
| 447 | 447 | $post_data['start'] = $start; | 
| @@ -462,8 +462,8 @@ discard block | ||
| 462 | 462 | * @param string $reference_code [Mandatory - Invoice Reference Code] | 
| 463 | 463 | * @return object | 
| 464 | 464 | */ | 
| 465 | -    public function deleteTransfer($reference_code){ | |
| 466 | -        if(!$reference_code){ | |
| 465 | +    public function deleteTransfer($reference_code) { | |
| 466 | +        if (!$reference_code) { | |
| 467 | 467 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| 468 | 468 | } | 
| 469 | 469 | |
| @@ -484,22 +484,22 @@ discard block | ||
| 484 | 484 | * @param string $amount [Mandatory] | 
| 485 | 485 | * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] | 
| 486 | 486 | */ | 
| 487 | -    public function addPayment(string $reference_code, string $date, string $amount, string $channel){ | |
| 488 | -        if(!$reference_code){ | |
| 487 | +    public function addPayment(string $reference_code, string $date, string $amount, string $channel) { | |
| 488 | +        if (!$reference_code) { | |
| 489 | 489 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| 490 | 490 | } | 
| 491 | 491 | |
| 492 | -        if(!$due_date){ | |
| 492 | +        if (!$due_date) { | |
| 493 | 493 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid date"); | 
| 494 | 494 | } | 
| 495 | 495 | |
| 496 | -        if(!$amount){ | |
| 496 | +        if (!$amount) { | |
| 497 | 497 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount"); | 
| 498 | 498 | } | 
| 499 | 499 | |
| 500 | 500 | $valid_channels = ["Cash", "BankTransfer", "POS", "Cheque"]; | 
| 501 | 501 | |
| 502 | -        if(!$channel){ | |
| 502 | +        if (!$channel) { | |
| 503 | 503 |              throw new IsNull("Error Processing Request - Null/Invalid amount"); | 
| 504 | 504 |          }elseif (!in_array(ucfirst($channel), $valid_channels)) { | 
| 505 | 505 |              throw new IsInvalid("Invalid Channel - Cash, BankTransfer, POS or Cheque"); | 
| @@ -525,8 +525,8 @@ discard block | ||
| 525 | 525 | * [getPayment] | 
| 526 | 526 | * @param string $reference_code [Mandatory - Invoice Reference Code] | 
| 527 | 527 | */ | 
| 528 | -    public function getPayment($reference_code){ | |
| 529 | -        if(!$reference_code){ | |
| 528 | +    public function getPayment($reference_code) { | |
| 529 | +        if (!$reference_code) { | |
| 530 | 530 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); | 
| 531 | 531 | } | 
| 532 | 532 | |
| @@ -546,8 +546,8 @@ discard block | ||
| 546 | 546 | * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] | 
| 547 | 547 | * @return object | 
| 548 | 548 | */ | 
| 549 | -    public function getPaymentHistory(string $period, string $start, string $end){ | |
| 550 | -        if(!$period){ | |
| 549 | +    public function getPaymentHistory(string $period, string $start, string $end) { | |
| 550 | +        if (!$period) { | |
| 551 | 551 |              throw new RequiredValueMissing("Error Processing Request - period Missing"); | 
| 552 | 552 | } | 
| 553 | 553 | |
| @@ -562,8 +562,8 @@ discard block | ||
| 562 | 562 | 'period' => $period | 
| 563 | 563 | ]; | 
| 564 | 564 | |
| 565 | -        if ($period == 'custom'){ | |
| 566 | -            if (!$start || !$end){ | |
| 565 | +        if ($period == 'custom') { | |
| 566 | +            if (!$start || !$end) { | |
| 567 | 567 |                  throw new IsNull("Invalid custom Start or End date"); | 
| 568 | 568 | } | 
| 569 | 569 | $post_data['start'] = $start; | 
| @@ -586,23 +586,23 @@ discard block | ||
| 586 | 586 | * @param string $unit_cost [Mandatory - Product's unit cost] | 
| 587 | 587 | * @param string $type [Mandatory - Product type 'product' or 'service'] | 
| 588 | 588 | */ | 
| 589 | -    public function addProduct(string $name, string $description, string $unit_cost, string $type){ | |
| 590 | -        if(!$name){ | |
| 589 | +    public function addProduct(string $name, string $description, string $unit_cost, string $type) { | |
| 590 | +        if (!$name) { | |
| 591 | 591 |              throw new IsNull("Error Processing Request - Null/Invalid name"); | 
| 592 | 592 | } | 
| 593 | 593 | |
| 594 | -        if(!$description){ | |
| 594 | +        if (!$description) { | |
| 595 | 595 |              throw new IsNull("Error Processing Request - Null/Invalid description"); | 
| 596 | 596 | } | 
| 597 | 597 | |
| 598 | -        if(!$unit_cost){ | |
| 598 | +        if (!$unit_cost) { | |
| 599 | 599 |              throw new IsNull("Error Processing Request - Null/Invalid unit_cost"); | 
| 600 | 600 | } | 
| 601 | 601 | |
| 602 | 602 | //Validate Product Type | 
| 603 | 603 | $valid_product_type = ["product", "service"]; | 
| 604 | 604 | |
| 605 | -        if(!$type){ | |
| 605 | +        if (!$type) { | |
| 606 | 606 |              throw new IsNull("Error Processing Request - Null/Invalid type"); | 
| 607 | 607 |          }elseif (!in_array(strtolower($type), $valid_product_type)) { | 
| 608 | 608 |              throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); | 
| @@ -629,8 +629,8 @@ discard block | ||
| 629 | 629 | * @param int $product_id [Mandatory - Product ID] | 
| 630 | 630 | * @return object | 
| 631 | 631 | */ | 
| 632 | -    public function getProduct($product_id){ | |
| 633 | -        if(!$product_id){ | |
| 632 | +    public function getProduct($product_id) { | |
| 633 | +        if (!$product_id) { | |
| 634 | 634 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); | 
| 635 | 635 | } | 
| 636 | 636 | |
| @@ -649,8 +649,8 @@ discard block | ||
| 649 | 649 | * @param array $product_data [description] | 
| 650 | 650 | * @return object | 
| 651 | 651 | */ | 
| 652 | -    public function editProduct($product_id, array $product_data){ | |
| 653 | -        if(!$product_id){ | |
| 652 | +    public function editProduct($product_id, array $product_data) { | |
| 653 | +        if (!$product_id) { | |
| 654 | 654 |                 throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); | 
| 655 | 655 | } | 
| 656 | 656 | |
| @@ -659,7 +659,7 @@ discard block | ||
| 659 | 659 | |
| 660 | 660 | $valid_product_type = ["product", "service"]; | 
| 661 | 661 | |
| 662 | -        if(!$product_type){ | |
| 662 | +        if (!$product_type) { | |
| 663 | 663 |              throw new IsNull("Error Processing Request - Null/Invalid type"); | 
| 664 | 664 |          }elseif (!in_array($product_type, $valid_product_type)) { | 
| 665 | 665 |              throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); | 
| @@ -670,7 +670,7 @@ discard block | ||
| 670 | 670 | // Mandatory fields | 
| 671 | 671 | $required_values = ['name', 'description', 'unit_cost', 'type']; | 
| 672 | 672 | |
| 673 | -        if(!array_keys_exist($client_data, $required_values)){ | |
| 673 | +        if (!array_keys_exist($client_data, $required_values)) { | |
| 674 | 674 |               throw new RequiredValuesMissing("Missing required values :("); | 
| 675 | 675 | } | 
| 676 | 676 | |
| @@ -684,7 +684,7 @@ discard block | ||
| 684 | 684 | * [getProducts] | 
| 685 | 685 | * @return object | 
| 686 | 686 | */ | 
| 687 | -    public function getProducts(){ | |
| 687 | +    public function getProducts() { | |
| 688 | 688 | $url = "/products"; | 
| 689 | 689 | |
| 690 | 690 |          return $this->sendRequest('get', $url); | 
| @@ -698,8 +698,8 @@ discard block | ||
| 698 | 698 | * @param $product_id [Mandatory - Product ID] | 
| 699 | 699 | * @return object | 
| 700 | 700 | */ | 
| 701 | -    public function deleteProduct($product_id){ | |
| 702 | -        if(!$product_id){ | |
| 701 | +    public function deleteProduct($product_id) { | |
| 702 | +        if (!$product_id) { | |
| 703 | 703 |              throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); | 
| 704 | 704 | } | 
| 705 | 705 | |
| @@ -716,22 +716,22 @@ discard block | ||
| 716 | 716 | * @param string $url [Mandatory - url to send request to] | 
| 717 | 717 | * @param array $params [data to post to request url] | 
| 718 | 718 | */ | 
| 719 | - public function sendRequest($method, $url, $params=[]) | |
| 719 | + public function sendRequest($method, $url, $params = []) | |
| 720 | 720 |      { | 
| 721 | -        try{ | |
| 722 | -            if (strtolower($method) == 'get'){ | |
| 721 | +        try { | |
| 722 | +            if (strtolower($method) == 'get') { | |
| 723 | 723 |                  $result = $this->client->request('GET', $url); | 
| 724 | -            }elseif (strtolower($method) == 'post'){ | |
| 724 | +            }elseif (strtolower($method) == 'post') { | |
| 725 | 725 |                  $result = $this->client->request('POST', $url, $params); | 
| 726 | -            }elseif (strtolower($method) == 'put'){ | |
| 726 | +            }elseif (strtolower($method) == 'put') { | |
| 727 | 727 |                  $result = $this->client->request('PUT', $url, $params); | 
| 728 | -            }elseif (strtolower($method) == 'delete'){ | |
| 728 | +            }elseif (strtolower($method) == 'delete') { | |
| 729 | 729 |                  $result = $this->client->request('DELETE', $url); | 
| 730 | 730 | } | 
| 731 | 731 | |
| 732 | 732 | return cleanResponse($result); | 
| 733 | 733 | } | 
| 734 | -        catch( Exception $e){ | |
| 734 | +        catch (Exception $e) { | |
| 735 | 735 | throw $e; | 
| 736 | 736 | } | 
| 737 | 737 | } |