/* tslint:disable */
/* eslint-disable */
/**
 * RMI Backend
 * Rug Munch Intelligence — institutional-grade crypto intelligence API. 13+ chains, 96 data providers, 8 MCP tools, x402 paid tier, sovereign-first FOSS.
 *
 * The version of the OpenAPI document: 2026.06.21
 * 
 *
 * 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 { TokenHolding } from './TokenHolding';
import {
    TokenHoldingFromJSON,
    TokenHoldingFromJSONTyped,
    TokenHoldingToJSON,
    TokenHoldingToJSONTyped,
} from './TokenHolding';

/**
 * Wallet balance + token holdings.
 * @export
 * @interface Balance
 */
export interface Balance {
    /**
     * 
     * @type {string}
     * @memberof Balance
     */
    address: string;
    /**
     * 
     * @type {string}
     * @memberof Balance
     */
    chain: string;
    /**
     * 
     * @type {number}
     * @memberof Balance
     */
    nativeBalance?: number;
    /**
     * 
     * @type {string}
     * @memberof Balance
     */
    nativeSymbol?: string;
    /**
     * 
     * @type {number}
     * @memberof Balance
     */
    totalValueUsd?: number;
    /**
     * 
     * @type {Array<TokenHolding>}
     * @memberof Balance
     */
    tokens?: Array<TokenHolding>;
    /**
     * 
     * @type {Date}
     * @memberof Balance
     */
    fetchedAt?: Date;
}

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

export function BalanceFromJSON(json: any): Balance {
    return BalanceFromJSONTyped(json, false);
}

export function BalanceFromJSONTyped(json: any, ignoreDiscriminator: boolean): Balance {
    if (json == null) {
        return json;
    }
    return {
        
        'address': json['address'],
        'chain': json['chain'],
        'nativeBalance': json['native_balance'] == null ? undefined : json['native_balance'],
        'nativeSymbol': json['native_symbol'] == null ? undefined : json['native_symbol'],
        'totalValueUsd': json['total_value_usd'] == null ? undefined : json['total_value_usd'],
        'tokens': json['tokens'] == null ? undefined : ((json['tokens'] as Array<any>).map(TokenHoldingFromJSON)),
        'fetchedAt': json['fetched_at'] == null ? undefined : (new Date(json['fetched_at'])),
    };
}

export function BalanceToJSON(json: any): Balance {
    return BalanceToJSONTyped(json, false);
}

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

    return {
        
        'address': value['address'],
        'chain': value['chain'],
        'native_balance': value['nativeBalance'],
        'native_symbol': value['nativeSymbol'],
        'total_value_usd': value['totalValueUsd'],
        'tokens': value['tokens'] == null ? undefined : ((value['tokens'] as Array<any>).map(TokenHoldingToJSON)),
        'fetched_at': value['fetchedAt'] == null ? value['fetchedAt'] : value['fetchedAt'].toISOString(),
    };
}

