/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2025.10.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 { mapValues } from '../runtime';
import type { User } from './User';
import {
    UserFromJSON,
    UserFromJSONTyped,
    UserToJSON,
    UserToJSONTyped,
} from './User';
import type { Application } from './Application';
import {
    ApplicationFromJSON,
    ApplicationFromJSONTyped,
    ApplicationToJSON,
    ApplicationToJSONTyped,
} from './Application';

/**
 * UserConsent Serializer
 * @export
 * @interface UserConsent
 */
export interface UserConsent {
    /**
     * 
     * @type {number}
     * @memberof UserConsent
     */
    readonly pk: number;
    /**
     * 
     * @type {Date}
     * @memberof UserConsent
     */
    expires?: Date | null;
    /**
     * 
     * @type {boolean}
     * @memberof UserConsent
     */
    expiring?: boolean;
    /**
     * 
     * @type {User}
     * @memberof UserConsent
     */
    user: User;
    /**
     * 
     * @type {Application}
     * @memberof UserConsent
     */
    application: Application;
    /**
     * 
     * @type {string}
     * @memberof UserConsent
     */
    permissions?: string;
}

/**
 * Check if a given object implements the UserConsent interface.
 */
export function instanceOfUserConsent(value: object): value is UserConsent {
    if (!('pk' in value) || value['pk'] === undefined) return false;
    if (!('user' in value) || value['user'] === undefined) return false;
    if (!('application' in value) || value['application'] === undefined) return false;
    return true;
}

export function UserConsentFromJSON(json: any): UserConsent {
    return UserConsentFromJSONTyped(json, false);
}

export function UserConsentFromJSONTyped(json: any, ignoreDiscriminator: boolean): UserConsent {
    if (json == null) {
        return json;
    }
    return {
        
        'pk': json['pk'],
        'expires': json['expires'] == null ? undefined : (new Date(json['expires'])),
        'expiring': json['expiring'] == null ? undefined : json['expiring'],
        'user': UserFromJSON(json['user']),
        'application': ApplicationFromJSON(json['application']),
        'permissions': json['permissions'] == null ? undefined : json['permissions'],
    };
}

export function UserConsentToJSON(json: any): UserConsent {
    return UserConsentToJSONTyped(json, false);
}

export function UserConsentToJSONTyped(value?: Omit<UserConsent, 'pk'> | null, ignoreDiscriminator: boolean = false): any {
    if (value == null) {
        return value;
    }

    return {
        
        'expires': value['expires'] === null ? null : ((value['expires'] as any)?.toISOString()),
        'expiring': value['expiring'],
        'user': UserToJSON(value['user']),
        'application': ApplicationToJSON(value['application']),
        'permissions': value['permissions'],
    };
}

