# This file was auto-generated by Fern from our API Definition.

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.batch_scrape_options import BatchScrapeOptions
from ..types.job_list_response import JobListResponse
from ..types.job_status_response import JobStatusResponse
from ..types.scrape_options import ScrapeOptions
from ..types.scrape_response import ScrapeResponse
from ..types.site_analysis_response import SiteAnalysisResponse
from .raw_client import AsyncRawWebScrapingClient, RawWebScrapingClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class WebScrapingClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawWebScrapingClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawWebScrapingClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawWebScrapingClient
        """
        return self._raw_client

    def scrape_url(
        self,
        *,
        url: str,
        schema: typing.Dict[str, typing.Any],
        organization_id: typing.Optional[str] = OMIT,
        options: typing.Optional[ScrapeOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ScrapeResponse:
        """
        Scrape a single URL and extract structured data.

        Supports both synchronous and asynchronous processing modes:
        - sync=true: Wait for results (good for small/fast sites)
        - sync=false: Return job_id immediately (good for large operations)

        Parameters
        ----------
        url : str
            URL to scrape

        schema : typing.Dict[str, typing.Any]
            Data extraction schema

        organization_id : typing.Optional[str]
            Organization ID (org_ prefixed string). Optional for API key auth - defaults to API key's organization.

        options : typing.Optional[ScrapeOptions]
            Scraping options

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ScrapeResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.scrape_url(
            url="url",
            schema={"key": "value"},
        )
        """
        _response = self._raw_client.scrape_url(
            url=url, schema=schema, organization_id=organization_id, options=options, request_options=request_options
        )
        return _response.data

    def scrape_batch(
        self,
        *,
        urls: typing.Sequence[str],
        schema: typing.Dict[str, typing.Any],
        organization_id: typing.Optional[str] = OMIT,
        options: typing.Optional[BatchScrapeOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Scrape multiple URLs in batch with optimized parallel processing.

        Processes multiple URLs in parallel with resource management and progress tracking.
        Returns batch ID and progress information for monitoring.

        Parameters
        ----------
        urls : typing.Sequence[str]
            URLs to scrape

        schema : typing.Dict[str, typing.Any]
            Data extraction schema

        organization_id : typing.Optional[str]
            Organization ID (org_ prefixed string). Optional for API key auth - defaults to API key's organization.

        options : typing.Optional[BatchScrapeOptions]
            Batch options

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.scrape_batch(
            urls=["urls"],
            schema={"key": "value"},
        )
        """
        _response = self._raw_client.scrape_batch(
            urls=urls, schema=schema, organization_id=organization_id, options=options, request_options=request_options
        )
        return _response.data

    def analyze_site(
        self, *, url: str, request_options: typing.Optional[RequestOptions] = None
    ) -> SiteAnalysisResponse:
        """
        Analyze a website to determine scraping strategy and complexity.

        Returns site characteristics, recommended engine, and processing estimates.

        Parameters
        ----------
        url : str
            URL to analyze

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SiteAnalysisResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.analyze_site(
            url="url",
        )
        """
        _response = self._raw_client.analyze_site(url=url, request_options=request_options)
        return _response.data

    def list_jobs(
        self,
        *,
        status: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> JobListResponse:
        """
        List scraping jobs for the authenticated user.

        Supports filtering by status and pagination.

        Parameters
        ----------
        status : typing.Optional[str]

        limit : typing.Optional[int]

        offset : typing.Optional[int]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        JobListResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.list_jobs()
        """
        _response = self._raw_client.list_jobs(
            status=status, limit=limit, offset=offset, request_options=request_options
        )
        return _response.data

    def get_job(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get details and results of a specific scraping job.

        Returns job status and raw extracted_data in the format defined by your schema.

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.get_job(
            job_id="job_id",
        )
        """
        _response = self._raw_client.get_job(job_id, request_options=request_options)
        return _response.data

    def cancel_job(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Cancel a pending or running scraping job.

        Only jobs in pending or processing status can be cancelled.

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.cancel_job(
            job_id="job_id",
        )
        """
        _response = self._raw_client.cancel_job(job_id, request_options=request_options)
        return _response.data

    def get_job_status(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> JobStatusResponse:
        """
        Get current status of a scraping job.

        Lightweight endpoint for checking job progress.

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        JobStatusResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.get_job_status(
            job_id="job_id",
        )
        """
        _response = self._raw_client.get_job_status(job_id, request_options=request_options)
        return _response.data

    def stream_job_progress(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Stream real-time progress updates for a scraping job.

        Returns Server-Sent Events (SSE) with job status updates.

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.stream_job_progress(
            job_id="job_id",
        )
        """
        _response = self._raw_client.stream_job_progress(job_id, request_options=request_options)
        return _response.data

    def get_batch_progress(
        self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get progress information for a batch processing operation.

        Returns detailed progress including completed/failed jobs, items extracted,
        and estimated completion time.

        Parameters
        ----------
        batch_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.get_batch_progress(
            batch_id="batch_id",
        )
        """
        _response = self._raw_client.get_batch_progress(batch_id, request_options=request_options)
        return _response.data

    def cancel_batch(
        self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Cancel all jobs in a batch processing operation.

        Cancels all pending and processing jobs in the specified batch.

        Parameters
        ----------
        batch_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.cancel_batch(
            batch_id="batch_id",
        )
        """
        _response = self._raw_client.cancel_batch(batch_id, request_options=request_options)
        return _response.data

    def get_resource_stats(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get current system resource utilization statistics.

        Returns information about active jobs, domain distribution,
        and resource utilization for monitoring purposes.

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.get_resource_stats()
        """
        _response = self._raw_client.get_resource_stats(request_options=request_options)
        return _response.data

    def optimize_batch_order(
        self, *, request: typing.Dict[str, typing.Any], request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Optimize the processing order for a batch of URLs.

        Analyzes cache status and domain distribution to suggest
        an optimal processing order for better performance.

        Parameters
        ----------
        request : typing.Dict[str, typing.Any]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.optimize_batch_order(
            request={"key": "value"},
        )
        """
        _response = self._raw_client.optimize_batch_order(request=request, request_options=request_options)
        return _response.data

    def get_job_progress(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get detailed progress for a scraping job with pagination tracking.

        Returns real-time progress information including:
        - Current page being scraped
        - Total pages scraped so far
        - Total properties found
        - Progress percentage
        - Pagination completion status

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.web_scraping.get_job_progress(
            job_id="job_id",
        )
        """
        _response = self._raw_client.get_job_progress(job_id, request_options=request_options)
        return _response.data


class AsyncWebScrapingClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawWebScrapingClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawWebScrapingClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawWebScrapingClient
        """
        return self._raw_client

    async def scrape_url(
        self,
        *,
        url: str,
        schema: typing.Dict[str, typing.Any],
        organization_id: typing.Optional[str] = OMIT,
        options: typing.Optional[ScrapeOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ScrapeResponse:
        """
        Scrape a single URL and extract structured data.

        Supports both synchronous and asynchronous processing modes:
        - sync=true: Wait for results (good for small/fast sites)
        - sync=false: Return job_id immediately (good for large operations)

        Parameters
        ----------
        url : str
            URL to scrape

        schema : typing.Dict[str, typing.Any]
            Data extraction schema

        organization_id : typing.Optional[str]
            Organization ID (org_ prefixed string). Optional for API key auth - defaults to API key's organization.

        options : typing.Optional[ScrapeOptions]
            Scraping options

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ScrapeResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.scrape_url(
                url="url",
                schema={"key": "value"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.scrape_url(
            url=url, schema=schema, organization_id=organization_id, options=options, request_options=request_options
        )
        return _response.data

    async def scrape_batch(
        self,
        *,
        urls: typing.Sequence[str],
        schema: typing.Dict[str, typing.Any],
        organization_id: typing.Optional[str] = OMIT,
        options: typing.Optional[BatchScrapeOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Scrape multiple URLs in batch with optimized parallel processing.

        Processes multiple URLs in parallel with resource management and progress tracking.
        Returns batch ID and progress information for monitoring.

        Parameters
        ----------
        urls : typing.Sequence[str]
            URLs to scrape

        schema : typing.Dict[str, typing.Any]
            Data extraction schema

        organization_id : typing.Optional[str]
            Organization ID (org_ prefixed string). Optional for API key auth - defaults to API key's organization.

        options : typing.Optional[BatchScrapeOptions]
            Batch options

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.scrape_batch(
                urls=["urls"],
                schema={"key": "value"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.scrape_batch(
            urls=urls, schema=schema, organization_id=organization_id, options=options, request_options=request_options
        )
        return _response.data

    async def analyze_site(
        self, *, url: str, request_options: typing.Optional[RequestOptions] = None
    ) -> SiteAnalysisResponse:
        """
        Analyze a website to determine scraping strategy and complexity.

        Returns site characteristics, recommended engine, and processing estimates.

        Parameters
        ----------
        url : str
            URL to analyze

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SiteAnalysisResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.analyze_site(
                url="url",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.analyze_site(url=url, request_options=request_options)
        return _response.data

    async def list_jobs(
        self,
        *,
        status: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> JobListResponse:
        """
        List scraping jobs for the authenticated user.

        Supports filtering by status and pagination.

        Parameters
        ----------
        status : typing.Optional[str]

        limit : typing.Optional[int]

        offset : typing.Optional[int]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        JobListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.list_jobs()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_jobs(
            status=status, limit=limit, offset=offset, request_options=request_options
        )
        return _response.data

    async def get_job(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get details and results of a specific scraping job.

        Returns job status and raw extracted_data in the format defined by your schema.

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.get_job(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_job(job_id, request_options=request_options)
        return _response.data

    async def cancel_job(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Cancel a pending or running scraping job.

        Only jobs in pending or processing status can be cancelled.

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.cancel_job(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.cancel_job(job_id, request_options=request_options)
        return _response.data

    async def get_job_status(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> JobStatusResponse:
        """
        Get current status of a scraping job.

        Lightweight endpoint for checking job progress.

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        JobStatusResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.get_job_status(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_job_status(job_id, request_options=request_options)
        return _response.data

    async def stream_job_progress(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Stream real-time progress updates for a scraping job.

        Returns Server-Sent Events (SSE) with job status updates.

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.stream_job_progress(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.stream_job_progress(job_id, request_options=request_options)
        return _response.data

    async def get_batch_progress(
        self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get progress information for a batch processing operation.

        Returns detailed progress including completed/failed jobs, items extracted,
        and estimated completion time.

        Parameters
        ----------
        batch_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.get_batch_progress(
                batch_id="batch_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_batch_progress(batch_id, request_options=request_options)
        return _response.data

    async def cancel_batch(
        self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Cancel all jobs in a batch processing operation.

        Cancels all pending and processing jobs in the specified batch.

        Parameters
        ----------
        batch_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.cancel_batch(
                batch_id="batch_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.cancel_batch(batch_id, request_options=request_options)
        return _response.data

    async def get_resource_stats(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get current system resource utilization statistics.

        Returns information about active jobs, domain distribution,
        and resource utilization for monitoring purposes.

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.get_resource_stats()


        asyncio.run(main())
        """
        _response = await self._raw_client.get_resource_stats(request_options=request_options)
        return _response.data

    async def optimize_batch_order(
        self, *, request: typing.Dict[str, typing.Any], request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Optimize the processing order for a batch of URLs.

        Analyzes cache status and domain distribution to suggest
        an optimal processing order for better performance.

        Parameters
        ----------
        request : typing.Dict[str, typing.Any]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.optimize_batch_order(
                request={"key": "value"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.optimize_batch_order(request=request, request_options=request_options)
        return _response.data

    async def get_job_progress(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Get detailed progress for a scraping job with pagination tracking.

        Returns real-time progress information including:
        - Current page being scraped
        - Total pages scraped so far
        - Total properties found
        - Progress percentage
        - Pagination completion status

        Parameters
        ----------
        job_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.web_scraping.get_job_progress(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_job_progress(job_id, request_options=request_options)
        return _response.data
