The com.innovaphone.working.client api enables apps to start and stop the working time for a given user.
The app service finds and connects to the right Service API:
class IService* service = NULL;
class AppSession* session = NULL;
for (auto pbxsession : app->pbxSessions) { //Look for the right app service
if (pbxsession->services) {
service = pbxsession->services->GetService("com.innovaphone.working.client");
session = pbxsession;
if (service) break;
}
}
//If found then connect the appwebsocket client
if (service) this->awsClient->Connect(service->GetWebsocketUrl(), service->GetName(), session->services->CreateAuthenticator(), false);
else this->awsClient->Close();
Callback when the appwebsocket client has been connected, so you can start sending messages.
void App::AppWebsocketClientConnectComplete(class IAppWebsocketClient* appWebsocketClient)
{
char sb[200];
class json_io send(sb);
word base = send.add_object(JSON_ID_ROOT, 0);
send.add_string(base, "mt", "StopWorkingTime");
send.add_string(base, "sip", "test_user");
send.add_string(base, "api", "--innovaphone-client-working-api");
this->awsClient->MessageSend(send, sb);
this->awsClient->MessageComplete();
}
Function where the answers from the Working Client API are received.
void App::AppWebsocketClientMessage(class IAppWebsocketClient* appWebsocketClient, class json_io& msg, word base, const char* mt, const char* src)
{
if (!strcmp(mt, "StopWorkingTimeResult")) { //Manage the answers from the Working Client API
...
}
...
}
If not already started, it starts the working time of the user.
| string sip | The SIP of the user. |
| string api | "--innovaphone-client-working-api" |
| string label | "Optional: The textvalue for the label of this time" |
| string time | Optional: epoch milliseconds to import/back-date a start instead of using the current time. If an already open time entry overlaps this timestamp, the import is rejected (see StartWorkingTimeResult). |
Answer to the start of the working time of an user.
| string result | "ok", "failed" or "overlap". "overlap" is only returned for an import (time given) whose timestamp falls within an already existing time entry (e.g. an old entry that was never stopped); the import is rejected in that case. |
| number overlapStart | Only present when result is "overlap": start (epoch milliseconds) of the blocking time entry. |
| number overlapStop | Only present when result is "overlap": stop (epoch milliseconds) of the blocking time entry, or null if that entry is still open. |
If not already stopped, it stops the working time of the user.
| string sip | The SIP of the user. |
| string api | "--innovaphone-client-working-api" |
| boolean confirmed | "Optional: true, if the time should be marked as confirmed. No editing in the Working User App is possible than. |
| string time | Optional: epoch milliseconds to import/back-date a stop instead of using the current time. Closes the latest open time entry with a start before this timestamp. |
Answer to the stop of the working time of an user.
| string result | "ok" or "failed". |
Check the status of the given user.
| string sip | The SIP of the user. |
| string api | "--innovaphone-client-working-api" |
Answer to check the status of an user.
| string state | "started" or "stopped". |
Retrieves all labels defined in the Working App.
| string api | "--innovaphone-client-working-api" |
Response containing all available labels.
| Array result | Array of label names, e.g. "result":["Home Office","School Day","Business Trip"] |
Retrieves the target hours, worked hours, and remaining hours for the current day of the specified user.
| string sip | The SIP of the user. |
| string api | "--innovaphone-client-working-api" |
Response containing today's working time information.
| string targetHours | Target hours in decimal hours format. |
| string workedHours | Worked hours in decimal hours format. |
| string remainingHours | Remaining hours in decimal hours format. |
Retrieves the target hours, worked hours, and remaining hours for the given month of the specified user.
| string sip | The SIP of the user. |
| stringmonth | Optional: The number of the month (e.g. "1" for January). If no month is given, the actual month is taken" |
| stringyear | >Optional: The number of the month (e.g. "2026"). If no year is given, the actual year is taken" |
| string api | "--innovaphone-client-working-api" |
Response containing month's working time information.
| string targetHours | Target hours in decimal hours format. |
| string workedHours | Worked hours in decimal hours format. |
| string remainingHours | Remaining hours in decimal hours format. |
| string month | The requested month |
| string year | The requested year |
Retrieves the overtime in hours of the specified user.
| string sip | The SIP of the user. |
| string api | "--innovaphone-client-working-api" |
Response containing the overtime in hours of the specified user.
| string sip | The sip of the requested user |
| string overtime | The value of hours |
Retrieves the absences of the specified user.
| string sip | The SIP of the user. |
| string month | Optional: The requested month |
| string year | Optional: The requested year |
| string api | "--innovaphone-client-working-api" |
Response containing the absences with dates of the specified user.
| array result | Array with objects for each day: start (formatted as "DD.MM.YYYY"), duration, type. |
| string sip | The SIP of the user. |
| string month | The requested month |
| string year | The requested year |