|
@@ 461-492 (lines=32) @@
|
| 458 |
|
* @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
| 459 |
|
* @return object |
| 460 |
|
*/ |
| 461 |
|
public function addPayment(string $reference_code, string $due_date, string $amount, string $channel){ |
| 462 |
|
if(!$reference_code){ |
| 463 |
|
throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
| 464 |
|
} |
| 465 |
|
|
| 466 |
|
if(!$due_date){ |
| 467 |
|
throw new IsNullOrInvalid("Error Processing Request - Null/Invalid date"); |
| 468 |
|
} |
| 469 |
|
|
| 470 |
|
if(!$amount){ |
| 471 |
|
throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount"); |
| 472 |
|
} |
| 473 |
|
|
| 474 |
|
$valid_channels = ["Cash", "BankTransfer", "POS", "Cheque"]; |
| 475 |
|
|
| 476 |
|
if(!$channel){ |
| 477 |
|
throw new IsNull("Error Processing Request - Null/Invalid amount"); |
| 478 |
|
}elseif (!in_array(ucfirst($channel), $valid_channels)) { |
| 479 |
|
throw new IsInvalid("Invalid Channel - Cash, BankTransfer, POS or Cheque"); |
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
$url = "/payments"; |
| 483 |
|
|
| 484 |
|
$post_data = [ |
| 485 |
|
'reference_code' => $reference_code, |
| 486 |
|
'date' => $due_date, |
| 487 |
|
'amount' => $amount, |
| 488 |
|
'channel' => $channel |
| 489 |
|
]; |
| 490 |
|
|
| 491 |
|
return $this->sendRequest('post', $url, ['form_params' => $post_data]); |
| 492 |
|
} |
| 493 |
|
|
| 494 |
|
|
| 495 |
|
|
|
@@ 738-770 (lines=33) @@
|
| 735 |
|
* @param string $type [Mandatory - Product type 'product' or 'service'] |
| 736 |
|
* @return object |
| 737 |
|
*/ |
| 738 |
|
public function addProduct(string $name, string $description, string $unit_cost, string $type){ |
| 739 |
|
if(!$name){ |
| 740 |
|
throw new IsNull("Error Processing Request - Null/Invalid name"); |
| 741 |
|
} |
| 742 |
|
|
| 743 |
|
if(!$description){ |
| 744 |
|
throw new IsNull("Error Processing Request - Null/Invalid description"); |
| 745 |
|
} |
| 746 |
|
|
| 747 |
|
if(!$unit_cost){ |
| 748 |
|
throw new IsNull("Error Processing Request - Null/Invalid unit_cost"); |
| 749 |
|
} |
| 750 |
|
|
| 751 |
|
//Validate Product Type |
| 752 |
|
$valid_product_type = ["product", "service"]; |
| 753 |
|
|
| 754 |
|
if(!$type){ |
| 755 |
|
throw new IsNull("Error Processing Request - Null/Invalid type"); |
| 756 |
|
}elseif (!in_array(strtolower($type), $valid_product_type)) { |
| 757 |
|
throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
| 758 |
|
} |
| 759 |
|
|
| 760 |
|
$url = "/products"; |
| 761 |
|
|
| 762 |
|
$post_data = [ |
| 763 |
|
'name' => $name, |
| 764 |
|
'description' => $description, |
| 765 |
|
'unit_cost' => $unit_cost, |
| 766 |
|
'type' => $type |
| 767 |
|
]; |
| 768 |
|
|
| 769 |
|
return $this->sendRequest('post', $url, ['form_params' => $post_data]); |
| 770 |
|
} |
| 771 |
|
|
| 772 |
|
|
| 773 |
|
|