(2024.2) Calling API Logic
call
Custom Logic can invoke the API endpoints by using the call function. This function allows passing data from the logic to the API endpoint. When invoking this from the Custom API this feature call functions will follow the same API permissions granted the API Key that is being used.
array call(string $method, array $params, bool $commitOnSuccess)
Parameters
$method The callable method name. The available callable methods:
API Write Calls: saveCable, saveContact, saveEquipment, saveGla, saveLocation, saveService, and saveServiceDesk
API Report Rendering: renderCustomReport and renderCableViewPath
$params An array of key payload data that is passed to the other API calling function.
$commitOnSuccess A True/False value telling PCR-360 whether to commit the database transaction successful call or not. This only applies to the API Write Calls. When True, if a call is successful, PCR-360 will commit the change. When not provided with a True, the function will assume False is desired, and if an error occurs down the line, any successful changes will be rolled-back.
This parameter is ignored for Custom Validations.
Return Values
The function returns a result array containing 'data' which specifies the outcome of the call. For a successful call to saveServiceDesk, this array contain the Service Desk item/action that was created. For a Report Rendering call the return will contain an array containing the rendered report in the specified format.
Example Creating/Updating Service Desk
In this example, the $payload array contains all the parameters required to create a Service Order and Action
$result = $this->call("saveServiceDesk", $payload);
$response["servicedesk_number"] = $result["data"];
Example Creating a New Contact
In this example, the Contact API is being invoked via the Custom API endpoint
$contact_request = [
"customer_number" => "ABC123",
"last_name" => "Help",
"first_name" => "PCR",
"email" => "help@pcr.com",
"email_directory" => 1,
"phone_number" => "616-555-1212",
"phone_primary" => 1,
"phone_type" => 1234, // RECID from Lists
"phone_directory" => 1,
"status" => 1,
"contact_directory" => 1,
"contact_types" => "CUSTOMER",
];
$result_contact = $this->call("saveContact", $contact_request);
if($result_contact["status"] == "success") {
$response["contact"] = $result_contact["data"];
}
Example: Rendering a Custom Report
Example: Rendering a Cable View Path Report