Completed
Branch master (7df6ea)
by Emmanuel
04:49
created
src/PayantServiceProvider.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
     protected $defer = false;
25 25
 
26 26
     /**
27
-    * Publishes all the config file this package needs to function
28
-    */
27
+     * Publishes all the config file this package needs to function
28
+     */
29 29
     public function boot()
30 30
     {
31 31
         $config = realpath(__DIR__.'/../resources/config/payant.php');
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     /**
39
-    * Register the application services.
40
-    */
39
+     * Register the application services.
40
+     */
41 41
     public function register()
42 42
     {
43 43
         $this->app->bind('laravel-payant', function () {
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
     }
49 49
 
50 50
     /**
51
-    * Get the services provided by the provider
52
-    * @return array
53
-    */
51
+     * Get the services provided by the provider
52
+     * @return array
53
+     */
54 54
     public function provides()
55 55
     {
56 56
         return ['laravel-payant'];
Please login to merge, or discard this patch.
src/Support/helpers.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 
7 7
 if (! function_exists('array_get'))
8 8
 {
9
-  /*
9
+    /*
10 10
    *
11 11
    * @param array  $data
12 12
    * @param string $key
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
    *
15 15
    * @return mixed
16 16
    */
17
-   function array_get($data, $key, $default = false) {
18
-     if (!is_array($data)) {
19
-         return $default;
20
-     }
21
-     return isset($data[$key]) ? $data[$key]: $default;
22
-   }
17
+    function array_get($data, $key, $default = false) {
18
+        if (!is_array($data)) {
19
+            return $default;
20
+        }
21
+        return isset($data[$key]) ? $data[$key]: $default;
22
+    }
23 23
 }
24 24
 
25 25
 if(!function_exists('array_keys_exist')){
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 function cleanResponse($response){
51
-	$result = $response->getBody();
52
-	return json_decode($result);
51
+    $result = $response->getBody();
52
+    return json_decode($result);
53 53
 }
54
- ?>
54
+    ?>
Please login to merge, or discard this patch.
src/Payant.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     /**
23 23
      * @var $private_key
24
-    */
24
+     */
25 25
     protected $private_key;
26 26
     
27 27
 
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @var $base_uri
31 31
      *
32
-    */
32
+     */
33 33
     protected $base_uri = 'https://api.payant.ng';
34 34
     
35 35
     
36 36
     /**
37 37
      * @var $client
38 38
      *
39
-    */
39
+     */
40 40
     protected $client;
41 41
 
42 42
     
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     /**
54
-    * Get Base Url from Payant config file
55
-    */
54
+     * Get Base Url from Payant config file
55
+     */
56 56
     public function setBaseUrl()
57 57
     {
58 58
         if(Config::get('payantng.isdemo') == 'TRUE')
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     private function setRequestOptions()
77 77
     {       
78
-       $authorization_string = 'Bearer '. $this->private_key;
78
+        $authorization_string = 'Bearer '. $this->private_key;
79 79
 
80 80
         //Set up Guzzle
81 81
         $this->client = new Client( [
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     /**
93 93
      * [getStates Get States in a country (Nigeria)]
94 94
      * @return [object] [list of banks and their respective bank_ids]
95
-    */
95
+     */
96 96
     public function getBanks(){
97 97
         return $this->sendRequest('get', '/banks');
98 98
     }
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
      * [resolveAccount description]
104 104
      * @param array $client_data [description]
105 105
      * Required fields - 'settlement_bank', 'account_number'
106
-    */
106
+     */
107 107
     public function resolveAccount( array $client_data){
108 108
         // Mandatory fields
109 109
         $required_values = ['settlement_bank', 'account_number'];
110 110
 
111 111
         if(!array_keys_exist($client_data, $required_values)){
112
-         throw new Exception\RequiredValuesMissing("Missing required values :(");
112
+            throw new Exception\RequiredValuesMissing("Missing required values :(");
113 113
         }
114 114
 
115 115
         $url = '/resolve-account';
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
      * @param array $client_data [description]
126 126
      * Required fields - 'first_name', 'last_name', 'email', 'phone'
127 127
      * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
128
-    */
128
+     */
129 129
     public function addClient( array $client_data){
130 130
         // Mandatory fields
131 131
         $required_values = ['first_name', 'last_name', 'email', 'phone'];
132 132
 
133 133
         if(!array_keys_exist($client_data, $required_values)){
134
-         throw new Exception\RequiredValuesMissing("Missing required values :(");
134
+            throw new Exception\RequiredValuesMissing("Missing required values :(");
135 135
         }
136 136
 
137 137
         $url = '/clients';
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * [getClient Get client Details]
147 147
      * @param  [string] $client_id
148 148
      * @return [object]
149
-    */
149
+     */
150 150
     public function getClient($client_id = null){
151 151
         if(!$client_id){
152 152
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 
163 163
 
164 164
     /**
165
-    * [editClient - Edit Existing Client]
166
-    * @param [string] $client_id
167
-    * @param [array] $client_data
168
-    *        Required fields - 'first_name', 'last_name', 'email', 'phone'
169
-    *        Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
170
-    */
165
+     * [editClient - Edit Existing Client]
166
+     * @param [string] $client_id
167
+     * @param [array] $client_data
168
+     *        Required fields - 'first_name', 'last_name', 'email', 'phone'
169
+     *        Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
170
+     */
171 171
     public function editClient( $client_id, array $client_data){
172 172
         if(!$client_id){
173
-           throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
173
+            throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
174 174
         }
175 175
 
176 176
         $url = "/clients/{$client_id}";
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $required_values = ['first_name', 'last_name', 'email', 'phone'];
180 180
 
181 181
         if(!array_keys_exist($client_data, $required_values)){
182
-             throw new Exception\RequiredValuesMissing("Missing required values :(");
182
+                throw new Exception\RequiredValuesMissing("Missing required values :(");
183 183
         }
184 184
 
185 185
         return $this->sendRequest('put', $url, ['form_params' => $client_data]);
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 
264 264
 
265 265
     /**
266
-    * [getInvoice ]
267
-    * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
268
-    * @return [object]               
269
-    */
266
+     * [getInvoice ]
267
+     * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
268
+     * @return [object]               
269
+     */
270 270
     public function getInvoice($reference_code){
271 271
         if(!$reference_code){
272 272
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
     }
279 279
 
280 280
     /**
281
-    * [sendInvoice]
282
-    * @param  [type] $reference_code [Mandatory - Invoice Reference Code]
283
-    * @return [object]               
284
-    */
281
+     * [sendInvoice]
282
+     * @param  [type] $reference_code [Mandatory - Invoice Reference Code]
283
+     * @return [object]               
284
+     */
285 285
     public function sendInvoice($reference_code = null){
286 286
         if(!$reference_code){
287 287
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 
298 298
 
299 299
     /**
300
-    * [getInvoiceHistory]
301
-    * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
302
-    * @param  [string] $start  [Format - DD/MM/YYYY]
303
-    * @param  [string] $end    [Format - DD/MM/YYYY]
304
-    * @return [object]         
305
-    */
300
+     * [getInvoiceHistory]
301
+     * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
302
+     * @param  [string] $start  [Format - DD/MM/YYYY]
303
+     * @param  [string] $end    [Format - DD/MM/YYYY]
304
+     * @return [object]         
305
+     */
306 306
     public function getInvoiceHistory($period, $start = null, $end = null){
307 307
         if(!$period){
308 308
             throw new Exception\RequiredValueMissing("Error Processing Request - period Missing");
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
 
338 338
 
339 339
     /**
340
-    * [deleteInvoice]
341
-    * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
342
-    * @return [object]                 
343
-    */
340
+     * [deleteInvoice]
341
+     * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
342
+     * @return [object]                 
343
+     */
344 344
     public function deleteInvoice($reference_code){
345 345
         if(!$reference_code){
346 346
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 
357 357
 
358 358
     /**
359
-    * [addPayment]
360
-    * @param [string] $reference_code [Mandatory - Invoice Reference Code]
361
-    * @param [string] $date           [Mandatory - [Format - DD/MM/YYYY]]
362
-    * @param [string] $amount         [Mandatory]
363
-    * @param [string] $channel        [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]]
364
-    */
359
+     * [addPayment]
360
+     * @param [string] $reference_code [Mandatory - Invoice Reference Code]
361
+     * @param [string] $date           [Mandatory - [Format - DD/MM/YYYY]]
362
+     * @param [string] $amount         [Mandatory]
363
+     * @param [string] $channel        [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]]
364
+     */
365 365
     public function addPayment(string $reference_code, string $date, string $amount, string $channel){
366 366
         if(!$reference_code){
367 367
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 
401 401
 
402 402
     /**
403
-    * [getPayment]
404
-    * @param [string] $reference_code [Mandatory - Invoice Reference Code]
405
-    */
403
+     * [getPayment]
404
+     * @param [string] $reference_code [Mandatory - Invoice Reference Code]
405
+     */
406 406
     public function getPayment($reference_code){
407 407
         if(!$reference_code){
408 408
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
 
419 419
 
420 420
     /**
421
-    * [getPaymentHistory]
422
-    * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
423
-    * @param  [string] $start  [Format - DD/MM/YYYY || Optional if $period !== 'custom']
424
-    * @param  [string] $end    [Format - DD/MM/YYYY || Optional if $period !== 'custom']
425
-    * @return [object]         
426
-    */
421
+     * [getPaymentHistory]
422
+     * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
423
+     * @param  [string] $start  [Format - DD/MM/YYYY || Optional if $period !== 'custom']
424
+     * @param  [string] $end    [Format - DD/MM/YYYY || Optional if $period !== 'custom']
425
+     * @return [object]         
426
+     */
427 427
     public function getPaymentHistory(string $period, string $start, string $end){
428 428
         if(!$period){
429 429
             throw new Exception\RequiredValueMissing("Error Processing Request - period Missing");
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 
459 459
 
460 460
     /**
461
-    * [addProduct]
462
-    * @param string $name        [Mandatory - Product's name]
463
-    * @param string $description [Mandatory - Product's description]
464
-    * @param string $unit_cost   [Mandatory - Product's unit cost]
465
-    * @param string $type        [Mandatory - Product type 'product' or 'service']
466
-    */
461
+     * [addProduct]
462
+     * @param string $name        [Mandatory - Product's name]
463
+     * @param string $description [Mandatory - Product's description]
464
+     * @param string $unit_cost   [Mandatory - Product's unit cost]
465
+     * @param string $type        [Mandatory - Product type 'product' or 'service']
466
+     */
467 467
     public function addProduct(string $name, string $description, string $unit_cost, string $type){
468 468
         if(!$name){
469 469
             throw new Exception\IsNull("Error Processing Request - Null/Invalid name");
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 
504 504
 
505 505
     /**
506
-    * [getProduct]
507
-    * @param  [int] $product_id [Mandatory - Product ID]
508
-    * @return [object] 
509
-    */
506
+     * [getProduct]
507
+     * @param  [int] $product_id [Mandatory - Product ID]
508
+     * @return [object] 
509
+     */
510 510
     public function getProduct($product_id){
511 511
         if(!$product_id){
512 512
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid product_id");
@@ -522,14 +522,14 @@  discard block
 block discarded – undo
522 522
 
523 523
 
524 524
     /**
525
-    * [editProduct]
526
-    * @param  string $product_id   [Mandatory - Product ID]
527
-    * @param  array  $product_data [description]
528
-    * @return object               
529
-    */
525
+     * [editProduct]
526
+     * @param  string $product_id   [Mandatory - Product ID]
527
+     * @param  array  $product_data [description]
528
+     * @return object               
529
+     */
530 530
     public function editProduct($product_id, array $product_data){
531 531
         if(!$product_id){
532
-               throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
532
+                throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
533 533
         }
534 534
 
535 535
         //Validate Type
@@ -543,13 +543,13 @@  discard block
 block discarded – undo
543 543
             throw new Exception\IsInvalid("Invalid Type - Available options: 'product' or 'service'");
544 544
         }
545 545
 
546
-       $url = "/products/{$product_id}";
546
+        $url = "/products/{$product_id}";
547 547
 
548
-       // Mandatory fields
549
-       $required_values = ['name', 'description', 'unit_cost', 'type'];
548
+        // Mandatory fields
549
+        $required_values = ['name', 'description', 'unit_cost', 'type'];
550 550
 
551 551
         if(!array_keys_exist($client_data, $required_values)){
552
-             throw new Exception\RequiredValuesMissing("Missing required values :(");
552
+                throw new Exception\RequiredValuesMissing("Missing required values :(");
553 553
         }
554 554
 
555 555
         return $this->sendRequest('put', $url, ['form_params' => $post_data]);
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 
560 560
 
561 561
     /**
562
-    * [getProducts]
563
-    * @return object
564
-    */
562
+     * [getProducts]
563
+     * @return object
564
+     */
565 565
     public function getProducts(){
566 566
         $url = "/products";
567 567
 
@@ -572,10 +572,10 @@  discard block
 block discarded – undo
572 572
 
573 573
 
574 574
     /**
575
-    * [deleteProduct]
576
-    * @param $product_id [Mandatory - Product ID]
577
-    * @return object           
578
-    */
575
+     * [deleteProduct]
576
+     * @param $product_id [Mandatory - Product ID]
577
+     * @return object           
578
+     */
579 579
     public function deleteProduct($product_id){
580 580
         if(!$product_id){
581 581
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
 
590 590
 
591 591
     /**
592
-    * [addPayment]
593
-    * @param [string] $method       [Mandatory - request method <get | post | put | delete> ]
594
-    * @param [string] $url           [Mandatory - url to send request to]
595
-    * @param [array] $params         [data to post to request url]
596
-    */
592
+     * [addPayment]
593
+     * @param [string] $method       [Mandatory - request method <get | post | put | delete> ]
594
+     * @param [string] $url           [Mandatory - url to send request to]
595
+     * @param [array] $params         [data to post to request url]
596
+     */
597 597
     public function sendRequest($method, $url, $params=[])
598 598
     {
599 599
         try{
Please login to merge, or discard this patch.
src/Exception.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,4 +10,4 @@
 block discarded – undo
10 10
 class InvalidFeeBearer extends \Exception { }
11 11
 class IsInvalid extends \Exception { }
12 12
 class ApiRequestError extends \Exception { }
13
- ?>
13
+    ?>
Please login to merge, or discard this patch.