"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * The `sos.management.proxy` API groups together methods for managing the proxy settings on the device.
 *
 * <details>
 *     <summary>Proxy Management Capabilities</summary>
 * 		| Capability | Description |
 * 		|:------------|:-------------|
 * 		| `PROXY` | If device supports Proxy setup connection |
 *
 * 		If you want to check if the device supports this capability, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports).
 * </details>
 */
class Proxy {
    messagePrefix;
    postMessage;
    /** @internal */
    constructor(messagePrefix, postMessage) {
        this.messagePrefix = messagePrefix;
        this.postMessage = postMessage;
    }
    /**
     * The `isEnabled()` method returns whether the proxy is enabled on the device.
     *
     * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the proxy is enabled.
     * @since 5.4.0
     *
     * @example
     * const enabled = await sos.management.proxy.isEnabled();
     * console.log(`Proxy is enabled: ${enabled}`);
     */
    async isEnabled() {
        const { isEnabled } = await this.postMessage({
            type: this.getMessage('proxy_is_enabled'),
        });
        return isEnabled;
    }
    /**
     * The `setManual()` allows you to manually configure the proxy settings on the device.
     *
     * @param uri The URI of the proxy server
     * @param port The port of the proxy server
     * @param username The username for the proxy server
     * @param password The password for the proxy server
     * @return {Promise<void>} A promise that resolves when the proxy is set.
     * @throws {Error} If the proxy settings are invalid.
     * @throws {Error} If the device does not support proxy management.
     * @since 5.4.0
     *
     * @example
     * await sos.management.proxy.setManual('178.62.193.192', 1080, 'username', 'password');
     */
    async setManual(uri, port, username, password) {
        await this.postMessage({
            type: this.getMessage('proxy_set_manual'),
            uri,
            port,
            username,
            password,
        });
    }
    /**
     * The `disable()` method disables the proxy on the device.
     *
     * @returns {Promise<void>} A promise that resolves when the proxy is disabled.
     * @throws {Error} If the device does not support proxy management.
     * @since 5.4.0
     *
     * @example
     * await sos.management.proxy.disable();
     */
    async disable() {
        await this.postMessage({
            type: this.getMessage('proxy_disable'),
        });
    }
    /**
     * The `getConnectedTo()` method returns the current connected proxy server URI on the device.
     *
     * @returns {Promise<string>} A promise that resolves to the URI of the connected proxy server.
     * @throws {Error} If the device does not support proxy management.
     * @since 5.4.0
     *
     * @example
     * const uri = await sos.management.proxy.getConnectedTo();
     * console.log(uri); // 178.62.193.192
     */
    async getConnectedTo() {
        const { connectedTo } = await this.postMessage({
            type: this.getMessage('proxy_get_connected_to'),
        });
        return connectedTo;
    }
    getMessage(name) {
        return this.messagePrefix + '.' + name;
    }
}
exports.default = Proxy;
//# sourceMappingURL=Proxy.js.map