@@ -24,8 +24,8 @@ discard block |
||
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 |
||
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 |
||
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']; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | if (! function_exists('array_get')) |
27 | 27 | { |
28 | - /* |
|
28 | + /* |
|
29 | 29 | * |
30 | 30 | * @param array $data |
31 | 31 | * @param string $key |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | - function array_get($data, $key, $default = false) { |
|
37 | - if (!is_array($data)) { |
|
38 | - return $default; |
|
39 | - } |
|
40 | - return isset($data[$key]) ? $data[$key]: $default; |
|
41 | - } |
|
36 | + function array_get($data, $key, $default = false) { |
|
37 | + if (!is_array($data)) { |
|
38 | + return $default; |
|
39 | + } |
|
40 | + return isset($data[$key]) ? $data[$key]: $default; |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | if(!function_exists('array_keys_exist')){ |
@@ -67,6 +67,6 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | function cleanResponse($response){ |
70 | - $result = $response->getBody(); |
|
71 | - return $result; |
|
70 | + $result = $response->getBody(); |
|
71 | + return $result; |
|
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var $private_key |
31 | - */ |
|
31 | + */ |
|
32 | 32 | protected $private_key; |
33 | 33 | |
34 | 34 | |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @var $base_uri |
38 | 38 | * |
39 | - */ |
|
39 | + */ |
|
40 | 40 | protected $base_uri = 'https://api.demo.payant.ng'; |
41 | 41 | |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @var $client |
45 | 45 | * |
46 | - */ |
|
46 | + */ |
|
47 | 47 | protected $client; |
48 | 48 | |
49 | 49 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | - * Get Base Url from Payant config file |
|
62 | - */ |
|
61 | + * Get Base Url from Payant config file |
|
62 | + */ |
|
63 | 63 | public function setBaseUrl() |
64 | 64 | { |
65 | 65 | if(Config::get('payant.mode') == 'LIVE') |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | private function setRequestOptions() |
84 | 84 | { |
85 | - $authorization_string = 'Bearer '. $this->private_key; |
|
85 | + $authorization_string = 'Bearer '. $this->private_key; |
|
86 | 86 | |
87 | 87 | //Set up Guzzle |
88 | 88 | $this->client = new Client( [ |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | /** |
101 | 101 | * [getBanks Get Banks and their ids (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 | } |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | * @param array $client_data [description] |
113 | 113 | * Required fields - 'settlement_bank', 'account_number' |
114 | 114 | * @return object |
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'; |
@@ -135,13 +135,13 @@ 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 | * @return object |
138 | - */ |
|
138 | + */ |
|
139 | 139 | public function addClient( array $client_data){ |
140 | 140 | // Mandatory fields |
141 | 141 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
142 | 142 | |
143 | 143 | if(!array_keys_exist($client_data, $required_values)){ |
144 | - throw new RequiredValuesMissing("Missing required values :("); |
|
144 | + throw new RequiredValuesMissing("Missing required values :("); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | $url = '/clients'; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * [getClient Get client Details] |
157 | 157 | * @param string $client_id |
158 | 158 | * @return object |
159 | - */ |
|
159 | + */ |
|
160 | 160 | public function getClient($client_id = null){ |
161 | 161 | if(!$client_id){ |
162 | 162 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | |
173 | 173 | |
174 | 174 | /** |
175 | - * [editClient - Edit Existing Client] |
|
176 | - * @param string $client_id |
|
177 | - * @param array $client_data |
|
178 | - * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
179 | - * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
180 | - */ |
|
175 | + * [editClient - Edit Existing Client] |
|
176 | + * @param string $client_id |
|
177 | + * @param array $client_data |
|
178 | + * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
179 | + * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
180 | + */ |
|
181 | 181 | public function editClient( $client_id, array $client_data){ |
182 | 182 | if(!$client_id){ |
183 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
183 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $url = "/clients/{$client_id}"; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
190 | 190 | |
191 | 191 | if(!array_keys_exist($client_data, $required_values)){ |
192 | - throw new RequiredValuesMissing("Missing required values :("); |
|
192 | + throw new RequiredValuesMissing("Missing required values :("); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | return $this->sendRequest('put', $url, ['form_params' => $client_data]); |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | |
274 | 274 | |
275 | 275 | /** |
276 | - * [getInvoice ] |
|
277 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
278 | - * @return object |
|
279 | - */ |
|
276 | + * [getInvoice ] |
|
277 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
278 | + * @return object |
|
279 | + */ |
|
280 | 280 | public function getInvoice(string $reference_code){ |
281 | 281 | if(!$reference_code){ |
282 | 282 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | |
293 | 293 | |
294 | 294 | /** |
295 | - * [sendInvoice] |
|
296 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
297 | - * @return object |
|
298 | - */ |
|
295 | + * [sendInvoice] |
|
296 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
297 | + * @return object |
|
298 | + */ |
|
299 | 299 | public function sendInvoice(string $reference_code = null){ |
300 | 300 | if(!$reference_code){ |
301 | 301 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | |
312 | 312 | |
313 | 313 | /** |
314 | - * [getInvoiceHistory] |
|
315 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
316 | - * @param string $start [Format - DD/MM/YYYY] |
|
317 | - * @param string $end [Format - DD/MM/YYYY] |
|
318 | - * @return object |
|
319 | - */ |
|
314 | + * [getInvoiceHistory] |
|
315 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
316 | + * @param string $start [Format - DD/MM/YYYY] |
|
317 | + * @param string $end [Format - DD/MM/YYYY] |
|
318 | + * @return object |
|
319 | + */ |
|
320 | 320 | public function getInvoiceHistory($period, $start = null, $end = null){ |
321 | 321 | if(!$period){ |
322 | 322 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | |
335 | 335 | |
336 | 336 | /** |
337 | - * [deleteInvoice] |
|
338 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
339 | - * @return object |
|
340 | - */ |
|
337 | + * [deleteInvoice] |
|
338 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
339 | + * @return object |
|
340 | + */ |
|
341 | 341 | public function deleteInvoice(string $reference_code){ |
342 | 342 | if(!$reference_code){ |
343 | 343 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | |
388 | 388 | |
389 | 389 | /** |
390 | - * [getTransfer ] |
|
391 | - * @param string $reference_code [Mandatory - Transfer Reference Code] |
|
392 | - * @return object |
|
393 | - */ |
|
390 | + * [getTransfer ] |
|
391 | + * @param string $reference_code [Mandatory - Transfer Reference Code] |
|
392 | + * @return object |
|
393 | + */ |
|
394 | 394 | public function getTransfer(string $reference_code){ |
395 | 395 | if(!$reference_code){ |
396 | 396 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -407,12 +407,12 @@ discard block |
||
407 | 407 | |
408 | 408 | |
409 | 409 | /** |
410 | - * [getTransferHistory] |
|
411 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
412 | - * @param string $start [Format - DD/MM/YYYY] |
|
413 | - * @param string $end [Format - DD/MM/YYYY] |
|
414 | - * @return object |
|
415 | - */ |
|
410 | + * [getTransferHistory] |
|
411 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
412 | + * @param string $start [Format - DD/MM/YYYY] |
|
413 | + * @param string $end [Format - DD/MM/YYYY] |
|
414 | + * @return object |
|
415 | + */ |
|
416 | 416 | public function getTransferHistory($period, $start = null, $end = null){ |
417 | 417 | if(!$period){ |
418 | 418 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | |
432 | 432 | |
433 | 433 | /** |
434 | - * [deleteTransfer] |
|
435 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
436 | - * @return object |
|
437 | - */ |
|
434 | + * [deleteTransfer] |
|
435 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
436 | + * @return object |
|
437 | + */ |
|
438 | 438 | public function deleteTransfer(string $reference_code){ |
439 | 439 | if(!$reference_code){ |
440 | 440 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -451,13 +451,13 @@ discard block |
||
451 | 451 | |
452 | 452 | |
453 | 453 | /** |
454 | - * [addPayment] |
|
455 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
456 | - * @param string $due_date [Mandatory - [Format - DD/MM/YYYY]] |
|
457 | - * @param string $amount [Mandatory] |
|
458 | - * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
459 | - * @return object |
|
460 | - */ |
|
454 | + * [addPayment] |
|
455 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
456 | + * @param string $due_date [Mandatory - [Format - DD/MM/YYYY]] |
|
457 | + * @param string $amount [Mandatory] |
|
458 | + * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
459 | + * @return object |
|
460 | + */ |
|
461 | 461 | public function addPayment(string $reference_code, string $due_date, string $amount, string $channel){ |
462 | 462 | if(!$reference_code){ |
463 | 463 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | |
497 | 497 | |
498 | 498 | /** |
499 | - * [getPayment] |
|
500 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
501 | - * @return object |
|
502 | - */ |
|
499 | + * [getPayment] |
|
500 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
501 | + * @return object |
|
502 | + */ |
|
503 | 503 | public function getPayment(string $reference_code){ |
504 | 504 | if(!$reference_code){ |
505 | 505 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -515,12 +515,12 @@ discard block |
||
515 | 515 | |
516 | 516 | |
517 | 517 | /** |
518 | - * [getPaymentHistory] |
|
519 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
520 | - * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
521 | - * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
522 | - * @return object |
|
523 | - */ |
|
518 | + * [getPaymentHistory] |
|
519 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
520 | + * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
521 | + * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
522 | + * @return object |
|
523 | + */ |
|
524 | 524 | public function getPaymentHistory(string $period, string $start, string $end){ |
525 | 525 | if(!$period){ |
526 | 526 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -539,11 +539,11 @@ discard block |
||
539 | 539 | |
540 | 540 | |
541 | 541 | /** |
542 | - * [addWallet] |
|
543 | - * @param string $name [Mandatory - Wallet's name] |
|
544 | - * @param string $passcode [Mandatory - Wallet's passcode] |
|
545 | - * @return object |
|
546 | - */ |
|
542 | + * [addWallet] |
|
543 | + * @param string $name [Mandatory - Wallet's name] |
|
544 | + * @param string $passcode [Mandatory - Wallet's passcode] |
|
545 | + * @return object |
|
546 | + */ |
|
547 | 547 | public function addWallet(string $name, string $passcode){ |
548 | 548 | if(!$name){ |
549 | 549 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid name"); |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | |
569 | 569 | |
570 | 570 | /** |
571 | - * [getWallet] |
|
572 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
573 | - * @return object |
|
574 | - */ |
|
571 | + * [getWallet] |
|
572 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
573 | + * @return object |
|
574 | + */ |
|
575 | 575 | public function getWallet(string $reference_code){ |
576 | 576 | if(!$reference_code){ |
577 | 577 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -587,12 +587,12 @@ discard block |
||
587 | 587 | |
588 | 588 | |
589 | 589 | /** |
590 | - * [changeWalletPasscode] |
|
591 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
592 | - * @param string $old_passcode [Mandatory - Wallet's Old Passcode] |
|
593 | - * @param string $passcode [Mandatory - Wallet's Passcode] |
|
594 | - * @return object |
|
595 | - */ |
|
590 | + * [changeWalletPasscode] |
|
591 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
592 | + * @param string $old_passcode [Mandatory - Wallet's Old Passcode] |
|
593 | + * @param string $passcode [Mandatory - Wallet's Passcode] |
|
594 | + * @return object |
|
595 | + */ |
|
596 | 596 | public function changeWalletPasscode(string $reference_code, string $old_passcode, string $passcode){ |
597 | 597 | if(!$reference_code){ |
598 | 598 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | |
622 | 622 | |
623 | 623 | /** |
624 | - * [getWallets] |
|
625 | - * @return object |
|
626 | - */ |
|
624 | + * [getWallets] |
|
625 | + * @return object |
|
626 | + */ |
|
627 | 627 | public function getWallets(){ |
628 | 628 | |
629 | 629 | $url = "/wallets"; |
@@ -636,10 +636,10 @@ discard block |
||
636 | 636 | |
637 | 637 | |
638 | 638 | /** |
639 | - * [setWalletStatus] |
|
640 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
641 | - * @return object |
|
642 | - */ |
|
639 | + * [setWalletStatus] |
|
640 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
641 | + * @return object |
|
642 | + */ |
|
643 | 643 | public function setWalletStatus(string $reference_code){ |
644 | 644 | if(!$reference_code){ |
645 | 645 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -655,14 +655,14 @@ discard block |
||
655 | 655 | |
656 | 656 | |
657 | 657 | /** |
658 | - * [withdrawFromWallet] |
|
659 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
660 | - * @param array $client_data [Mandatory - Client Data] |
|
661 | - * Required fields - 'settlement_bank', 'account_number' |
|
662 | - * @param string $amount [Mandatory - Amount to send] |
|
663 | - * @param string $passcode [Mandatory - Wallet's Passcode] |
|
664 | - * @return object |
|
665 | - */ |
|
658 | + * [withdrawFromWallet] |
|
659 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
660 | + * @param array $client_data [Mandatory - Client Data] |
|
661 | + * Required fields - 'settlement_bank', 'account_number' |
|
662 | + * @param string $amount [Mandatory - Amount to send] |
|
663 | + * @param string $passcode [Mandatory - Wallet's Passcode] |
|
664 | + * @return object |
|
665 | + */ |
|
666 | 666 | public function withdrawFromWallet(string $reference_code, array $client_data, string $amount, string $passcode){ |
667 | 667 | if(!$reference_code){ |
668 | 668 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | $required_values = ['settlement_bank', 'account_number']; |
673 | 673 | |
674 | 674 | if(!array_keys_exist($client_data, $required_values)){ |
675 | - throw new RequiredValuesMissing("Missing required values :("); |
|
675 | + throw new RequiredValuesMissing("Missing required values :("); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | if(!$amount){ |
@@ -700,13 +700,13 @@ discard block |
||
700 | 700 | |
701 | 701 | |
702 | 702 | /** |
703 | - * [getWalletTransactions] |
|
704 | - * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
705 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
706 | - * @param string $start [Format - DD/MM/YYYY] |
|
707 | - * @param string $end [Format - DD/MM/YYYY] |
|
708 | - * @return object |
|
709 | - */ |
|
703 | + * [getWalletTransactions] |
|
704 | + * @param string $reference_code [Mandatory - Wallet's Reference Code] |
|
705 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
706 | + * @param string $start [Format - DD/MM/YYYY] |
|
707 | + * @param string $end [Format - DD/MM/YYYY] |
|
708 | + * @return object |
|
709 | + */ |
|
710 | 710 | public function getWalletTransactions(string $reference_code, $period, $start = null, $end = null){ |
711 | 711 | if(!$reference_code){ |
712 | 712 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -728,13 +728,13 @@ discard block |
||
728 | 728 | |
729 | 729 | |
730 | 730 | /** |
731 | - * [addProduct] |
|
732 | - * @param string $name [Mandatory - Product's name] |
|
733 | - * @param string $description [Mandatory - Product's description] |
|
734 | - * @param string $unit_cost [Mandatory - Product's unit cost] |
|
735 | - * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
736 | - * @return object |
|
737 | - */ |
|
731 | + * [addProduct] |
|
732 | + * @param string $name [Mandatory - Product's name] |
|
733 | + * @param string $description [Mandatory - Product's description] |
|
734 | + * @param string $unit_cost [Mandatory - Product's unit cost] |
|
735 | + * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
736 | + * @return object |
|
737 | + */ |
|
738 | 738 | public function addProduct(string $name, string $description, string $unit_cost, string $type){ |
739 | 739 | if(!$name){ |
740 | 740 | throw new IsNull("Error Processing Request - Null/Invalid name"); |
@@ -774,10 +774,10 @@ discard block |
||
774 | 774 | |
775 | 775 | |
776 | 776 | /** |
777 | - * [getProduct] |
|
778 | - * @param int $product_id [Mandatory - Product ID] |
|
779 | - * @return object |
|
780 | - */ |
|
777 | + * [getProduct] |
|
778 | + * @param int $product_id [Mandatory - Product ID] |
|
779 | + * @return object |
|
780 | + */ |
|
781 | 781 | public function getProduct($product_id){ |
782 | 782 | if(!$product_id){ |
783 | 783 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); |
@@ -793,14 +793,14 @@ discard block |
||
793 | 793 | |
794 | 794 | |
795 | 795 | /** |
796 | - * [editProduct] |
|
797 | - * @param string $product_id [Mandatory - Product ID] |
|
798 | - * @param array $product_data [description] |
|
799 | - * @return object |
|
800 | - */ |
|
796 | + * [editProduct] |
|
797 | + * @param string $product_id [Mandatory - Product ID] |
|
798 | + * @param array $product_data [description] |
|
799 | + * @return object |
|
800 | + */ |
|
801 | 801 | public function editProduct($product_id, array $product_data){ |
802 | 802 | if(!$product_id){ |
803 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
803 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | //Validate Type |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
815 | 815 | } |
816 | 816 | |
817 | - $url = "/products/{$product_id}"; |
|
817 | + $url = "/products/{$product_id}"; |
|
818 | 818 | |
819 | - // Mandatory fields |
|
820 | - $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
819 | + // Mandatory fields |
|
820 | + $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
821 | 821 | |
822 | 822 | if(!array_keys_exist($product_data, $required_values)){ |
823 | - throw new RequiredValuesMissing("Missing required values :("); |
|
823 | + throw new RequiredValuesMissing("Missing required values :("); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | return $this->sendRequest('put', $url, ['form_params' => $product_data]); |
@@ -830,9 +830,9 @@ discard block |
||
830 | 830 | |
831 | 831 | |
832 | 832 | /** |
833 | - * [getProducts] |
|
834 | - * @return object |
|
835 | - */ |
|
833 | + * [getProducts] |
|
834 | + * @return object |
|
835 | + */ |
|
836 | 836 | public function getProducts(){ |
837 | 837 | $url = "/products"; |
838 | 838 | |
@@ -843,10 +843,10 @@ discard block |
||
843 | 843 | |
844 | 844 | |
845 | 845 | /** |
846 | - * [deleteProduct] |
|
847 | - * @param $product_id [Mandatory - Product ID] |
|
848 | - * @return object |
|
849 | - */ |
|
846 | + * [deleteProduct] |
|
847 | + * @param $product_id [Mandatory - Product ID] |
|
848 | + * @return object |
|
849 | + */ |
|
850 | 850 | public function deleteProduct($product_id){ |
851 | 851 | if(!$product_id){ |
852 | 852 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
@@ -860,12 +860,12 @@ discard block |
||
860 | 860 | |
861 | 861 | |
862 | 862 | /** |
863 | - * [sendRequest] |
|
864 | - * @param string $method [Mandatory - request method <get | post | put | delete> ] |
|
865 | - * @param string $url [Mandatory - url to send request to] |
|
866 | - * @param array $params [data to post to request url] |
|
867 | - * @return object |
|
868 | - */ |
|
863 | + * [sendRequest] |
|
864 | + * @param string $method [Mandatory - request method <get | post | put | delete> ] |
|
865 | + * @param string $url [Mandatory - url to send request to] |
|
866 | + * @param array $params [data to post to request url] |
|
867 | + * @return object |
|
868 | + */ |
|
869 | 869 | public function sendRequest($method, $url, $params=[]) |
870 | 870 | { |
871 | 871 | try{ |