// This file was autogenerated. Please do not change.
// All changes will be overwrited on commit.
export interface IClient {
    blocked_services?: string[];
    filtering_enabled?: boolean;
    ids?: string[];
    name?: string;
    parental_enabled?: boolean;
    safebrowsing_enabled?: boolean;
    safesearch_enabled?: boolean;
    upstreams?: string[];
    use_global_blocked_services?: boolean;
    use_global_settings?: boolean;
}

export default class Client {
    readonly _blocked_services: string[] | undefined;

    get blockedServices(): string[] | undefined {
        return this._blocked_services;
    }

    readonly _filtering_enabled: boolean | undefined;

    get filteringEnabled(): boolean | undefined {
        return this._filtering_enabled;
    }

    readonly _ids: string[] | undefined;

    /** */
    get ids(): string[] | undefined {
        return this._ids;
    }

    readonly _name: string | undefined;

    /**
     * Description: Name
     * Example: localhost
     */
    get name(): string | undefined {
        return this._name;
    }

    readonly _parental_enabled: boolean | undefined;

    get parentalEnabled(): boolean | undefined {
        return this._parental_enabled;
    }

    readonly _safebrowsing_enabled: boolean | undefined;

    get safebrowsingEnabled(): boolean | undefined {
        return this._safebrowsing_enabled;
    }

    readonly _safesearch_enabled: boolean | undefined;

    get safesearchEnabled(): boolean | undefined {
        return this._safesearch_enabled;
    }

    readonly _upstreams: string[] | undefined;

    get upstreams(): string[] | undefined {
        return this._upstreams;
    }

    readonly _use_global_blocked_services: boolean | undefined;

    get useGlobalBlockedServices(): boolean | undefined {
        return this._use_global_blocked_services;
    }

    readonly _use_global_settings: boolean | undefined;

    get useGlobalSettings(): boolean | undefined {
        return this._use_global_settings;
    }

    constructor(props: IClient) {
        if (props.blocked_services) {
            this._blocked_services = props.blocked_services;
        }
        if (typeof props.filtering_enabled === 'boolean') {
            this._filtering_enabled = props.filtering_enabled;
        }
        if (props.ids) {
            this._ids = props.ids;
        }
        if (typeof props.name === 'string') {
            this._name = props.name.trim();
        }
        if (typeof props.parental_enabled === 'boolean') {
            this._parental_enabled = props.parental_enabled;
        }
        if (typeof props.safebrowsing_enabled === 'boolean') {
            this._safebrowsing_enabled = props.safebrowsing_enabled;
        }
        if (typeof props.safesearch_enabled === 'boolean') {
            this._safesearch_enabled = props.safesearch_enabled;
        }
        if (props.upstreams) {
            this._upstreams = props.upstreams;
        }
        if (typeof props.use_global_blocked_services === 'boolean') {
            this._use_global_blocked_services = props.use_global_blocked_services;
        }
        if (typeof props.use_global_settings === 'boolean') {
            this._use_global_settings = props.use_global_settings;
        }
    }

    serialize(): IClient {
        const data: IClient = {
        };
        if (typeof this._blocked_services !== 'undefined') {
            data.blocked_services = this._blocked_services;
        }
        if (typeof this._filtering_enabled !== 'undefined') {
            data.filtering_enabled = this._filtering_enabled;
        }
        if (typeof this._ids !== 'undefined') {
            data.ids = this._ids;
        }
        if (typeof this._name !== 'undefined') {
            data.name = this._name;
        }
        if (typeof this._parental_enabled !== 'undefined') {
            data.parental_enabled = this._parental_enabled;
        }
        if (typeof this._safebrowsing_enabled !== 'undefined') {
            data.safebrowsing_enabled = this._safebrowsing_enabled;
        }
        if (typeof this._safesearch_enabled !== 'undefined') {
            data.safesearch_enabled = this._safesearch_enabled;
        }
        if (typeof this._upstreams !== 'undefined') {
            data.upstreams = this._upstreams;
        }
        if (typeof this._use_global_blocked_services !== 'undefined') {
            data.use_global_blocked_services = this._use_global_blocked_services;
        }
        if (typeof this._use_global_settings !== 'undefined') {
            data.use_global_settings = this._use_global_settings;
        }
        return data;
    }

    validate(): string[] {
        const validate = {
            name: !this._name ? true : typeof this._name === 'string' && !this._name ? true : this._name,
            ids: !this._ids ? true : this._ids.reduce((result, p) => result && typeof p === 'string', true),
            use_global_settings: !this._use_global_settings ? true : typeof this._use_global_settings === 'boolean',
            filtering_enabled: !this._filtering_enabled ? true : typeof this._filtering_enabled === 'boolean',
            parental_enabled: !this._parental_enabled ? true : typeof this._parental_enabled === 'boolean',
            safebrowsing_enabled: !this._safebrowsing_enabled ? true : typeof this._safebrowsing_enabled === 'boolean',
            safesearch_enabled: !this._safesearch_enabled ? true : typeof this._safesearch_enabled === 'boolean',
            use_global_blocked_services: !this._use_global_blocked_services ? true : typeof this._use_global_blocked_services === 'boolean',
            blocked_services: !this._blocked_services ? true : this._blocked_services.reduce((result, p) => result && typeof p === 'string', true),
            upstreams: !this._upstreams ? true : this._upstreams.reduce((result, p) => result && typeof p === 'string', true),
        };
        const isError: string[] = [];
        Object.keys(validate).forEach((key) => {
            if (!(validate as any)[key]) {
                isError.push(key);
            }
        });
        return isError;
    }

    update(props: Partial<IClient>): Client {
        return new Client({ ...this.serialize(), ...props });
    }
}
