/// <reference path="./sigApi.ApiBase.d.ts" />
/// <reference path="./sigApi.Checkbit.d.ts" />

declare namespace SigApi {
    interface ApiCheckbitManager extends ApiBase {
        /**
         * Returns a list with all available checkbits.
         * 
         * @returns {Checkbit[]} An array of available checkbit objects.
         */
        getCheckbits(): Checkbit[]
        /**
         * Gets a checkbit by its id. Returns a checkbit object.
         * 
         * Possible errors:
         * * Invalid checkbit id
         * * Unknown checkbit
         * 
         * @param {string} checkbitId The id of the checkbit
         * @returns {Checkbit|null} A checkbit object with the given id or null on error.
         */
        getCheckbitById(checkbitId: string): Checkbit | null
        /**
         * Gets the value of a checkbit by its id. Returns a boolean.
         * 
         * Possible errors:
         * * Invalid checkbit id
         * * Unknown checkbit
         * 
         * @param {string} checkbitId The id of the checkbit
         * @returns {boolean} The value of the given checkbit. Defaults to false on error.
         */
        getCheckbitValueById(checkbitId: string): boolean
        /**
         * Adds a callback function to checkbit
         * 
         * callback({boolean})
         * 
         * @param {string} checkbitId The id of the checkbit
         * @param {Function} callback A function called every time the checkbit value changes
         * @returns {string} observerId
         */
        addObserver(
            checkbitId: string,
            callback: (value: boolean) => void
        ): string | undefined
        /**
         * Removes a callback function
         * 
         * @param {string} observerId The observerId optained by addObserver
         * @returns {boolean}
         */
        removeObserver(observerId: string): boolean
        /**
         * Function to check if parameter object is a instanceof Checkbit.
         * This function can be used without importing the type Checkbit to be used with the instanceof operator.
         * @param {*} object Any object to type check
         * @returns {boolean} Returns true if parameter object is instanceof Checkbit, else false
         */
        instanceofCheckbit(object: any): boolean
    }
}
