/* tslint:disable */
/* eslint-disable */
/**
 * AskNews API
 * AskNews API [![status](https://status.asknews.app/api/badge/2/status?style=for-the-badge)](https://status.asknews.app/status/prod)
 *
 * The version of the OpenAPI document: 0.24.66
 * Contact: contact@emergentmethods.ai
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import type { AskNewsSource } from './AskNewsSource';
import {
    instanceOfAskNewsSource,
    AskNewsSourceFromJSON,
    AskNewsSourceFromJSONTyped,
    AskNewsSourceToJSON,
} from './AskNewsSource';
import type { BlueskySource } from './BlueskySource';
import {
    instanceOfBlueskySource,
    BlueskySourceFromJSON,
    BlueskySourceFromJSONTyped,
    BlueskySourceToJSON,
} from './BlueskySource';
import type { DeepNewsSource } from './DeepNewsSource';
import {
    instanceOfDeepNewsSource,
    DeepNewsSourceFromJSON,
    DeepNewsSourceFromJSONTyped,
    DeepNewsSourceToJSON,
} from './DeepNewsSource';
import type { TelegramSource } from './TelegramSource';
import {
    instanceOfTelegramSource,
    TelegramSourceFromJSON,
    TelegramSourceFromJSONTyped,
    TelegramSourceToJSON,
} from './TelegramSource';
import type { WebSource } from './WebSource';
import {
    instanceOfWebSource,
    WebSourceFromJSON,
    WebSourceFromJSONTyped,
    WebSourceToJSON,
} from './WebSource';

/**
 * @type SourcesInner
 * 
 * @export
 */
export type SourcesInner = { identifier: 'asknews' } & AskNewsSource | { identifier: 'bluesky' } & BlueskySource | { identifier: 'deepnews' } & DeepNewsSource | { identifier: 'telegram' } & TelegramSource | { identifier: 'web' } & WebSource;

export function SourcesInnerFromJSON(json: any): SourcesInner {
    return SourcesInnerFromJSONTyped(json, false);
}

export function SourcesInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): SourcesInner {
    if (json == null) {
        return json;
    }
    switch (json['identifier']) {
        case 'asknews':
            return Object.assign({}, AskNewsSourceFromJSONTyped(json, true), { identifier: 'asknews' } as const);
        case 'bluesky':
            return Object.assign({}, BlueskySourceFromJSONTyped(json, true), { identifier: 'bluesky' } as const);
        case 'deepnews':
            return Object.assign({}, DeepNewsSourceFromJSONTyped(json, true), { identifier: 'deepnews' } as const);
        case 'telegram':
            return Object.assign({}, TelegramSourceFromJSONTyped(json, true), { identifier: 'telegram' } as const);
        case 'web':
            return Object.assign({}, WebSourceFromJSONTyped(json, true), { identifier: 'web' } as const);
        default:
            throw new Error(`No variant of SourcesInner exists with 'identifier=${json['identifier']}'`);
    }
}

export function SourcesInnerToJSON(json: any): any {
    return SourcesInnerToJSONTyped(json, false);
}

export function SourcesInnerToJSONTyped(value?: SourcesInner | null, ignoreDiscriminator: boolean = false): any {
    if (value == null) {
        return value;
    }
    switch (value['identifier']) {
        case 'asknews':
            return Object.assign({}, AskNewsSourceToJSON(value), { identifier: 'asknews' } as const);
        case 'bluesky':
            return Object.assign({}, BlueskySourceToJSON(value), { identifier: 'bluesky' } as const);
        case 'deepnews':
            return Object.assign({}, DeepNewsSourceToJSON(value), { identifier: 'deepnews' } as const);
        case 'telegram':
            return Object.assign({}, TelegramSourceToJSON(value), { identifier: 'telegram' } as const);
        case 'web':
            return Object.assign({}, WebSourceToJSON(value), { identifier: 'web' } as const);
        default:
            throw new Error(`No variant of SourcesInner exists with 'identifier=${value['identifier']}'`);
    }

}

