Variables Class Documentation

Variables

A comprehensive JavaScript wrapper class for managing variables through HTTP API calls

ConfigureConfigure API url

public static void <JsonElement> configure(string apiUrl)

Specify a custom API url.

â†Šī¸ Returns

void

💡 Example

Variables.configure("https://prod-api.mycompany.com")

GET getVariable

async getVariable(name: string): Promise<any>

Retrieves a specific variable by its name from the API.

📝 Parameters

name (string) - The name of the variable to retrieve

â†Šī¸ Returns

Promise<any> - The retrieved variable data, or null if not found

💡 Example

const variable = await Variables.getVariable("myVariable");
if (variable) {
    console.log(`Variable found: ${JSON.stringify(variable)}`);
} else {
    console.log("Variable not found");
}

GET getAllVariables

async getAllVariables(): Promise<any>

Retrieves all variables from the API.

â†Šī¸ Returns

Promise<any> - All variables data

💡 Example

const allVariables = await Variables.getAllVariables();

for (const variable of allVariables) {
    for (const [key, value] of Object.entries(variable)) {
        console.log(`${key}: ${value}`);
    }
}

POST createVariable

async createVariable(data: Record<string, any>): Promise<any>

Creates a new variable with the specified data.

📝 Parameters

data (Record<string, any>) - The variable data to create. Can be any object with string keys.

â†Šī¸ Returns

Promise<any> - The created variable data returned from the API

💡 Example

const newVariable = {
    name: "temperature",
    value: "25.5",
    type: "number"
};

const result = await Variables.createVariable(newVariable);
console.log(`Created variable: ${JSON.stringify(result)}`);

PUT updateVariable

async updateVariable(name: string, new_value: string | number | boolean): Promise<any>

Updates an existing variable with a new value.

📝 Parameters

name (string) - The name of the variable to update
new_value (string | number | boolean) - The new value for the variable

â†Šī¸ Returns

Promise<any> - The updated variable data returned from the API

💡 Example

// Update a variable with a new value
const result = await Variables.updateVariable("temperature", "30.2");
console.log(`Updated variable: ${JSON.stringify(result)}`);

📤 Request Body Structure

The method automatically wraps the new value in a JSON object:

{
    "value": <new_value>
}