Passed
Push — master ( a8d879...5effd2 )
by Emmanuel
02:40
created
src/Payant.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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{
Please login to merge, or discard this patch.