/* 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 { IntentEnum } from "./IntentEnum";
import { IntentEnumFromJSON, IntentEnumToJSON } from "./IntentEnum";
import type { User } from "./User";
import { UserFromJSON } from "./User";

/**
 * Token Serializer
 * @export
 * @interface Token
 */
export interface Token {
    /**
     *
     * @type {string}
     * @memberof Token
     */
    readonly pk: string;
    /**
     * Objects that are managed by authentik. These objects are created and updated automatically. This flag only indicates that an object can be overwritten by migrations. You can still modify the objects via the API, but expect changes to be overwritten in a later update.
     * @type {string}
     * @memberof Token
     */
    managed?: string | null;
    /**
     *
     * @type {string}
     * @memberof Token
     */
    identifier: string;
    /**
     *
     * @type {IntentEnum}
     * @memberof Token
     */
    intent?: IntentEnum;
    /**
     *
     * @type {number}
     * @memberof Token
     */
    user?: number;
    /**
     *
     * @type {User}
     * @memberof Token
     */
    readonly userObj: User;
    /**
     *
     * @type {string}
     * @memberof Token
     */
    description?: string;
    /**
     *
     * @type {Date}
     * @memberof Token
     */
    expires?: Date | null;
    /**
     *
     * @type {boolean}
     * @memberof Token
     */
    expiring?: boolean;
}

/**
 * Check if a given object implements the Token interface.
 */
export function instanceOfToken(value: object): value is Token {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("identifier" in value) || value["identifier"] === undefined) return false;
    if (!("userObj" in value) || value["userObj"] === undefined) return false;
    return true;
}

export function TokenFromJSON(json: any): Token {
    return TokenFromJSONTyped(json, false);
}

export function TokenFromJSONTyped(json: any, ignoreDiscriminator: boolean): Token {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        managed: json["managed"] == null ? undefined : json["managed"],
        identifier: json["identifier"],
        intent: json["intent"] == null ? undefined : IntentEnumFromJSON(json["intent"]),
        user: json["user"] == null ? undefined : json["user"],
        userObj: UserFromJSON(json["user_obj"]),
        description: json["description"] == null ? undefined : json["description"],
        expires: json["expires"] == null ? undefined : new Date(json["expires"]),
        expiring: json["expiring"] == null ? undefined : json["expiring"],
    };
}

export function TokenToJSON(json: any): Token {
    return TokenToJSONTyped(json, false);
}

export function TokenToJSONTyped(
    value?: Omit<Token, "pk" | "user_obj"> | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        managed: value["managed"],
        identifier: value["identifier"],
        intent: IntentEnumToJSON(value["intent"]),
        user: value["user"],
        description: value["description"],
        expires: value["expires"] == null ? value["expires"] : value["expires"].toISOString(),
        expiring: value["expiring"],
    };
}
