com.innovaphone.working.client

The com.innovaphone.working.client api enables apps to start and stop the working time for a given user.

Summary

GetService
AppWebsocketClientConnectComplete
AppWebsocketClientMessage
Messages send to the service
Messages received by the service

GetService

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();

AppWebsocketClientConnectComplete

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();
}

AppWebsocketClientMessage

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
        ...
    }
    ...
}

Messages send to the service

StartWorkingTime
StopWorkingTime
GetStatus
GetLabels
GetLabels
GetToday
GetMonth
GetOverTime
GetAbsences

Messages received by the service

StartWorkingTimeResult
StopWorkingTimeResult
GetStatusResult
GetLabelsResult
GetTodayResult
GetMonthResult
GetOverTimeResult
GetAbsencesResult

StartWorkingTime

If not already started, it starts the working time of the user.

Parameters

string sipThe SIP of the user.
string api"--innovaphone-client-working-api"
string label"Optional: The textvalue for the label of this time"
string timeOptional: 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).

StartWorkingTimeResult

Answer to the start of the working time of an user.

Parameters

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 overlapStartOnly present when result is "overlap": start (epoch milliseconds) of the blocking time entry.
number overlapStopOnly present when result is "overlap": stop (epoch milliseconds) of the blocking time entry, or null if that entry is still open.

StopWorkingTime

If not already stopped, it stops the working time of the user.

Parameters

string sipThe 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 timeOptional: 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.

StopWorkingTimeResult

Answer to the stop of the working time of an user.

Parameters

string result "ok" or "failed".

GetStatus

Check the status of the given user.

Parameters

string sipThe SIP of the user.
string api"--innovaphone-client-working-api"

GetStatusResult

Answer to check the status of an user.

Parameters

string state "started" or "stopped".

GetLabels

Retrieves all labels defined in the Working App.

Parameters

string api"--innovaphone-client-working-api"

GetLabelsResult

Response containing all available labels.

Parameters

Array result Array of label names, e.g. "result":["Home Office","School Day","Business Trip"]

GetToday

Retrieves the target hours, worked hours, and remaining hours for the current day of the specified user.

Parameters

string sipThe SIP of the user.
string api"--innovaphone-client-working-api"

GetTodayResult

Response containing today's working time information.

Parameters

string targetHoursTarget hours in decimal hours format.
string workedHoursWorked hours in decimal hours format.
string remainingHoursRemaining hours in decimal hours format.

GetMonth

Retrieves the target hours, worked hours, and remaining hours for the given month of the specified user.

Parameters

string sipThe SIP of the user.
stringmonthOptional: 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"

GetMonthResult

Response containing month's working time information.

Parameters

string targetHoursTarget hours in decimal hours format.
string workedHoursWorked hours in decimal hours format.
string remainingHoursRemaining hours in decimal hours format.
string monthThe requested month
string yearThe requested year

GetOverTime

Retrieves the overtime in hours of the specified user.

Parameters

string sipThe SIP of the user.
string api"--innovaphone-client-working-api"

GetOverTimeResult

Response containing the overtime in hours of the specified user.

Parameters

string sipThe sip of the requested user
string overtimeThe value of hours

GetAbsences

Retrieves the absences of the specified user.

Parameters

string sipThe SIP of the user.
string monthOptional: The requested month
string yearOptional: The requested year
string api"--innovaphone-client-working-api"

GetAbsencesResult

Response containing the absences with dates of the specified user.

Parameters

array resultArray with objects for each day: start (formatted as "DD.MM.YYYY"), duration, type.
string sipThe SIP of the user.
string monthThe requested month
string yearThe requested year