/* 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 { TokenType } from './TokenType';
import {
    TokenTypeFromJSON,
    TokenTypeFromJSONTyped,
    TokenTypeToJSON,
    TokenTypeToJSONTyped,
} from './TokenType';

/**
 * 
 * @export
 * @interface TokenResponse
 */
export interface TokenResponse {
    /**
     * 
     * @type {TokenType}
     * @memberof TokenResponse
     */
    tokenType: TokenType;
    /**
     * 
     * @type {string}
     * @memberof TokenResponse
     */
    accessToken: string | null;
    /**
     * 
     * @type {string}
     * @memberof TokenResponse
     */
    refreshToken?: string | null;
    /**
     * 
     * @type {string}
     * @memberof TokenResponse
     */
    scope?: string | null;
    /**
     * 
     * @type {string}
     * @memberof TokenResponse
     */
    state?: string | null;
    /**
     * 
     * @type {number}
     * @memberof TokenResponse
     */
    expiresIn?: number;
}



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

export function TokenResponseFromJSON(json: any): TokenResponse {
    return TokenResponseFromJSONTyped(json, false);
}

export function TokenResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TokenResponse {
    if (json == null) {
        return json;
    }
    return {
        
        'tokenType': TokenTypeFromJSON(json['token_type']),
        'accessToken': json['access_token'],
        'refreshToken': json['refresh_token'] == null ? undefined : json['refresh_token'],
        'scope': json['scope'] == null ? undefined : json['scope'],
        'state': json['state'] == null ? undefined : json['state'],
        'expiresIn': json['expires_in'] == null ? undefined : json['expires_in'],
    };
}

export function TokenResponseToJSON(json: any): TokenResponse {
    return TokenResponseToJSONTyped(json, false);
}

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

    return {
        
        'token_type': TokenTypeToJSON(value['tokenType']),
        'access_token': value['accessToken'],
        'refresh_token': value['refreshToken'],
        'scope': value['scope'],
        'state': value['state'],
        'expires_in': value['expiresIn'],
    };
}

