/* tslint:disable */
/* eslint-disable */
/**
 * Tribufu API
 * API to access Tribufu services.
 *
 * The version of the OpenAPI document: 1.3.0
 * Contact: contact@tribufu.com
 *
 * 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 { LoginProvider } from './LoginProvider';
import {
    LoginProviderFromJSON,
    LoginProviderFromJSONTyped,
    LoginProviderToJSON,
    LoginProviderToJSONTyped,
} from './LoginProvider';

/**
 * 
 * @export
 * @interface Account
 */
export interface Account {
    /**
     * 
     * @type {string}
     * @memberof Account
     */
    id: string | null;
    /**
     * 
     * @type {string}
     * @memberof Account
     */
    name?: string | null;
    /**
     * 
     * @type {LoginProvider}
     * @memberof Account
     */
    provider: LoginProvider;
    /**
     * 
     * @type {string}
     * @memberof Account
     */
    userId?: string;
    /**
     * 
     * @type {boolean}
     * @memberof Account
     */
    authorized?: boolean;
    /**
     * 
     * @type {any}
     * @memberof Account
     */
    fields?: any | null;
    /**
     * 
     * @type {Date}
     * @memberof Account
     */
    created?: Date;
    /**
     * 
     * @type {Date}
     * @memberof Account
     */
    updated?: Date | null;
}



/**
 * Check if a given object implements the Account interface.
 */
export function instanceOfAccount(value: object): value is Account {
    if (!('id' in value) || value['id'] === undefined) return false;
    if (!('provider' in value) || value['provider'] === undefined) return false;
    return true;
}

export function AccountFromJSON(json: any): Account {
    return AccountFromJSONTyped(json, false);
}

export function AccountFromJSONTyped(json: any, ignoreDiscriminator: boolean): Account {
    if (json == null) {
        return json;
    }
    return {
        
        'id': json['id'],
        'name': json['name'] == null ? undefined : json['name'],
        'provider': LoginProviderFromJSON(json['provider']),
        'userId': json['user_id'] == null ? undefined : json['user_id'],
        'authorized': json['authorized'] == null ? undefined : json['authorized'],
        'fields': json['fields'] == null ? undefined : json['fields'],
        'created': json['created'] == null ? undefined : (new Date(json['created'])),
        'updated': json['updated'] == null ? undefined : (new Date(json['updated'])),
    };
}

export function AccountToJSON(json: any): Account {
    return AccountToJSONTyped(json, false);
}

export function AccountToJSONTyped(value?: Account | null, ignoreDiscriminator: boolean = false): any {
    if (value == null) {
        return value;
    }

    return {
        
        'id': value['id'],
        'name': value['name'],
        'provider': LoginProviderToJSON(value['provider']),
        'user_id': value['userId'],
        'authorized': value['authorized'],
        'fields': value['fields'],
        'created': value['created'] == null ? undefined : ((value['created']).toISOString()),
        'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()),
    };
}

