from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.base_request_builder import BaseRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from kiota_abstractions.default_query_parameters import QueryParameters
from kiota_abstractions.get_path_parameters import get_path_parameters
from kiota_abstractions.method import Method
from kiota_abstractions.request_adapter import RequestAdapter
from kiota_abstractions.request_information import RequestInformation
from kiota_abstractions.request_option import RequestOption
from kiota_abstractions.serialization import Parsable, ParsableFactory
from typing import Any, Optional, TYPE_CHECKING, Union
from uuid import UUID
from warnings import warn

if TYPE_CHECKING:
    from .item.with_review_item_request_builder import WithReviewItemRequestBuilder
    from .reviews_get_response import ReviewsGetResponse
    from .reviews_post_request_body import ReviewsPostRequestBody
    from .reviews_post_response import ReviewsPostResponse

class ReviewsRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/reviews/v1/projects/{projectId}/reviews
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new ReviewsRequestBuilder and sets the default values.
        param path_parameters: The raw url or the url-template parameters for the request.
        param request_adapter: The request adapter to use to execute the requests.
        Returns: None
        """
        super().__init__(request_adapter, "{+baseurl}/construction/reviews/v1/projects/{projectId}/reviews{?filter%5BarchivedAt%5D*,filter%5BarchivedBy%5D*,filter%5Barchived%5D*,filter%5BcreatedAt%5D*,filter%5BcurrentStepDueDate%5D*,filter%5BfinishedAt%5D*,filter%5Bname%5D*,filter%5BnextActionByCompany%5D*,filter%5BnextActionByRole%5D*,filter%5BnextActionByUser%5D*,filter%5BsequenceId%5D*,filter%5Bstatus%5D*,filter%5BupdatedAt%5D*,filter%5BworkflowId%5D*,limit*,offset*,sort*}", path_parameters)
    
    def by_review_id(self,review_id: UUID) -> WithReviewItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.construction.reviews.v1.projects.item.reviews.item collection
        param review_id: The unique ID of the review.It must be in UUID format — not the numeric sequence ID shown in the Reviews UI. To find the review ID, call `GET reviews <en/docs/acc/v1/reference/http/reviews-reviews-GET/>`_.
        Returns: WithReviewItemRequestBuilder
        """
        if review_id is None:
            raise TypeError("review_id cannot be null.")
        from .item.with_review_item_request_builder import WithReviewItemRequestBuilder

        url_tpl_params = get_path_parameters(self.path_parameters)
        url_tpl_params["reviewId"] = review_id
        return WithReviewItemRequestBuilder(self.request_adapter, url_tpl_params)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[ReviewsRequestBuilderGetQueryParameters]] = None) -> Optional[ReviewsGetResponse]:
        """
        Retrieves the list of reviews created in the specified project.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[ReviewsGetResponse]
        """
        request_info = self.to_get_request_information(
            request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .reviews_get_response import ReviewsGetResponse

        return await self.request_adapter.send_async(request_info, ReviewsGetResponse, None)
    
    async def post(self,body: ReviewsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[ReviewsPostResponse]:
        """
        Creates a new review in the specified project using an existing approval workflow.
        param body: The request body
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[ReviewsPostResponse]
        """
        if body is None:
            raise TypeError("body cannot be null.")
        request_info = self.to_post_request_information(
            body, request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .reviews_post_response import ReviewsPostResponse

        return await self.request_adapter.send_async(request_info, ReviewsPostResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[ReviewsRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        Retrieves the list of reviews created in the specified project.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: RequestInformation
        """
        request_info = RequestInformation(Method.GET, self.url_template, self.path_parameters)
        request_info.configure(request_configuration)
        request_info.headers.try_add("Accept", "application/json")
        return request_info
    
    def to_post_request_information(self,body: ReviewsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> RequestInformation:
        """
        Creates a new review in the specified project using an existing approval workflow.
        param body: The request body
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: RequestInformation
        """
        if body is None:
            raise TypeError("body cannot be null.")
        request_info = RequestInformation(Method.POST, self.url_template, self.path_parameters)
        request_info.configure(request_configuration)
        request_info.headers.try_add("Accept", "application/json")
        request_info.set_content_from_parsable(self.request_adapter, "application/json", body)
        return request_info
    
    def with_url(self,raw_url: str) -> ReviewsRequestBuilder:
        """
        Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored.
        param raw_url: The raw URL to use for the request builder.
        Returns: ReviewsRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return ReviewsRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class ReviewsRequestBuilderGetQueryParameters():
        """
        Retrieves the list of reviews created in the specified project.
        """
        def get_query_parameter(self,original_name: str) -> str:
            """
            Maps the query parameters names to their encoded names for the URI template parsing.
            param original_name: The original query parameter name in the class.
            Returns: str
            """
            if original_name is None:
                raise TypeError("original_name cannot be null.")
            if original_name == "filterarchived":
                return "filter%5Barchived%5D"
            if original_name == "filterarchived_at":
                return "filter%5BarchivedAt%5D"
            if original_name == "filterarchived_by":
                return "filter%5BarchivedBy%5D"
            if original_name == "filtercreated_at":
                return "filter%5BcreatedAt%5D"
            if original_name == "filtercurrent_step_due_date":
                return "filter%5BcurrentStepDueDate%5D"
            if original_name == "filterfinished_at":
                return "filter%5BfinishedAt%5D"
            if original_name == "filtername":
                return "filter%5Bname%5D"
            if original_name == "filternext_action_by_company":
                return "filter%5BnextActionByCompany%5D"
            if original_name == "filternext_action_by_role":
                return "filter%5BnextActionByRole%5D"
            if original_name == "filternext_action_by_user":
                return "filter%5BnextActionByUser%5D"
            if original_name == "filtersequence_id":
                return "filter%5BsequenceId%5D"
            if original_name == "filterstatus":
                return "filter%5Bstatus%5D"
            if original_name == "filterupdated_at":
                return "filter%5BupdatedAt%5D"
            if original_name == "filterworkflow_id":
                return "filter%5BworkflowId%5D"
            if original_name == "limit":
                return "limit"
            if original_name == "offset":
                return "offset"
            if original_name == "sort":
                return "sort"
            return original_name
        
        # Filter by archive status in URL-encoded format.``true``: retrieves only archived reviews.``false``: retrieves only active (non-archived) reviews.If omitted, only active reviews are retrieved.For example: ``filter[archived]=false``.
        filterarchived: Optional[bool] = None

        # Filter by the date the review was archived, in URL-encoded format.It only applies if ``filter[archived]=true``.Provide a date range using the format ``startDate..endDate``.Both values must be in ISO 8601 format.For example: ``filter[archivedAt]=2023-06-01..2023-06-30``.
        filterarchived_at: Optional[str] = None

        # Filter by the Autodesk ID of the user who archived the review, in URL-encoded format. To find the ID, call `GET users </en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET/>`_.It only takes effect when ``filter[archived]=true`` is also set.For example: ``filter[archivedBy]=A96JX8NUKRLVFWSR``.
        filterarchived_by: Optional[str] = None

        # Filter by review creation date in URL-encoded format.Provide a date range using the format ``startDate..endDate``.Both values must be in ISO 8601 format.For example: ``filter[createdAt]=2023-06-01..2023-06-30``
        filtercreated_at: Optional[str] = None

        # Filter by the due date of the current review step in URL-encoded format.Provide a date range using the format ``startDate..endDate``.Both values must be in ISO 8601 format.For example: ``filter[updatedAt]=2023-06-01..2023-06-30``.
        filtercurrent_step_due_date: Optional[str] = None

        # Filter by the date the review was finished, in URL-encoded format.Provide a date range using the format ``startDate..endDate``.Both values must be in ISO 8601 format.For example: ``filter[finishedAt]=2023-06-01..2023-06-30``.
        filterfinished_at: Optional[str] = None

        # Filter by review name in URL-encoded format.Retrieves reviews with names that contain the specified string (not case-sensitive).For example: ``filter[name]=Apartment`` retrieves reviews like ``Apartment Block A`` and ``apartment_rendering``.
        filtername: Optional[str] = None

        # Filter by Autodesk ID of a company responsible for the next action, in URL-encoded format.For example: ``filter[nextActionByCompany]=81768771``.
        filternext_action_by_company: Optional[str] = None

        # Filter by Autodesk ID of a role responsible for the next action, in URL-encoded format.For example: ``filter[nextActionByRole]=1572818``.
        filternext_action_by_role: Optional[str] = None

        # Filter by Autodesk ID of a user responsible for the next action, in URL-encoded format.This includes reviews assigned directly to the user or to their role or company.For example: ``filter[nextActionByUser]=A96JX8NUKRLVFWSR``.
        filternext_action_by_user: Optional[str] = None

        # Filter by review sequence ID in URL-encoded format.Retrieves reviews with sequence IDs that partially match the specified number.For example: ``filter[sequenceId]=11`` may retrieve ``113`` and ``211``.
        filtersequence_id: Optional[int] = None

        # Filter by the review status in URL-encoded format.Possible values: ``OPEN``, ``CLOSED``, ``VOID``, ``FAILED``.For example: ``filter[status]=OPEN``.Reviews with status ``FAILED`` are only visible to project administrators.
        filterstatus: Optional[str] = None

        # Filter by the review’s last updated date in URL-encoded format.Provide a date range using the format ``startDate..endDate``.Both values must be in ISO 8601 format.For example: ``filter[updatedAt]=2023-06-01..2023-06-30``.
        filterupdated_at: Optional[str] = None

        # Filter by a specific approval workflow ID in URL-encoded format.For example: ``filter[workflowId]=497f6eca-6276-4993-bfeb-53cbbbba6f08``.
        filterworkflow_id: Optional[UUID] = None

        # The maximum number of reviews to retrieve.Possible values: ``1-50``. Maximum: ``50``. Default: ``50``. For example: ``limit=2``.
        limit: Optional[int] = None

        # The index of the first result to return (zero-based).Default: ``0``. For example: ``offset=10``.
        offset: Optional[int] = None

        # Sorts the results by a single field.Use the format ``fieldName`` (ascending) or ``fieldName desc`` (descending).If no direction is specified, sorting defaults to ascending.Possible values: ``name``, ``status``, ``sequenceId``, ``currentStepDueDate``, ``createdAt``, ``finishedAt``.For example: ``sort=createdAt desc``.
        sort: Optional[str] = None

    
    @dataclass
    class ReviewsRequestBuilderGetRequestConfiguration(RequestConfiguration[ReviewsRequestBuilderGetQueryParameters]):
        """
        Configuration for the request such as headers, query parameters, and middleware options.
        """
        warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)
    
    @dataclass
    class ReviewsRequestBuilderPostRequestConfiguration(RequestConfiguration[QueryParameters]):
        """
        Configuration for the request such as headers, query parameters, and middleware options.
        """
        warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)
    

