Test Setup Failed
Push — master ( 27bb17...16acb2 )
by Emmanuel
02:25
created
src/Payant.php 1 patch
Indentation   +85 added lines, -85 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.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('payantng.isdemo') == 'TRUE')
@@ -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( [
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
286 286
     }
287 287
 
288 288
     /**
289
-    * [sendInvoice]
290
-    * @param  [type] $reference_code [Mandatory - Invoice Reference Code]
291
-    * @return [object]               
292
-    */
289
+     * [sendInvoice]
290
+     * @param  [type] $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
 block discarded – undo
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");
@@ -345,10 +345,10 @@  discard block
 block discarded – undo
345 345
 
346 346
 
347 347
     /**
348
-    * [deleteInvoice]
349
-    * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
350
-    * @return [object]                 
351
-    */
348
+     * [deleteInvoice]
349
+     * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
350
+     * @return [object]                 
351
+     */
352 352
     public function deleteInvoice($reference_code){
353 353
         if(!$reference_code){
354 354
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
 
365 365
 
366 366
     /**
367
-    * [addPayment]
368
-    * @param [string] $reference_code [Mandatory - Invoice Reference Code]
369
-    * @param [string] $date           [Mandatory - [Format - DD/MM/YYYY]]
370
-    * @param [string] $amount         [Mandatory]
371
-    * @param [string] $channel        [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]]
372
-    */
367
+     * [addPayment]
368
+     * @param [string] $reference_code [Mandatory - Invoice Reference Code]
369
+     * @param [string] $date           [Mandatory - [Format - DD/MM/YYYY]]
370
+     * @param [string] $amount         [Mandatory]
371
+     * @param [string] $channel        [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]]
372
+     */
373 373
     public function addPayment(string $reference_code, string $date, string $amount, string $channel){
374 374
         if(!$reference_code){
375 375
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
 
409 409
 
410 410
     /**
411
-    * [getPayment]
412
-    * @param [string] $reference_code [Mandatory - Invoice Reference Code]
413
-    */
411
+     * [getPayment]
412
+     * @param [string] $reference_code [Mandatory - Invoice Reference Code]
413
+     */
414 414
     public function getPayment($reference_code){
415 415
         if(!$reference_code){
416 416
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
 
427 427
 
428 428
     /**
429
-    * [getPaymentHistory]
430
-    * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
431
-    * @param  [string] $start  [Format - DD/MM/YYYY || Optional if $period !== 'custom']
432
-    * @param  [string] $end    [Format - DD/MM/YYYY || Optional if $period !== 'custom']
433
-    * @return [object]         
434
-    */
429
+     * [getPaymentHistory]
430
+     * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
431
+     * @param  [string] $start  [Format - DD/MM/YYYY || Optional if $period !== 'custom']
432
+     * @param  [string] $end    [Format - DD/MM/YYYY || Optional if $period !== 'custom']
433
+     * @return [object]         
434
+     */
435 435
     public function getPaymentHistory(string $period, string $start, string $end){
436 436
         if(!$period){
437 437
             throw new RequiredValueMissing("Error Processing Request - period Missing");
@@ -466,12 +466,12 @@  discard block
 block discarded – undo
466 466
 
467 467
 
468 468
     /**
469
-    * [addProduct]
470
-    * @param string $name        [Mandatory - Product's name]
471
-    * @param string $description [Mandatory - Product's description]
472
-    * @param string $unit_cost   [Mandatory - Product's unit cost]
473
-    * @param string $type        [Mandatory - Product type 'product' or 'service']
474
-    */
469
+     * [addProduct]
470
+     * @param string $name        [Mandatory - Product's name]
471
+     * @param string $description [Mandatory - Product's description]
472
+     * @param string $unit_cost   [Mandatory - Product's unit cost]
473
+     * @param string $type        [Mandatory - Product type 'product' or 'service']
474
+     */
475 475
     public function addProduct(string $name, string $description, string $unit_cost, string $type){
476 476
         if(!$name){
477 477
             throw new IsNull("Error Processing Request - Null/Invalid name");
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 
512 512
 
513 513
     /**
514
-    * [getProduct]
515
-    * @param  [int] $product_id [Mandatory - Product ID]
516
-    * @return [object] 
517
-    */
514
+     * [getProduct]
515
+     * @param  [int] $product_id [Mandatory - Product ID]
516
+     * @return [object] 
517
+     */
518 518
     public function getProduct($product_id){
519 519
         if(!$product_id){
520 520
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id");
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
 
531 531
 
532 532
     /**
533
-    * [editProduct]
534
-    * @param  string $product_id   [Mandatory - Product ID]
535
-    * @param  array  $product_data [description]
536
-    * @return object               
537
-    */
533
+     * [editProduct]
534
+     * @param  string $product_id   [Mandatory - Product ID]
535
+     * @param  array  $product_data [description]
536
+     * @return object               
537
+     */
538 538
     public function editProduct($product_id, array $product_data){
539 539
         if(!$product_id){
540
-               throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
540
+                throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
541 541
         }
542 542
 
543 543
         //Validate Type
@@ -551,13 +551,13 @@  discard block
 block discarded – undo
551 551
             throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'");
552 552
         }
553 553
 
554
-       $url = "/products/{$product_id}";
554
+        $url = "/products/{$product_id}";
555 555
 
556
-       // Mandatory fields
557
-       $required_values = ['name', 'description', 'unit_cost', 'type'];
556
+        // Mandatory fields
557
+        $required_values = ['name', 'description', 'unit_cost', 'type'];
558 558
 
559 559
         if(!array_keys_exist($client_data, $required_values)){
560
-             throw new RequiredValuesMissing("Missing required values :(");
560
+                throw new RequiredValuesMissing("Missing required values :(");
561 561
         }
562 562
 
563 563
         return $this->sendRequest('put', $url, ['form_params' => $post_data]);
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
 
568 568
 
569 569
     /**
570
-    * [getProducts]
571
-    * @return object
572
-    */
570
+     * [getProducts]
571
+     * @return object
572
+     */
573 573
     public function getProducts(){
574 574
         $url = "/products";
575 575
 
@@ -580,10 +580,10 @@  discard block
 block discarded – undo
580 580
 
581 581
 
582 582
     /**
583
-    * [deleteProduct]
584
-    * @param $product_id [Mandatory - Product ID]
585
-    * @return object           
586
-    */
583
+     * [deleteProduct]
584
+     * @param $product_id [Mandatory - Product ID]
585
+     * @return object           
586
+     */
587 587
     public function deleteProduct($product_id){
588 588
         if(!$product_id){
589 589
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
@@ -597,11 +597,11 @@  discard block
 block discarded – undo
597 597
 
598 598
 
599 599
     /**
600
-    * [addPayment]
601
-    * @param [string] $method       [Mandatory - request method <get | post | put | delete> ]
602
-    * @param [string] $url           [Mandatory - url to send request to]
603
-    * @param [array] $params         [data to post to request url]
604
-    */
600
+     * [addPayment]
601
+     * @param [string] $method       [Mandatory - request method <get | post | put | delete> ]
602
+     * @param [string] $url           [Mandatory - url to send request to]
603
+     * @param [array] $params         [data to post to request url]
604
+     */
605 605
     public function sendRequest($method, $url, $params=[])
606 606
     {
607 607
         try{
Please login to merge, or discard this patch.
src/Support/helpers.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 if (! function_exists('array_get'))
17 17
 {
18
-  /*
18
+    /*
19 19
    *
20 20
    * @param array  $data
21 21
    * @param string $key
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
    *
24 24
    * @return mixed
25 25
    */
26
-   function array_get($data, $key, $default = false) {
27
-     if (!is_array($data)) {
28
-         return $default;
29
-     }
30
-     return isset($data[$key]) ? $data[$key]: $default;
31
-   }
26
+    function array_get($data, $key, $default = false) {
27
+        if (!is_array($data)) {
28
+            return $default;
29
+        }
30
+        return isset($data[$key]) ? $data[$key]: $default;
31
+    }
32 32
 }
33 33
 
34 34
 if(!function_exists('array_keys_exist')){
@@ -57,6 +57,6 @@  discard block
 block discarded – undo
57 57
 }
58 58
 
59 59
 function cleanResponse($response){
60
-	$result = $response->getBody();
61
-	return json_decode($result);
60
+    $result = $response->getBody();
61
+    return json_decode($result);
62 62
 }
63 63
\ No newline at end of file
Please login to merge, or discard this patch.