/* 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 { OAuth2Provider } from "./OAuth2Provider";
import { OAuth2ProviderFromJSON, OAuth2ProviderToJSON } from "./OAuth2Provider";
import type { User } from "./User";
import { UserFromJSON, UserToJSON } from "./User";

/**
 * Serializer for BaseGrantModel and ExpiringBaseGrant
 * @export
 * @interface ExpiringBaseGrantModel
 */
export interface ExpiringBaseGrantModel {
    /**
     *
     * @type {number}
     * @memberof ExpiringBaseGrantModel
     */
    readonly pk: number;
    /**
     *
     * @type {OAuth2Provider}
     * @memberof ExpiringBaseGrantModel
     */
    provider: OAuth2Provider;
    /**
     *
     * @type {User}
     * @memberof ExpiringBaseGrantModel
     */
    user: User;
    /**
     * Check if token is expired yet.
     * @type {boolean}
     * @memberof ExpiringBaseGrantModel
     */
    readonly isExpired: boolean;
    /**
     *
     * @type {Date}
     * @memberof ExpiringBaseGrantModel
     */
    expires?: Date | null;
    /**
     *
     * @type {Array<string>}
     * @memberof ExpiringBaseGrantModel
     */
    scope: Array<string>;
}

/**
 * Check if a given object implements the ExpiringBaseGrantModel interface.
 */
export function instanceOfExpiringBaseGrantModel(value: object): value is ExpiringBaseGrantModel {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("provider" in value) || value["provider"] === undefined) return false;
    if (!("user" in value) || value["user"] === undefined) return false;
    if (!("isExpired" in value) || value["isExpired"] === undefined) return false;
    if (!("scope" in value) || value["scope"] === undefined) return false;
    return true;
}

export function ExpiringBaseGrantModelFromJSON(json: any): ExpiringBaseGrantModel {
    return ExpiringBaseGrantModelFromJSONTyped(json, false);
}

export function ExpiringBaseGrantModelFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): ExpiringBaseGrantModel {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        provider: OAuth2ProviderFromJSON(json["provider"]),
        user: UserFromJSON(json["user"]),
        isExpired: json["is_expired"],
        expires: json["expires"] == null ? undefined : new Date(json["expires"]),
        scope: json["scope"],
    };
}

export function ExpiringBaseGrantModelToJSON(json: any): ExpiringBaseGrantModel {
    return ExpiringBaseGrantModelToJSONTyped(json, false);
}

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

    return {
        provider: OAuth2ProviderToJSON(value["provider"]),
        user: UserToJSON(value["user"]),
        expires: value["expires"] == null ? value["expires"] : value["expires"].toISOString(),
        scope: value["scope"],
    };
}
