/* 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 * as runtime from '../runtime';
import {
    type HTTPValidationError,
    HTTPValidationErrorFromJSON,
    HTTPValidationErrorToJSON,
} from '../models/HTTPValidationError';
import {
    type NewsAnalysisResponse,
    NewsAnalysisResponseFromJSON,
    NewsAnalysisResponseToJSON,
} from '../models/NewsAnalysisResponse';
import {
    type NewsItemOut,
    NewsItemOutFromJSON,
    NewsItemOutToJSON,
} from '../models/NewsItemOut';
import {
    type NewsListResponse,
    NewsListResponseFromJSON,
    NewsListResponseToJSON,
} from '../models/NewsListResponse';

export interface AnalyzeNewsApiV1NewsNewsIdAnalyzePostRequest {
    newsId: string;
}

export interface GetNewsApiV1NewsNewsIdGetRequest {
    newsId: string;
}

export interface ListNewsApiV1NewsPostRequest {
    chain?: string | null;
    token?: string | null;
    category?: string | null;
    sinceHours?: number;
    limit?: number;
    offset?: number;
    sort?: string;
}

export interface TrendingNewsApiV1NewsTrendingGetRequest {
    windowHours?: number;
    limit?: number;
}

/**
 * 
 */
export class NewsApi extends runtime.BaseAPI {

    /**
     * Creates request options for analyzeNewsApiV1NewsNewsIdAnalyzePost without sending the request
     */
    async analyzeNewsApiV1NewsNewsIdAnalyzePostRequestOpts(requestParameters: AnalyzeNewsApiV1NewsNewsIdAnalyzePostRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['newsId'] == null) {
            throw new runtime.RequiredError(
                'newsId',
                'Required parameter "newsId" was null or undefined when calling analyzeNewsApiV1NewsNewsIdAnalyzePost().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/api/v1/news/{news_id}/analyze`;
        urlPath = urlPath.replace('{news_id}', encodeURIComponent(String(requestParameters['newsId'])));

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Generate LLM analysis via LiteLLM. Falls back to None if LLM unreachable.
     * Analyze News
     */
    async analyzeNewsApiV1NewsNewsIdAnalyzePostRaw(requestParameters: AnalyzeNewsApiV1NewsNewsIdAnalyzePostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<NewsAnalysisResponse>> {
        const requestOptions = await this.analyzeNewsApiV1NewsNewsIdAnalyzePostRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => NewsAnalysisResponseFromJSON(jsonValue));
    }

    /**
     * Generate LLM analysis via LiteLLM. Falls back to None if LLM unreachable.
     * Analyze News
     */
    async analyzeNewsApiV1NewsNewsIdAnalyzePost(requestParameters: AnalyzeNewsApiV1NewsNewsIdAnalyzePostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<NewsAnalysisResponse> {
        const response = await this.analyzeNewsApiV1NewsNewsIdAnalyzePostRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for getNewsApiV1NewsNewsIdGet without sending the request
     */
    async getNewsApiV1NewsNewsIdGetRequestOpts(requestParameters: GetNewsApiV1NewsNewsIdGetRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['newsId'] == null) {
            throw new runtime.RequiredError(
                'newsId',
                'Required parameter "newsId" was null or undefined when calling getNewsApiV1NewsNewsIdGet().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/api/v1/news/{news_id}`;
        urlPath = urlPath.replace('{news_id}', encodeURIComponent(String(requestParameters['newsId'])));

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Single news item. Searches both news_items and crypto_news.
     * Get News
     */
    async getNewsApiV1NewsNewsIdGetRaw(requestParameters: GetNewsApiV1NewsNewsIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<NewsItemOut>> {
        const requestOptions = await this.getNewsApiV1NewsNewsIdGetRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => NewsItemOutFromJSON(jsonValue));
    }

    /**
     * Single news item. Searches both news_items and crypto_news.
     * Get News
     */
    async getNewsApiV1NewsNewsIdGet(requestParameters: GetNewsApiV1NewsNewsIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<NewsItemOut> {
        const response = await this.getNewsApiV1NewsNewsIdGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for listNewsApiV1NewsPost without sending the request
     */
    async listNewsApiV1NewsPostRequestOpts(requestParameters: ListNewsApiV1NewsPostRequest): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters['chain'] != null) {
            queryParameters['chain'] = requestParameters['chain'];
        }

        if (requestParameters['token'] != null) {
            queryParameters['token'] = requestParameters['token'];
        }

        if (requestParameters['category'] != null) {
            queryParameters['category'] = requestParameters['category'];
        }

        if (requestParameters['sinceHours'] != null) {
            queryParameters['since_hours'] = requestParameters['sinceHours'];
        }

        if (requestParameters['limit'] != null) {
            queryParameters['limit'] = requestParameters['limit'];
        }

        if (requestParameters['offset'] != null) {
            queryParameters['offset'] = requestParameters['offset'];
        }

        if (requestParameters['sort'] != null) {
            queryParameters['sort'] = requestParameters['sort'];
        }

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/api/v1/news`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * List news items with filters. Reads from both news_items (new) and crypto_news (legacy).
     * List News
     */
    async listNewsApiV1NewsPostRaw(requestParameters: ListNewsApiV1NewsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<NewsListResponse>> {
        const requestOptions = await this.listNewsApiV1NewsPostRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => NewsListResponseFromJSON(jsonValue));
    }

    /**
     * List news items with filters. Reads from both news_items (new) and crypto_news (legacy).
     * List News
     */
    async listNewsApiV1NewsPost(requestParameters: ListNewsApiV1NewsPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<NewsListResponse> {
        const response = await this.listNewsApiV1NewsPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for trendingNewsApiV1NewsTrendingGet without sending the request
     */
    async trendingNewsApiV1NewsTrendingGetRequestOpts(requestParameters: TrendingNewsApiV1NewsTrendingGetRequest): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters['windowHours'] != null) {
            queryParameters['window_hours'] = requestParameters['windowHours'];
        }

        if (requestParameters['limit'] != null) {
            queryParameters['limit'] = requestParameters['limit'];
        }

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/api/v1/news/trending`;

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Time-decay trending. Reads from news_items (new) primary, falls back to crypto_news (legacy).
     * Trending News
     */
    async trendingNewsApiV1NewsTrendingGetRaw(requestParameters: TrendingNewsApiV1NewsTrendingGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<NewsListResponse>> {
        const requestOptions = await this.trendingNewsApiV1NewsTrendingGetRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => NewsListResponseFromJSON(jsonValue));
    }

    /**
     * Time-decay trending. Reads from news_items (new) primary, falls back to crypto_news (legacy).
     * Trending News
     */
    async trendingNewsApiV1NewsTrendingGet(requestParameters: TrendingNewsApiV1NewsTrendingGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<NewsListResponse> {
        const response = await this.trendingNewsApiV1NewsTrendingGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
