/* 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 { Flow } from "./Flow";
import { FlowFromJSON } from "./Flow";
import type { PartialUser } from "./PartialUser";
import { PartialUserFromJSON } from "./PartialUser";

/**
 * Invitation Serializer
 * @export
 * @interface Invitation
 */
export interface Invitation {
    /**
     *
     * @type {string}
     * @memberof Invitation
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof Invitation
     */
    name: string;
    /**
     *
     * @type {Date}
     * @memberof Invitation
     */
    expires?: Date | null;
    /**
     *
     * @type {{ [key: string]: any; }}
     * @memberof Invitation
     */
    fixedData?: { [key: string]: any };
    /**
     *
     * @type {PartialUser}
     * @memberof Invitation
     */
    readonly createdBy: PartialUser;
    /**
     * When enabled, the invitation will be deleted after usage.
     * @type {boolean}
     * @memberof Invitation
     */
    singleUse?: boolean;
    /**
     * When set, only the configured flow can use this invitation.
     * @type {string}
     * @memberof Invitation
     */
    flow?: string | null;
    /**
     *
     * @type {Flow}
     * @memberof Invitation
     */
    readonly flowObj: Flow;
}

/**
 * Check if a given object implements the Invitation interface.
 */
export function instanceOfInvitation(value: object): value is Invitation {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("createdBy" in value) || value["createdBy"] === undefined) return false;
    if (!("flowObj" in value) || value["flowObj"] === undefined) return false;
    return true;
}

export function InvitationFromJSON(json: any): Invitation {
    return InvitationFromJSONTyped(json, false);
}

export function InvitationFromJSONTyped(json: any, ignoreDiscriminator: boolean): Invitation {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        name: json["name"],
        expires: json["expires"] == null ? undefined : new Date(json["expires"]),
        fixedData: json["fixed_data"] == null ? undefined : json["fixed_data"],
        createdBy: PartialUserFromJSON(json["created_by"]),
        singleUse: json["single_use"] == null ? undefined : json["single_use"],
        flow: json["flow"] == null ? undefined : json["flow"],
        flowObj: FlowFromJSON(json["flow_obj"]),
    };
}

export function InvitationToJSON(json: any): Invitation {
    return InvitationToJSONTyped(json, false);
}

export function InvitationToJSONTyped(
    value?: Omit<Invitation, "pk" | "created_by" | "flow_obj"> | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        expires: value["expires"] == null ? value["expires"] : value["expires"].toISOString(),
        fixed_data: value["fixedData"],
        single_use: value["singleUse"],
        flow: value["flow"],
    };
}
