/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2025.12.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 { UserTypeEnum } from './UserTypeEnum';
import {
    UserTypeEnumFromJSON,
    UserTypeEnumFromJSONTyped,
    UserTypeEnumToJSON,
    UserTypeEnumToJSONTyped,
} from './UserTypeEnum';
import type { PartialGroup } from './PartialGroup';
import {
    PartialGroupFromJSON,
    PartialGroupFromJSONTyped,
    PartialGroupToJSON,
    PartialGroupToJSONTyped,
} from './PartialGroup';

/**
 * User Serializer
 * @export
 * @interface User
 */
export interface User {
    /**
     * 
     * @type {number}
     * @memberof User
     */
    readonly pk: number;
    /**
     * 
     * @type {string}
     * @memberof User
     */
    username: string;
    /**
     * User's display name.
     * @type {string}
     * @memberof User
     */
    name: string;
    /**
     * Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
     * @type {boolean}
     * @memberof User
     */
    isActive?: boolean;
    /**
     * 
     * @type {Date}
     * @memberof User
     */
    lastLogin?: Date | null;
    /**
     * 
     * @type {Date}
     * @memberof User
     */
    readonly dateJoined: Date;
    /**
     * 
     * @type {boolean}
     * @memberof User
     */
    readonly isSuperuser: boolean;
    /**
     * 
     * @type {Array<string>}
     * @memberof User
     */
    groups?: Array<string>;
    /**
     * 
     * @type {Array<PartialGroup>}
     * @memberof User
     */
    readonly groupsObj: Array<PartialGroup> | null;
    /**
     * 
     * @type {string}
     * @memberof User
     */
    email?: string;
    /**
     * User's avatar, either a http/https URL or a data URI
     * @type {string}
     * @memberof User
     */
    readonly avatar: string;
    /**
     * 
     * @type {{ [key: string]: any; }}
     * @memberof User
     */
    attributes?: { [key: string]: any; };
    /**
     * 
     * @type {string}
     * @memberof User
     */
    readonly uid: string;
    /**
     * 
     * @type {string}
     * @memberof User
     */
    path?: string;
    /**
     * 
     * @type {UserTypeEnum}
     * @memberof User
     */
    type?: UserTypeEnum;
    /**
     * 
     * @type {string}
     * @memberof User
     */
    readonly uuid: string;
    /**
     * 
     * @type {Date}
     * @memberof User
     */
    readonly passwordChangeDate: Date;
    /**
     * 
     * @type {Date}
     * @memberof User
     */
    readonly lastUpdated: Date;
}



/**
 * Check if a given object implements the User interface.
 */
export function instanceOfUser(value: object): value is User {
    if (!('pk' in value) || value['pk'] === undefined) return false;
    if (!('username' in value) || value['username'] === undefined) return false;
    if (!('name' in value) || value['name'] === undefined) return false;
    if (!('dateJoined' in value) || value['dateJoined'] === undefined) return false;
    if (!('isSuperuser' in value) || value['isSuperuser'] === undefined) return false;
    if (!('groupsObj' in value) || value['groupsObj'] === undefined) return false;
    if (!('avatar' in value) || value['avatar'] === undefined) return false;
    if (!('uid' in value) || value['uid'] === undefined) return false;
    if (!('uuid' in value) || value['uuid'] === undefined) return false;
    if (!('passwordChangeDate' in value) || value['passwordChangeDate'] === undefined) return false;
    if (!('lastUpdated' in value) || value['lastUpdated'] === undefined) return false;
    return true;
}

export function UserFromJSON(json: any): User {
    return UserFromJSONTyped(json, false);
}

export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User {
    if (json == null) {
        return json;
    }
    return {
        
        'pk': json['pk'],
        'username': json['username'],
        'name': json['name'],
        'isActive': json['is_active'] == null ? undefined : json['is_active'],
        'lastLogin': json['last_login'] == null ? undefined : (new Date(json['last_login'])),
        'dateJoined': (new Date(json['date_joined'])),
        'isSuperuser': json['is_superuser'],
        'groups': json['groups'] == null ? undefined : json['groups'],
        'groupsObj': (json['groups_obj'] == null ? null : (json['groups_obj'] as Array<any>).map(PartialGroupFromJSON)),
        'email': json['email'] == null ? undefined : json['email'],
        'avatar': json['avatar'],
        'attributes': json['attributes'] == null ? undefined : json['attributes'],
        'uid': json['uid'],
        'path': json['path'] == null ? undefined : json['path'],
        'type': json['type'] == null ? undefined : UserTypeEnumFromJSON(json['type']),
        'uuid': json['uuid'],
        'passwordChangeDate': (new Date(json['password_change_date'])),
        'lastUpdated': (new Date(json['last_updated'])),
    };
}

export function UserToJSON(json: any): User {
    return UserToJSONTyped(json, false);
}

export function UserToJSONTyped(value?: Omit<User, 'pk'|'date_joined'|'is_superuser'|'groups_obj'|'avatar'|'uid'|'uuid'|'password_change_date'|'last_updated'> | null, ignoreDiscriminator: boolean = false): any {
    if (value == null) {
        return value;
    }

    return {
        
        'username': value['username'],
        'name': value['name'],
        'is_active': value['isActive'],
        'last_login': value['lastLogin'] == null ? value['lastLogin'] : value['lastLogin'].toISOString(),
        'groups': value['groups'],
        'email': value['email'],
        'attributes': value['attributes'],
        'path': value['path'],
        'type': UserTypeEnumToJSON(value['type']),
    };
}

