/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2026.5.0-rc1
 * Contact: hello@goauthentik.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import type { PolicyEngineMode } from "./PolicyEngineMode";
import { PolicyEngineModeFromJSON, PolicyEngineModeToJSON } from "./PolicyEngineMode";
import type { UserMatchingModeEnum } from "./UserMatchingModeEnum";
import { UserMatchingModeEnumFromJSON, UserMatchingModeEnumToJSON } from "./UserMatchingModeEnum";

/**
 * Source Serializer
 * @export
 * @interface TelegramSourceRequest
 */
export interface TelegramSourceRequest {
    /**
     * Source's display Name.
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    name: string;
    /**
     * Internal source name, used in URLs.
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    slug: string;
    /**
     *
     * @type {boolean}
     * @memberof TelegramSourceRequest
     */
    enabled?: boolean;
    /**
     * When enabled, this source will be displayed as a prominent button on the login page, instead of a small icon.
     * @type {boolean}
     * @memberof TelegramSourceRequest
     */
    promoted?: boolean;
    /**
     * Flow to use when authenticating existing users.
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    authenticationFlow?: string | null;
    /**
     * Flow to use when enrolling new users.
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    enrollmentFlow?: string | null;
    /**
     *
     * @type {Array<string>}
     * @memberof TelegramSourceRequest
     */
    userPropertyMappings?: Array<string>;
    /**
     *
     * @type {Array<string>}
     * @memberof TelegramSourceRequest
     */
    groupPropertyMappings?: Array<string>;
    /**
     *
     * @type {PolicyEngineMode}
     * @memberof TelegramSourceRequest
     */
    policyEngineMode?: PolicyEngineMode;
    /**
     * How the source determines if an existing user should be authenticated or a new user enrolled.
     * @type {UserMatchingModeEnum}
     * @memberof TelegramSourceRequest
     */
    userMatchingMode?: UserMatchingModeEnum;
    /**
     *
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    userPathTemplate?: string;
    /**
     *
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    icon?: string;
    /**
     * Telegram bot username
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    botUsername: string;
    /**
     * Telegram bot token
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    botToken: string;
    /**
     * Request access to send messages from your bot.
     * @type {boolean}
     * @memberof TelegramSourceRequest
     */
    requestMessageAccess?: boolean;
    /**
     * Flow used before authentication.
     * @type {string}
     * @memberof TelegramSourceRequest
     */
    preAuthenticationFlow: string;
}

/**
 * Check if a given object implements the TelegramSourceRequest interface.
 */
export function instanceOfTelegramSourceRequest(value: object): value is TelegramSourceRequest {
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("slug" in value) || value["slug"] === undefined) return false;
    if (!("botUsername" in value) || value["botUsername"] === undefined) return false;
    if (!("botToken" in value) || value["botToken"] === undefined) return false;
    if (!("preAuthenticationFlow" in value) || value["preAuthenticationFlow"] === undefined)
        return false;
    return true;
}

export function TelegramSourceRequestFromJSON(json: any): TelegramSourceRequest {
    return TelegramSourceRequestFromJSONTyped(json, false);
}

export function TelegramSourceRequestFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): TelegramSourceRequest {
    if (json == null) {
        return json;
    }
    return {
        name: json["name"],
        slug: json["slug"],
        enabled: json["enabled"] == null ? undefined : json["enabled"],
        promoted: json["promoted"] == null ? undefined : json["promoted"],
        authenticationFlow:
            json["authentication_flow"] == null ? undefined : json["authentication_flow"],
        enrollmentFlow: json["enrollment_flow"] == null ? undefined : json["enrollment_flow"],
        userPropertyMappings:
            json["user_property_mappings"] == null ? undefined : json["user_property_mappings"],
        groupPropertyMappings:
            json["group_property_mappings"] == null ? undefined : json["group_property_mappings"],
        policyEngineMode:
            json["policy_engine_mode"] == null
                ? undefined
                : PolicyEngineModeFromJSON(json["policy_engine_mode"]),
        userMatchingMode:
            json["user_matching_mode"] == null
                ? undefined
                : UserMatchingModeEnumFromJSON(json["user_matching_mode"]),
        userPathTemplate:
            json["user_path_template"] == null ? undefined : json["user_path_template"],
        icon: json["icon"] == null ? undefined : json["icon"],
        botUsername: json["bot_username"],
        botToken: json["bot_token"],
        requestMessageAccess:
            json["request_message_access"] == null ? undefined : json["request_message_access"],
        preAuthenticationFlow: json["pre_authentication_flow"],
    };
}

export function TelegramSourceRequestToJSON(json: any): TelegramSourceRequest {
    return TelegramSourceRequestToJSONTyped(json, false);
}

export function TelegramSourceRequestToJSONTyped(
    value?: TelegramSourceRequest | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        slug: value["slug"],
        enabled: value["enabled"],
        promoted: value["promoted"],
        authentication_flow: value["authenticationFlow"],
        enrollment_flow: value["enrollmentFlow"],
        user_property_mappings: value["userPropertyMappings"],
        group_property_mappings: value["groupPropertyMappings"],
        policy_engine_mode: PolicyEngineModeToJSON(value["policyEngineMode"]),
        user_matching_mode: UserMatchingModeEnumToJSON(value["userMatchingMode"]),
        user_path_template: value["userPathTemplate"],
        icon: value["icon"],
        bot_username: value["botUsername"],
        bot_token: value["botToken"],
        request_message_access: value["requestMessageAccess"],
        pre_authentication_flow: value["preAuthenticationFlow"],
    };
}
