/* 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 { AlertType } from './AlertType';
import {
    AlertTypeFromJSON,
    AlertTypeFromJSONTyped,
    AlertTypeToJSON,
    AlertTypeToJSONTyped,
} from './AlertType';

/**
 * A token alert subscription record (what we store in Redis).
 * @export
 * @interface AlertSubscription
 */
export interface AlertSubscription {
    /**
     * Unique subscription id, e.g. alert:1700000000
     * @type {string}
     * @memberof AlertSubscription
     */
    id: string;
    /**
     * 
     * @type {string}
     * @memberof AlertSubscription
     */
    tokenAddress: string;
    /**
     * 
     * @type {Array<AlertType>}
     * @memberof AlertSubscription
     */
    alertTypes?: Array<AlertType>;
    /**
     * 
     * @type {string}
     * @memberof AlertSubscription
     */
    webhookUrl?: string | null;
    /**
     * 
     * @type {Date}
     * @memberof AlertSubscription
     */
    createdAt?: Date;
    /**
     * 
     * @type {boolean}
     * @memberof AlertSubscription
     */
    active?: boolean;
    /**
     * User id of subscription owner, None = anonymous
     * @type {string}
     * @memberof AlertSubscription
     */
    ownerId?: string | null;
}

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

export function AlertSubscriptionFromJSON(json: any): AlertSubscription {
    return AlertSubscriptionFromJSONTyped(json, false);
}

export function AlertSubscriptionFromJSONTyped(json: any, ignoreDiscriminator: boolean): AlertSubscription {
    if (json == null) {
        return json;
    }
    return {
        
        'id': json['id'],
        'tokenAddress': json['token_address'],
        'alertTypes': json['alert_types'] == null ? undefined : ((json['alert_types'] as Array<any>).map(AlertTypeFromJSON)),
        'webhookUrl': json['webhook_url'] == null ? undefined : json['webhook_url'],
        'createdAt': json['created_at'] == null ? undefined : (new Date(json['created_at'])),
        'active': json['active'] == null ? undefined : json['active'],
        'ownerId': json['owner_id'] == null ? undefined : json['owner_id'],
    };
}

export function AlertSubscriptionToJSON(json: any): AlertSubscription {
    return AlertSubscriptionToJSONTyped(json, false);
}

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

    return {
        
        'id': value['id'],
        'token_address': value['tokenAddress'],
        'alert_types': value['alertTypes'] == null ? undefined : ((value['alertTypes'] as Array<any>).map(AlertTypeToJSON)),
        'webhook_url': value['webhookUrl'],
        'created_at': value['createdAt'] == null ? value['createdAt'] : value['createdAt'].toISOString(),
        'active': value['active'],
        'owner_id': value['ownerId'],
    };
}

