/* 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 { ContextualFlowInfo } from "./ContextualFlowInfo";
import { ContextualFlowInfoFromJSON, ContextualFlowInfoToJSON } from "./ContextualFlowInfo";
import type { ErrorDetail } from "./ErrorDetail";

/**
 * Base login challenge for Identification stage
 * @export
 * @interface TelegramLoginChallenge
 */
export interface TelegramLoginChallenge {
    /**
     *
     * @type {ContextualFlowInfo}
     * @memberof TelegramLoginChallenge
     */
    flowInfo?: ContextualFlowInfo;
    /**
     *
     * @type {string}
     * @memberof TelegramLoginChallenge
     */
    component?: string;
    /**
     *
     * @type {{ [key: string]: Array<ErrorDetail>; }}
     * @memberof TelegramLoginChallenge
     */
    responseErrors?: { [key: string]: Array<ErrorDetail> };
    /**
     * Telegram bot username
     * @type {string}
     * @memberof TelegramLoginChallenge
     */
    botUsername: string;
    /**
     *
     * @type {boolean}
     * @memberof TelegramLoginChallenge
     */
    requestMessageAccess: boolean;
}

/**
 * Check if a given object implements the TelegramLoginChallenge interface.
 */
export function instanceOfTelegramLoginChallenge(value: object): value is TelegramLoginChallenge {
    if (!("botUsername" in value) || value["botUsername"] === undefined) return false;
    if (!("requestMessageAccess" in value) || value["requestMessageAccess"] === undefined)
        return false;
    return true;
}

export function TelegramLoginChallengeFromJSON(json: any): TelegramLoginChallenge {
    return TelegramLoginChallengeFromJSONTyped(json, false);
}

export function TelegramLoginChallengeFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): TelegramLoginChallenge {
    if (json == null) {
        return json;
    }
    return {
        flowInfo:
            json["flow_info"] == null ? undefined : ContextualFlowInfoFromJSON(json["flow_info"]),
        component: json["component"] == null ? undefined : json["component"],
        responseErrors: json["response_errors"] == null ? undefined : json["response_errors"],
        botUsername: json["bot_username"],
        requestMessageAccess: json["request_message_access"],
    };
}

export function TelegramLoginChallengeToJSON(json: any): TelegramLoginChallenge {
    return TelegramLoginChallengeToJSONTyped(json, false);
}

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

    return {
        flow_info: ContextualFlowInfoToJSON(value["flowInfo"]),
        component: value["component"],
        response_errors: value["responseErrors"],
        bot_username: value["botUsername"],
        request_message_access: value["requestMessageAccess"],
    };
}
