### Get all users (Python) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Retrieves a list of all users from the ZelloWork network and prints their names. ```python # Python – get all users users = api.get_users() for user in users.get("users", []): print(user["name"]) ``` -------------------------------- ### List or Get Channels (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Retrieves a paginated list of all channels or details for a specific channel by name. ```php // PHP – list all channels (paginated) if ($api->getChannels("", 25, 0)) { foreach ($api->data["channels"] as $ch) { echo $ch["name"] . " (users: " . $ch["users_online"] . ")\n"; } } // PHP – get a specific channel if ($api->getChannels("Operations")) { print_r($api->data["channels"]); } ``` -------------------------------- ### Get Channels (Swift) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Fetches a list of channels and iterates through them to print their names. ```swift // Swift api.getChannels { success, response, error in if success, let channels = response?["channels"] as? [[String: Any]] { channels.forEach { print($0["name"] ?? "") } } } ``` -------------------------------- ### Get a specific user in a channel (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Retrieves details for a specific user within a given channel. Handles and displays errors if the user or channel is not found. ```php // PHP – get a specific user in a channel if ($api->getUsers("john_doe", false, 0, 0, "Field Team")) { print_r($api->data["users"]); } else { echo "Error: [{$api->errorCode}] {$api->errorDescription}"; } ``` -------------------------------- ### Get a specific user (Python) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Retrieves the data for a single, specific user by their username. ```python # Python – get a specific user user_data = api.get_user("john_doe") ``` -------------------------------- ### Retrieve dispatch analytics metrics (Python) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Fetches analytics data for a given UTC time range, including dispatch metrics. This method is exclusive to the Python library. Ensure the start and end times are provided as Unix timestamps. ```python # Python import time # Pull analytics for a 24-hour window start = 1660712400 # Unix timestamp end = 1660798799 data = api.get_analytics(start_time=start, end_time=end) # Output: {"status": "OK", "code": "200", ...metrics...} print(json.dumps(data, indent=2)) ``` -------------------------------- ### Create User (Python) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Adds a new user with optional fields. The response indicates success or failure. ```python # Python – create a user with optional fields result = api.add_user( name="jane_doe", password="initialPass123", email="jane@example.com", full_name="Jane Doe", job="Field Technician", admin=False, limited=False ) # {"status": "OK", "code": "200"} print(result) ``` -------------------------------- ### Authenticate with ZelloWork Server (Python) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Authenticates with the ZelloWork server. This snippet shows how to initialize the API client and perform the login operation. ```python from utils import zellowork_api api = zellowork_api(api_key="MY_API_KEY", network="mynetwork") print(api.get_token()) # fetches token + sid print(api.login("admin", "secret")) # Output: "Login successful!" ``` -------------------------------- ### Create or Update User (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Creates a new user or updates an existing one. Use `add: "true"` for creation-only mode. ```php // PHP – create a new user $success = $api->saveUser([ "name" => "jane_doe", "password" => md5("initialPass123"), "email" => "jane@example.com", "full_name" => "Jane Doe", "job" => "Field Technician", "admin" => "false", "limited_access" => "false", "add" => "true" // fail if already exists ]); if (!$success) { echo "Error: [{$api->errorCode}] {$api->errorDescription}"; } else { echo "User created."; } ``` -------------------------------- ### List Channel Roles Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Returns the role definitions for a given channel, including their permissions and which roles they can talk to. Requires the channel name. ```php // PHP if ($api->getChannelsRoles("Operations")) { foreach ($api->data["roles"] as $role) { echo $role["name"] . "\n"; } } ``` ```java // Java api.getChannelsRoles("Operations", (success, response, exception) -> { if (success) System.out.println(response.toString()); }); ``` -------------------------------- ### Authenticate with ZelloWork Server (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Authenticates with the ZelloWork server using provided credentials. Stores the session ID for reuse. Demonstrates how to instantiate the API and handle authentication failures. ```php require("./zello_server_api.class.php"); $api = new ZelloServerAPI("https://mynetwork.zellowork.com", "MY_API_KEY"); if (!$api->auth("admin", "secret")) { die("Login failed: [{$api->errorCode}] {$api->errorDescription}"); } // Persist the session ID for reuse across requests $sid = $api->sid; echo "Logged in. SID: $sid"; // Reuse an existing SID without re-authenticating $api2 = new ZelloServerAPI("https://mynetwork.zellowork.com", "MY_API_KEY", $sid); ``` -------------------------------- ### List all users (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Retrieves and lists all users on the ZelloWork network. Iterates through the user data and prints their name and email. ```php // PHP – list all users if ($api->getUsers()) { foreach ($api->data["users"] as $user) { echo $user["name"] . " - " . $user["email"] . "\n"; } } ``` -------------------------------- ### Async/await error handling with exception handling (C#) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Illustrates asynchronous error handling in C# using async/await, including authentication checks, user saving, and general exception catching. It also logs the last request URL for debugging. ```csharp // C# — async/await with exception handling var api = new ZelloAPI("mynetwork.zellowork.com", "MY_API_KEY"); try { var authResult = await api.Authenticate("admin", "secret"); if (!authResult.Success) { Console.WriteLine($"Auth error: {authResult.Response?["status"]}"); return; } var result = await api.SaveUser(new Dictionary { { "name", "bob" }, { "password", "hashedpass" }, { "add", "true" } }); if (!result.Success) { Console.WriteLine($"Save error: {result.Response?["status"]} (code: {result.Response?["code"]})"); Console.WriteLine($"Last URL: {api.LastURL}"); } } catch (Exception ex) { Console.WriteLine($"Exception: {ex.Message}"); } finally { await api.Logout(); } ``` -------------------------------- ### Comprehensive error handling with session reuse (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Demonstrates robust error handling in PHP, including authentication, user saving with specific error code checks, and session management using file storage for the Session ID. ```php // PHP — comprehensive error handling with session reuse $api = new ZelloServerAPI("https://mynetwork.zellowork.com", "MY_API_KEY"); if (!$api->auth("admin", "secret")) { error_log("Auth failed [{"$api->errorCode}"]: {$api->errorDescription}"); error_log("Request URL: {$api->lastUrl}"); exit(1); } // Store SID to avoid re-auth on next request file_put_contents("/tmp/zello_sid.txt", $api->sid); if (!$api->saveUser(["name" => "bob", "password" => md5("pass"), "add" => "true"] D)) { if ($api->errorCode === 16) { echo "User already exists.\n"; } else { echo "Unexpected error [{"$api->errorCode}"]: {$api->errorDescription}\n"; echo "Request: {$api->lastUrl}\n"; } } $api->logout(); ``` -------------------------------- ### Assign users to a role in a channel (Java) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Assigns existing network users to a specific role within a channel using a callback for success or error. Requires channel name, role name, and a list of usernames. ```java ArrayList drivers = new ArrayList<>(Arrays.asList("jane_doe", "john_smith")); api.addToChannelRole("Operations", "Driver", drivers, (success, response, exception) -> System.out.println(success ? "Assigned." : "Error: " + response) ); ``` -------------------------------- ### List Users in a Channel (Java) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Retrieves a list of users within a specified channel. Allows for pagination and filtering. ```java // Java – list first 50 users in a channel api.getUsers(null, false, 50, 0, "Field Team", new ResultCompletionHandler() { @Override public void onResult(boolean success, JSONObject response, Exception exception) { if (success) { System.out.println(response.toString()); } } }); ``` -------------------------------- ### saveUser / SaveUser / add_user Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Creates a new user or updates an existing one. The `name` and `password` (MD5 hash) fields are required when creating. Setting `add` to `"true"` forces creation-only mode and returns an error if the user already exists. ```APIDOC ## saveUser / SaveUser / add_user — Create or update a user ### Description Creates a new user or updates an existing one. The `name` and `password` (MD5 hash) fields are required when creating. Setting `add` to `"true"` forces creation-only mode and returns an error if the user already exists. ### PHP Example ```php // PHP – create a new user $success = $api->saveUser([ "name" => "jane_doe", "password" => md5("initialPass123"), "email" => "jane@example.com", "full_name" => "Jane Doe", "job" => "Field Technician", "admin" => "false", "limited_access" => "false", "add" => "true" // fail if already exists ]); if (!$success) { echo "Error: [{$api->errorCode}] {$api->errorDescription}"; } else { echo "User created."; } ``` ### Python Example ```python # Python – create a user with optional fields result = api.add_user( name="jane_doe", password="initialPass123", email="jane@example.com", full_name="Jane Doe", job="Field Technician", admin=False, limited=False ) # {"status": "OK", "code": "200"} print(result) ``` ### Java Example ```java // Java Map user = new HashMap<>(); user.put("name", "jane_doe"); user.put("password", MD5("initialPass123")); user.put("email", "jane@example.com"); user.put("full_name", "Jane Doe"); user.put("add", "true"); api.saveUser(user, new ResultCompletionHandler() { @Override public void onResult(boolean success, JSONObject response, Exception exception) { System.out.println(success ? "User created." : "Error: " + response); } }); ``` ### C# Example ```csharp // C# var user = new Dictionary { { "name", "jane_doe" }, { "password", MD5Hash("initialPass123") }, { "email", "jane@example.com" }, { "full_name", "Jane Doe" }, { "add", "true" } }; ZelloAPIResult result = await api.SaveUser(user); Console.WriteLine(result.Success ? "Created." : result.Response?["status"]?.ToString()); ``` ``` -------------------------------- ### Add Users to a Channel Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Adds one or more users to a specified channel. Check the return value for success or failure. ```php // PHP if (!$api->addToChannel("Operations", ["jane_doe", "john_smith"])) { echo "Error: [{$api->errorCode}] {$api->errorDescription}"; } else { echo "Users added to channel."; } ``` ```java // Java ArrayList users = new ArrayList<>(Arrays.asList("jane_doe", "john_smith")); api.addToChannel("Operations", users, (success, response, exception) -> System.out.println(success ? "Added." : "Error: " + response) ); ``` -------------------------------- ### Add Channel (C#) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Asynchronously creates a new channel, indicating if it's a group channel and if it's hidden. ```csharp // C# ZelloAPIResult result = await api.AddChannel("Operations", true, false); Console.WriteLine(result.Success ? "Created." : result.Response?["status"]?.ToString()); ``` -------------------------------- ### Assign users to a role in a channel (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Assigns existing network users to a specific role within a channel. Requires the channel name, role name, and a list of usernames. ```php $api->addToChannelRole("Operations", "Driver", ["jane_doe", "john_smith"]); ``` -------------------------------- ### Authenticate with ZelloWork Server (C#) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Authenticates with the ZelloWork server asynchronously. Logs the session ID or error message upon completion. ```csharp var api = new ZelloAPI("mynetwork.zellowork.com", "MY_API_KEY"); ZelloAPIResult result = await api.Authenticate("admin", "secret"); if (result.Success) { Console.WriteLine("Authenticated. SID: " + api.SessionId); } else { Console.WriteLine("Error: " + result.Response?["status"]); } ``` -------------------------------- ### Save User (C#) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Creates or updates a user using a dictionary of user properties. The `add` field forces creation. ```csharp // C# var user = new Dictionary { { "name", "jane_doe" }, { "password", MD5Hash("initialPass123") }, { "email", "jane@example.com" }, { "full_name", "Jane Doe" }, { "add", "true" } }; ZelloAPIResult result = await api.SaveUser(user); Console.WriteLine(result.Success ? "Created." : result.Response?["status"]?.ToString()); ``` -------------------------------- ### List Channel Roles Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Returns the role definitions for a given channel, including their permissions and which roles they can talk to. ```APIDOC ## getChannelsRoles / GetChannelsRoles — List roles defined in a channel Returns the role definitions for a given channel, including their permissions and which roles they can talk to. ### Method Not specified (assumed to be a method call on an API object) ### Parameters * **channelName** (string) - Required - The name of the channel to retrieve roles from. ### Request Example (PHP) ```php if ($api->getChannelsRoles("Operations")) { foreach ($api->data["roles"] as $role) { echo $role["name"] . "\n"; } } ``` ### Request Example (Java) ```java api.getChannelsRoles("Operations", (success, response, exception) -> { if (success) System.out.println(response.toString()); }); ``` ``` -------------------------------- ### Authenticate with ZelloWork Server (Java) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Authenticates with the ZelloWork server using a callback for handling the result. Displays the session ID upon successful authentication. ```java ZelloAPI api = new ZelloAPI("mynetwork.zellowork.com", "MY_API_KEY"); api.authenticate("admin", "secret", new ResultCompletionHandler() { @Override public void onResult(boolean success, JSONObject response, Exception exception) { if (success) { System.out.println("Authenticated. SID: " + api.sessionId); } else { System.out.println("Auth failed: " + response); } } }); ``` -------------------------------- ### Save User (Java) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Saves user information, potentially creating or updating an existing user. Requires a map of user properties. ```java // Java Map user = new HashMap<>(); user.put("name", "jane_doe"); user.put("password", MD5("initialPass123")); user.put("email", "jane@example.com"); user.put("full_name", "Jane Doe"); user.put("add", "true"); api.saveUser(user, new ResultCompletionHandler() { @Override public void onResult(boolean success, JSONObject response, Exception exception) { System.out.println(success ? "User created." : "Error: " + response); } }); ``` -------------------------------- ### Add Users to Multiple Channels Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Batch-adds a set of users to multiple channels in a single API call. ```APIDOC ## addToChannels / AddToChannels — Add users to multiple channels at once Batch-adds a set of users to multiple channels in a single API call. ### Method Not specified (assumed to be a method call on an API object) ### Parameters * **channels** (array of strings) - Required - A list of channel names to add users to. * **users** (array of strings) - Required - A list of user names to add to the channels. ### Request Example (PHP) ```php $api->addToChannels( ["Operations", "Field Team", "Dispatch"], ["jane_doe", "john_smith"] ); ``` ### Request Example (C#) ```csharp var channels = new ArrayList { "Operations", "Field Team" }; var users = new ArrayList { "jane_doe", "john_smith" }; await api.AddToChannels(channels, users); ``` ``` -------------------------------- ### Add Users to Multiple Channels Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Batch-adds a set of users to multiple channels in a single API call. This is efficient for managing multiple memberships simultaneously. ```php // PHP $api->addToChannels( ["Operations", "Field Team", "Dispatch"], ["jane_doe", "john_smith"] ); ``` ```csharp // C# var channels = new ArrayList { "Operations", "Field Team" }; var users = new ArrayList { "jane_doe", "john_smith" }; await api.AddToChannels(channels, users); ``` -------------------------------- ### Add Users to Channel Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Adds one or more users to the specified channel. ```APIDOC ## addToChannel / AddToChannel — Add users to a channel Adds one or more users to the specified channel. ### Method Not specified (assumed to be a method call on an API object) ### Parameters * **channelName** (string) - Required - The name of the channel to add users to. * **users** (array of strings) - Required - A list of user names to add to the channel. ### Request Example (PHP) ```php if (!$api->addToChannel("Operations", ["jane_doe", "john_smith"])) { echo "Error: [{$api->errorCode}] {$api->errorDescription}"; } else { echo "Users added to channel."; } ``` ### Request Example (Java) ```java ArrayList users = new ArrayList<>(Arrays.asList("jane_doe", "john_smith")); api.addToChannel("Operations", users, (success, response, exception) -> System.out.println(success ? "Added." : "Error: " + response) ); ``` ``` -------------------------------- ### Authenticate with ZelloWork Server (Swift) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Authenticates with the ZelloWork server using a closure to handle the response. Prints the session ID or error details. ```swift let api = ZelloAPI(host: "mynetwork.zellowork.com", apiKey: "MY_API_KEY") api.authenticate("admin", password: "secret") { success, response, error in if success { print("Authenticated. SID: \(api.sessionId ?? "")") } else { print("Auth failed: \(String(describing: response))") } } ``` -------------------------------- ### Add Channel (Java) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Creates a new channel, specifying whether it is a group channel and if it should be hidden. ```java // Java api.addChannel("Operations", true, false, (success, response, exception) -> System.out.println(success ? "Channel created." : "Error: " + response) ); ``` -------------------------------- ### getChannels / GetChannels Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Returns a paginated list of all channels or details of a single named channel. ```APIDOC ## getChannels / GetChannels — List channels or retrieve a specific channel ### Description Returns a paginated list of all channels or details of a single named channel. ### PHP Example ```php // PHP – list all channels (paginated) if ($api->getChannels("", 25, 0)) { foreach ($api->data["channels"] as $ch) { echo $ch["name"] . " (users: " . $ch["users_online"] . ")\n"; } } // PHP – get a specific channel if ($api->getChannels("Operations")) { print_r($api->data["channels"]); } ``` ### Swift Example ```swift // Swift api.getChannels { success, response, error in if success, let channels = response?["channels"] as? [[String: Any]] { channels.forEach { print($0["name"] ?? "") } } } ``` ``` -------------------------------- ### Add Channel (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Creates a new channel, which can be a persistent group channel or a dynamic channel. Set `is_hidden` and `is_group` to create hidden group channels. ```php // PHP – group channel if (!$api->addChannel("Operations", true, false)) { echo "Error: [{$api->errorCode}] {$api->errorDescription}"; } else { echo "Channel created."; } // PHP – hidden group channel $api->addChannel("Executive Channel", true, true); ``` -------------------------------- ### Authentication and Session Management Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Authenticates with the ZelloWork server by retrieving a token, hashing the password, and logging in. The resulting Session ID (SID) is stored and used for subsequent requests, and can be persisted for reuse. ```APIDOC ## auth / authenticate — Authenticate with the ZelloWork server ### Description Retrieves a one-time token, constructs a hashed password (`md5(md5(password) + token + apiKey)`), and logs in with the admin credentials. On success, the Session ID is stored and used for all subsequent requests. The SID can be persisted and reused to avoid repeated logins. ### Method POST (implied by login process) ### Endpoint `/user/gettoken` and `/user/login` (implied) ### Request Body (Conceptual) - `username` (string) - Required - The admin username. - `password` (string) - Required - The admin password. - `token` (string) - Required - The one-time token obtained from `/user/gettoken`. - `apiKey` (string) - Required - The API key for the network. ### Response (Conceptual) - `sid` (string) - The Session ID for subsequent requests. ### Request Example ```php // PHP require("./zello_server_api.class.php"); $api = new ZelloServerAPI("https://mynetwork.zellowork.com", "MY_API_KEY"); if (!$api->auth("admin", "secret")) { die("Login failed: [".$api->errorCode."] ".$api->errorDescription); } // Persist the session ID for reuse across requests $sid = $api->sid; echo "Logged in. SID: $sid"; // Reuse an existing SID without re-authenticating $api2 = new ZelloServerAPI("https://mynetwork.zellowork.com", "MY_API_KEY", $sid); ``` ```python # Python from utils import zellowork_api api = zellowork_api(api_key="MY_API_KEY", network="mynetwork") print(api.get_token()) # fetches token + sid print(api.login("admin", "secret")) # Output: "Login successful!" ``` ```java // Java ZelloAPI api = new ZelloAPI("mynetwork.zellowork.com", "MY_API_KEY"); api.authenticate("admin", "secret", new ResultCompletionHandler() { @Override public void onResult(boolean success, JSONObject response, Exception exception) { if (success) { System.out.println("Authenticated. SID: " + api.sessionId); } else { System.out.println("Auth failed: " + response); } } }); ``` ```csharp // C# var api = new ZelloAPI("mynetwork.zellowork.com", "MY_API_KEY"); ZelloAPIResult result = await api.Authenticate("admin", "secret"); if (result.Success) { Console.WriteLine("Authenticated. SID: " + api.SessionId); } else { Console.WriteLine("Error: " + result.Response?["status"]); } ``` ```swift // Swift let api = ZelloAPI(host: "mynetwork.zellowork.com", apiKey: "MY_API_KEY") api.authenticate("admin", password: "secret") { success, response, error in if success { print("Authenticated. SID: \(api.sessionId ?? "")") } else { print("Auth failed: \(String(describing: response))") } } ``` ``` -------------------------------- ### User Management Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Lists all users on the network or retrieves details for a specific user. Supports filtering by channel and optionally returning gateway users. ```APIDOC ## getUsers / GetUsers — List users or retrieve a specific user ### Description Returns a paginated list of all users on the network, or details for a single user if a username is provided. Supports filtering by channel and optionally returning gateway users instead of regular users. ### Method GET (implied) ### Endpoint `/user/get` (implied for single user) `/user/list` (implied for multiple users) ### Parameters #### Query Parameters (Conceptual) - `username` (string) - Optional - The username of the user to retrieve. - `gateway` (boolean) - Optional - If true, returns gateway users. - `limit` (integer) - Optional - The maximum number of users to return. - `offset` (integer) - Optional - The number of users to skip. - `channel` (string) - Optional - Filters users by the specified channel. ### Response (Conceptual) - `users` (array) - A list of user objects, each containing fields like `name`, `email`, etc. ### Request Example ```php // PHP – list all users if ($api->getUsers()) { foreach ($api->data["users"] as $user) { echo $user["name"] . " - " . $user["email"] . "\n"; } } // PHP – get a specific user in a channel if ($api->getUsers("john_doe", false, 0, 0, "Field Team")) { print_r($api->data["users"]); } else { echo "Error: [".$api->errorCode."] ".$api->errorDescription; } ``` ```python # Python – get all users users = api.get_users() for user in users.get("users", []): print(user["name"]) # Python – get a specific user user_data = api.get_user("john_doe") ``` ``` -------------------------------- ### addChannel / AddChannel Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Creates a group channel (persistent, shared) or a dynamic channel. Set `is_hidden`/`isHidden` to `true` together with `is_group`/`isGroup` to create a hidden group channel not visible to regular users. ```APIDOC ## addChannel / AddChannel — Create a new channel ### Description Creates a group channel (persistent, shared) or a dynamic channel. Set `is_hidden`/`isHidden` to `true` together with `is_group`/`isGroup` to create a hidden group channel not visible to regular users. ### PHP Example ```php // PHP – group channel if (!$api->addChannel("Operations", true, false)) { echo "Error: [{$api->errorCode}] {$api->errorDescription}"; } else { echo "Channel created."; } // PHP – hidden group channel $api->addChannel("Executive Channel", true, true); ``` ### Java Example ```java api.addChannel("Operations", true, false, (success, response, exception) -> System.out.println(success ? "Channel created." : "Error: " + response) ); ``` ### C# Example ```csharp // C# ZelloAPIResult result = await api.AddChannel("Operations", true, false); Console.WriteLine(result.Success ? "Created." : result.Response?["status"]?.ToString()); ``` ``` -------------------------------- ### Logout from ZelloWork Server (C#) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Logs out from the ZelloWork server asynchronously. Reports success or failure of the logout operation. ```csharp ZelloAPIResult result = await api.Logout(); Console.WriteLine(result.Success ? "Logged out." : "Logout failed."); // api.SessionId is now null ``` -------------------------------- ### Remove Users from Multiple Channels Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Batch-removes a set of users from multiple channels in a single API call. Use this for efficient bulk user removal. ```php // PHP $api->removeFromChannels( ["Operations", "Field Team"], ["jane_doe", "john_smith"] ); ``` ```java // Java ArrayList channels = new ArrayList<>(Arrays.asList("Operations", "Field Team")); ArrayList users = new ArrayList<>(Arrays.asList("jane_doe", "john_smith")); api.removeFromChannels(channels, users, (success, response, exception) -> System.out.println(success ? "Removed." : "Error: " + response) ); ``` -------------------------------- ### Logout from ZelloWork Server (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Logs out from the ZelloWork server, terminating the current session. Handles and displays potential logout errors. ```php if (!$api->logout()) { echo "Logout error: {$api->errorCode} {$api->errorDescription}"; } else { echo "Logged out successfully."; // $api->sid is now empty } ``` -------------------------------- ### Create or Update Channel Role Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Defines a named role within a channel with fine-grained permissions. ```APIDOC ## saveChannelRole / SaveChannelRole — Create or update a channel role Defines a named role within a channel with fine-grained permissions: `listen_only`, `no_disconnect`, `allow_alerts`, and `to` (which other roles this role can transmit to). ### Method Not specified (assumed to be a method call on an API object) ### Parameters * **channelName** (string) - Required - The name of the channel where the role will be created or updated. * **roleName** (string) - Required - The name of the role. * **settings** (object) - Required - An object containing the role's permissions. * **listen_only** (boolean) - Optional - If true, users with this role can only listen. * **no_disconnect** (boolean) - Optional - If true, users with this role cannot be disconnected. * **allow_alerts** (boolean) - Optional - If true, users with this role can send alerts. * **to** (array of strings) - Optional - A list of role names that this role can transmit to. ### Request Example (PHP - create Dispatcher role) ```php $api->saveChannelRole("Operations", "Dispatcher", [ "listen_only" => false, "no_disconnect" => true, "allow_alerts" => true, "to" => [] ]); ``` ### Request Example (PHP - create Driver role using JSON string) ```php $api->saveChannelRole("Operations", "Driver", '{"listen_only":false,"no_disconnect":false,"allow_alerts":true,"to":["Dispatcher"]}' ); ``` ### Request Example (Swift) ```swift var dispatcherSettings: [String: AnyObject] = [ "listen_only": false as AnyObject, "no_disconnect": true as AnyObject, "allow_alerts": true as AnyObject, "to": [] as AnyObject ] api.saveChannelRole("Operations", roleName: "Dispatcher", settings: dispatcherSettings) { success, response, error in print("saveChannelRole Dispatcher: \(success)") } ``` ### Request Example (Python - direct HTTP) ```python import requests, json payload = { "settings": json.dumps({ "listen_only": False, "no_disconnect": True, "allow_alerts": True, "to": [] }) } resp = requests.post( f"https://mynetwork.zellowork.com/channel/saverole/channel/Operations/name/Dispatcher?sid={api.sid}", data=payload ) print(resp.json()) ``` ``` -------------------------------- ### Remove Users (Python) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Deletes specified users from the network. Includes verification by attempting to retrieve a deleted user. ```python # Python api.remove_users(["jane_doe", "temp_user"]) # Prints: "Successfully removed users" # Verify deletion resp = api.get_user("jane_doe") if resp["status"] == "User not found": print("jane_doe successfully deleted") ``` -------------------------------- ### addToChannelRole Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Assigns existing network users to a specific role within a channel. ```APIDOC ## addToChannelRole / AddToChannelRole — Assign users to a role in a channel ### Description Assigns existing network users to a specific role within a channel, enabling role-based PTT routing. ### Method POST (assumed, based on operation) ### Endpoint `/channels/{channel_name}/roles/{role_name}/users` (assumed, based on operation) ### Parameters #### Path Parameters - **channel_name** (string) - Required - The name of the channel. - **role_name** (string) - Required - The name of the role. #### Request Body - **users** (array of strings) - Required - A list of user IDs or names to assign to the role. ``` ```PHP $api->addToChannelRole("Operations", "Driver", ["jane_doe", "john_smith"]); ``` ```Java ArrayList drivers = new ArrayList<>(Arrays.asList("jane_doe", "john_smith")); api.addToChannelRole("Operations", "Driver", drivers, (success, response, exception) -> System.out.println(success ? "Assigned." : "Error: " + response) ); ``` -------------------------------- ### Create or Update Channel Role Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Defines or modifies a named role within a channel with specific permissions. Note the different ways to pass settings (array vs JSON string in PHP). ```php // PHP – create a Dispatcher role (can receive from Driver, cannot be disconnected) $api->saveChannelRole("Operations", "Dispatcher", [ "listen_only" => false, "no_disconnect" => true, "allow_alerts" => true, "to" => [] // Dispatcher does not initiate to any specific role ]); // PHP – create a Driver role using JSON string $api->saveChannelRole("Operations", "Driver", '{"listen_only":false,"no_disconnect":false,"allow_alerts":true,"to":["Dispatcher"]}' ); ``` ```swift // Swift var dispatcherSettings: [String: AnyObject] = [ "listen_only": false as AnyObject, "no_disconnect": true as AnyObject, "allow_alerts": true as AnyObject, "to": [] as AnyObject ] api.saveChannelRole("Operations", roleName: "Dispatcher", settings: dispatcherSettings) { success, response, error in print("saveChannelRole Dispatcher: \(success)") } ``` ```python # Python (direct HTTP — Python library does not wrap roles) import requests, json payload = { "settings": json.dumps({ "listen_only": False, "no_disconnect": True, "allow_alerts": True, "to": [] }) } resp = requests.post( f"https://mynetwork.zellowork.com/channel/saverole/channel/Operations/name/Dispatcher?sid={api.sid}", data=payload ) print(resp.json()) ``` -------------------------------- ### get_analytics Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Retrieves dispatch analytics metrics for a given UTC time range. ```APIDOC ## get_analytics — Retrieve dispatch analytics metrics ### Description Fetches analytics data for a given UTC time range. Returns dispatch metrics including call counts, durations, and context data. This method is only available in the Python library. ### Method GET (assumed, based on operation) ### Endpoint `/analytics` (assumed, based on operation) ### Parameters #### Query Parameters - **start_time** (integer) - Required - Unix timestamp for the start of the time range. - **end_time** (integer) - Required - Unix timestamp for the end of the time range. ### Response #### Success Response (200) - **status** (string) - "OK" on success. - **code** (string) - "200" on success. - **metrics** (object) - Contains various dispatch metrics. ``` ```Python import json # Pull analytics for a 24-hour window start = 1660712400 # Unix timestamp end = 1660798799 data = api.get_analytics(start_time=start, end_time=end) # Output: {"status": "OK", "code": "200", ...metrics...} print(json.dumps(data, indent=2)) ``` -------------------------------- ### Delete Users (Java) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Permanently removes users from the network using an ArrayList of usernames. ```java // Java ArrayList users = new ArrayList<>(Arrays.asList("jane_doe", "temp_user")); api.deleteUsers(users, (success, response, exception) -> System.out.println(success ? "Deleted." : "Error: " + response) ); ``` -------------------------------- ### Remove Users from Multiple Channels Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Batch-removes a set of users from multiple channels in a single API call. ```APIDOC ## removeFromChannels / RemoveFromChannels — Remove users from multiple channels Batch-removes a set of users from multiple channels in a single API call. ### Method Not specified (assumed to be a method call on an API object) ### Parameters * **channels** (array of strings) - Required - A list of channel names to remove users from. * **users** (array of strings) - Required - A list of user names to remove from the channels. ### Request Example (PHP) ```php $api->removeFromChannels( ["Operations", "Field Team"], ["jane_doe", "john_smith"] ); ``` ### Request Example (Java) ```java ArrayList channels = new ArrayList<>(Arrays.asList("Operations", "Field Team")); ArrayList users = new ArrayList<>(Arrays.asList("jane_doe", "john_smith")); api.removeFromChannels(channels, users, (success, response, exception) -> System.out.println(success ? "Removed." : "Error: " + response) ); ``` ``` -------------------------------- ### Delete Users (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Removes one or more users from the network by providing an array of usernames. ```php // PHP if (!$api->deleteUsers(["jane_doe", "temp_user"])) { echo "Delete error: [{$api->errorCode}] {$api->errorDescription}"; } else { echo "Users deleted."; } ``` -------------------------------- ### Delete Channels Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Permanently removes one or more channels from the network. Ensure you have the correct channel names before execution. ```php // PHP $api->deleteChannels(["Operations", "Temp Channel"]); ``` ```csharp // C# var channels = new ArrayList { "Operations", "Temp Channel" }; ZelloAPIResult result = await api.DeleteChannels(channels); Console.WriteLine(result.Success ? "Deleted." : "Error."); ``` -------------------------------- ### deleteUsers / DeleteUsers / remove_users Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Permanently removes the specified users from the network. Accepts an array of usernames. ```APIDOC ## deleteUsers / DeleteUsers / remove_users — Delete one or more users ### Description Permanently removes the specified users from the network. Accepts an array of usernames. ### PHP Example ```php // PHP if (!$api->deleteUsers(["jane_doe", "temp_user"])) { echo "Delete error: [{$api->errorCode}] {$api->errorDescription}"; } else { echo "Users deleted."; } ``` ### Python Example ```python # Python api.remove_users(["jane_doe", "temp_user"]) # Prints: "Successfully removed users" # Verify deletion resp = api.get_user("jane_doe") if resp["status"] == "User not found": print("jane_doe successfully deleted") ``` ### Java Example ```java // Java ArrayList users = new ArrayList<>(Arrays.asList("jane_doe", "temp_user")); api.deleteUsers(users, (success, response, exception) -> System.out.println(success ? "Deleted." : "Error: " + response) ); ``` ``` -------------------------------- ### Delete roles from a channel (PHP) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Removes one or more named roles from a specified channel. Ensure the API object is initialized. ```php $api->deleteChannelRole("Operations", ["Driver", "Dispatcher"]); ``` -------------------------------- ### Delete roles from a channel (C#) Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Removes one or more named roles from a specified channel. Requires initializing an ArrayList for roles and awaiting the API call. ```csharp var roles = new ArrayList { "Driver", "Dispatcher" }; ZelloAPIResult result = await api.DeleteChannelRole("Operations", roles); Console.WriteLine(result.Success ? "Roles deleted." : result.Response?["status"]?.ToString()); ``` -------------------------------- ### Remove Users from a Channel Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Removes one or more users from a specified channel. The operation is confirmed by the success status. ```php // PHP $api->removeFromChannel("Operations", ["jane_doe"]); ``` ```swift // Swift api.removeFromChannel("Operations", users: ["jane_doe"]) { success, response, error in print("removeFromChannel: \(success)") } ``` -------------------------------- ### Logout Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Terminates the current API session identified by the Session ID and clears it server-side. This should be called when finished to invalidate the SID. ```APIDOC ## logout / Logout — End the current API session ### Description Terminates the session identified by the stored Session ID and clears it. Always call this when finished to invalidate the SID server-side. ### Method POST (implied) ### Endpoint `/user/logout` (implied) ### Request Body None ### Response - `status` (string) - Indicates success or failure of the logout operation. ### Request Example ```php // PHP if (!$api->logout()) { echo "Logout error: ".$api->errorCode." ".$api->errorDescription; } else { echo "Logged out successfully."; // $api->sid is now empty } ``` ```csharp // C# ZelloAPIResult result = await api.Logout(); Console.WriteLine(result.Success ? "Logged out." : "Logout failed."); // api.SessionId is now null ``` ``` -------------------------------- ### Remove Users from Channel Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Removes one or more users from the specified channel. ```APIDOC ## removeFromChannel / RemoveFromChannel — Remove users from a channel Removes one or more users from the specified channel. ### Method Not specified (assumed to be a method call on an API object) ### Parameters * **channelName** (string) - Required - The name of the channel to remove users from. * **users** (array of strings) - Required - A list of user names to remove from the channel. ### Request Example (PHP) ```php $api->removeFromChannel("Operations", ["jane_doe"]); ``` ### Request Example (Swift) ```swift api.removeFromChannel("Operations", users: ["jane_doe"]) { success, response, error in print("removeFromChannel: \(success)") } ``` ``` -------------------------------- ### Delete Channels Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Permanently removes one or more channels from the network. ```APIDOC ## deleteChannels / DeleteChannels — Delete channels Permanently removes one or more channels from the network. ### Method Not specified (assumed to be a method call on an API object) ### Parameters * **channels** (array of strings) - Required - A list of channel names to delete. ### Request Example (PHP) ```php $api->deleteChannels(["Operations", "Temp Channel"]); ``` ### Request Example (C#) ```csharp var channels = new ArrayList { "Operations", "Temp Channel" }; await api.DeleteChannels(channels); ``` ``` -------------------------------- ### deleteChannelRole Source: https://context7.com/zelloptt/zellowork-server-api-libs/llms.txt Removes one or more named roles from a channel. ```APIDOC ## deleteChannelRole / DeleteChannelRole — Delete roles from a channel ### Description Removes one or more named roles from a channel. ### Method POST (assumed, based on operation) ### Endpoint `/channels/{channel_name}/roles` (assumed, based on operation) ### Parameters #### Path Parameters - **channel_name** (string) - Required - The name of the channel. #### Request Body - **roles** (array of strings) - Required - A list of role names to remove. ``` ```PHP $api->deleteChannelRole("Operations", ["Driver", "Dispatcher"]); ``` ```C# var roles = new ArrayList { "Driver", "Dispatcher" }; ZelloAPIResult result = await api.DeleteChannelRole("Operations", roles); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.