"""
Publications API namespace.

AUTO-GENERATED by scripts/generate_sdk.py - DO NOT EDIT MANUALLY!
Regenerate with: python scripts/generate_sdk.py --category publications
"""
from __future__ import annotations

from typing import Any, Dict, Optional

from ._base import AsyncBaseAPI, BaseAPI


class PublicationsAPI(BaseAPI):
    """Publications namespace: by_source, details, facets, latest, search."""

    def by_source(
        self,
        *,
        source_news_id: str,
        limit: Optional[int] = 50,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Get publications by source

        Publications from a specific source.

        Args:
        source_news_id: Source news ID
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        params["source_news_id"] = source_news_id
        if limit is not None:
            params["limit"] = limit
        return self._call("publications.by_source", params=params, options=options, context=context, response_format=response_format)

    def details(
        self,
        *,
        doc_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get publication details

        Full publication by ID.

        Args:
        doc_id: Document ID"""
        params: Dict[str, Any] = {}
        params["doc_id"] = doc_id
        return self._call("publications.details", params=params, options=options, context=context)

    def facets(
        self,
        *,
        filters: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get publication facets

        Available sources and types.

        Args:
        filters: Pre-filter"""
        params: Dict[str, Any] = {}
        if filters is not None:
            params["filters"] = filters
        return self._call("publications.facets", params=params, options=options, context=context)

    def latest(
        self,
        *,
        limit: Optional[int] = 20,
        filters: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Get latest publications

        Most recent publications.

        Args:
        limit: Maximum results
        filters: Source/type filters"""
        params: Dict[str, Any] = {}
        if limit is not None:
            params["limit"] = limit
        if filters is not None:
            params["filters"] = filters
        return self._call("publications.latest", params=params, options=options, context=context, response_format=response_format)

    def search(
        self,
        *,
        query: str,
        limit: Optional[int] = 20,
        start_date: Optional[str] = None,
        end_date: Optional[str] = None,
        filters: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Search publications

        Search research reports and publications.

        Args:
        query: Search query
        limit: Maximum results
        start_date: Start date (YYYY-MM-DD)
        end_date: End date (YYYY-MM-DD)
        filters: Source/type filters"""
        params: Dict[str, Any] = {}
        params["query"] = query
        if limit is not None:
            params["limit"] = limit
        if start_date is not None:
            params["start_date"] = start_date
        if end_date is not None:
            params["end_date"] = end_date
        if filters is not None:
            params["filters"] = filters
        return self._call("publications.search", params=params, options=options, context=context, response_format=response_format)



class AsyncPublicationsAPI(AsyncBaseAPI):
    """Publications namespace: by_source, details, facets, latest, search."""

    async def by_source(
        self,
        *,
        source_news_id: str,
        limit: Optional[int] = 50,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Get publications by source

        Publications from a specific source.

        Args:
        source_news_id: Source news ID
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        params["source_news_id"] = source_news_id
        if limit is not None:
            params["limit"] = limit
        return await self._call("publications.by_source", params=params, options=options, context=context, response_format=response_format)

    async def details(
        self,
        *,
        doc_id: str,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get publication details

        Full publication by ID.

        Args:
        doc_id: Document ID"""
        params: Dict[str, Any] = {}
        params["doc_id"] = doc_id
        return await self._call("publications.details", params=params, options=options, context=context)

    async def facets(
        self,
        *,
        filters: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Get publication facets

        Available sources and types.

        Args:
        filters: Pre-filter"""
        params: Dict[str, Any] = {}
        if filters is not None:
            params["filters"] = filters
        return await self._call("publications.facets", params=params, options=options, context=context)

    async def latest(
        self,
        *,
        limit: Optional[int] = 20,
        filters: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Get latest publications

        Most recent publications.

        Args:
        limit: Maximum results
        filters: Source/type filters"""
        params: Dict[str, Any] = {}
        if limit is not None:
            params["limit"] = limit
        if filters is not None:
            params["filters"] = filters
        return await self._call("publications.latest", params=params, options=options, context=context, response_format=response_format)

    async def search(
        self,
        *,
        query: str,
        limit: Optional[int] = 20,
        start_date: Optional[str] = None,
        end_date: Optional[str] = None,
        filters: Optional[Dict[str, Any]] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Search publications

        Search research reports and publications.

        Args:
        query: Search query
        limit: Maximum results
        start_date: Start date (YYYY-MM-DD)
        end_date: End date (YYYY-MM-DD)
        filters: Source/type filters"""
        params: Dict[str, Any] = {}
        params["query"] = query
        if limit is not None:
            params["limit"] = limit
        if start_date is not None:
            params["start_date"] = start_date
        if end_date is not None:
            params["end_date"] = end_date
        if filters is not None:
            params["filters"] = filters
        return await self._call("publications.search", params=params, options=options, context=context, response_format=response_format)


