from __future__ import annotations

from datetime import datetime
from typing import TYPE_CHECKING, List, Optional, Union, Any

if TYPE_CHECKING:
    from ..client import SyncPhraseTMSClient

from ..models import (
    LQAConversationDto,
    PageDtoCommonConversationDto,
    CreateLqaConversationDto,
    LQAConversationsListDto,
    FindConversationsDto,
    EditPlainConversationDto,
    ConversationListDto,
    AddCommentDto,
    AddPlainCommentResultDto,
    FindConversationsForProjectDto,
    PlainConversationsListDto,
    CreatePlainConversationDto,
    EditLqaConversationDto,
    AddLqaCommentResultDto,
    PlainConversationDto
    
)


class ConversationsOperations:
    def __init__(self, client: SyncPhraseTMSClient):
        self.client = client


    async def add_lqa_comment_v2(
        self,
        add_comment_dto: AddCommentDto,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> AddLqaCommentResultDto:
        """
        Operation id: addLQACommentV2
        Add LQA comment
        
        :param add_comment_dto: AddCommentDto (required), body. 
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: AddLqaCommentResultDto
        """
        endpoint = f"/api2/v2/jobs/{job_uid}/conversations/lqas/{conversation_id}/comments"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = add_comment_dto

        r = await self.client.make_request(
            "POST",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return AddLqaCommentResultDto(**r.json())
        


    async def add_plain_comment_v3(
        self,
        add_comment_dto: AddCommentDto,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> AddPlainCommentResultDto:
        """
        Operation id: addPlainCommentV3
        Add plain comment
        
        :param add_comment_dto: AddCommentDto (required), body. 
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: AddPlainCommentResultDto
        """
        endpoint = f"/api2/v3/jobs/{job_uid}/conversations/plains/{conversation_id}/comments"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = add_comment_dto

        r = await self.client.make_request(
            "POST",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return AddPlainCommentResultDto(**r.json())
        


    async def create_lqa_conversation_v2(
        self,
        create_lqa_conversation_dto: CreateLqaConversationDto,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> LQAConversationDto:
        """
        Operation id: createLqaConversationV2
        Create LQA conversation
        
        :param create_lqa_conversation_dto: CreateLqaConversationDto (required), body. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: LQAConversationDto
        """
        endpoint = f"/api2/v2/jobs/{job_uid}/conversations/lqas"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = create_lqa_conversation_dto

        r = await self.client.make_request(
            "POST",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return LQAConversationDto(**r.json())
        


    async def create_segment_target_conversation_v3(
        self,
        create_plain_conversation_dto: CreatePlainConversationDto,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> PlainConversationDto:
        """
        Operation id: createSegmentTargetConversationV3
        Create plain conversation
        
        :param create_plain_conversation_dto: CreatePlainConversationDto (required), body. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: PlainConversationDto
        """
        endpoint = f"/api2/v3/jobs/{job_uid}/conversations/plains"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = create_plain_conversation_dto

        r = await self.client.make_request(
            "POST",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return PlainConversationDto(**r.json())
        


    async def delete_lqa_comment(
        self,
        comment_id: str,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> None:
        """
        Operation id: deleteLQAComment
        Delete LQA comment
        
        :param comment_id: str (required), path. 
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: None
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/lqas/{conversation_id}/comments/{comment_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "DELETE",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return
        


    async def delete_lqa_conversation(
        self,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> None:
        """
        Operation id: deleteLQAConversation
        Delete LQA conversation
        
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: None
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/lqas/{conversation_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "DELETE",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return
        


    async def delete_plain_comment(
        self,
        comment_id: str,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> None:
        """
        Operation id: deletePlainComment
        Delete plain comment
        
        :param comment_id: str (required), path. 
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: None
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/plains/{conversation_id}/comments/{comment_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "DELETE",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return
        


    async def delete_plain_conversation(
        self,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> None:
        """
        Operation id: deletePlainConversation
        Delete plain conversation
        
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: None
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/plains/{conversation_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "DELETE",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return
        


    async def find_conversations(
        self,
        find_conversations_dto: FindConversationsDto,
        phrase_token: Optional[str] = None,
) -> ConversationListDto:
        """
        Operation id: findConversations
        Find all conversation
        
        :param find_conversations_dto: FindConversationsDto (required), body. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: ConversationListDto
        """
        endpoint = f"/api2/v1/jobs/conversations/find"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = find_conversations_dto

        r = await self.client.make_request(
            "POST",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return ConversationListDto(**r.json())
        


    async def get_lqa_conversation(
        self,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> LQAConversationDto:
        """
        Operation id: getLQAConversation
        Get LQA conversation
        
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: LQAConversationDto
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/lqas/{conversation_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "GET",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return LQAConversationDto(**r.json())
        


    async def get_plain_conversation(
        self,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> PlainConversationDto:
        """
        Operation id: getPlainConversation
        Get plain conversation
        
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: PlainConversationDto
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/plains/{conversation_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "GET",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return PlainConversationDto(**r.json())
        


    async def list_all_conversations(
        self,
        job_uid: str,
        include_deleted: Optional[bool] = False,
        since: Optional[str] = None,
        phrase_token: Optional[str] = None,
) -> ConversationListDto:
        """
        Operation id: listAllConversations
        List all conversations
        
        :param job_uid: str (required), path. 
        :param include_deleted: Optional[bool] = False (optional), query. 
        :param since: Optional[str] = None (optional), query. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: ConversationListDto
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations"
        params = {
            "includeDeleted": include_deleted,
            "since": since
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "GET",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return ConversationListDto(**r.json())
        


    async def list_lqa_conversations(
        self,
        job_uid: str,
        include_deleted: Optional[bool] = False,
        since: Optional[str] = None,
        phrase_token: Optional[str] = None,
) -> LQAConversationsListDto:
        """
        Operation id: listLQAConversations
        List LQA conversations
        
        :param job_uid: str (required), path. 
        :param include_deleted: Optional[bool] = False (optional), query. 
        :param since: Optional[str] = None (optional), query. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: LQAConversationsListDto
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/lqas"
        params = {
            "includeDeleted": include_deleted,
            "since": since
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "GET",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return LQAConversationsListDto(**r.json())
        


    async def list_plain_conversations(
        self,
        job_uid: str,
        include_deleted: Optional[bool] = False,
        since: Optional[str] = None,
        phrase_token: Optional[str] = None,
) -> PlainConversationsListDto:
        """
        Operation id: listPlainConversations
        List plain conversations
        
        :param job_uid: str (required), path. 
        :param include_deleted: Optional[bool] = False (optional), query. 
        :param since: Optional[str] = None (optional), query. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: PlainConversationsListDto
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/plains"
        params = {
            "includeDeleted": include_deleted,
            "since": since
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = None

        r = await self.client.make_request(
            "GET",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return PlainConversationsListDto(**r.json())
        


    async def search_by_project(
        self,
        find_conversations_for_project_dto: FindConversationsForProjectDto,
        phrase_token: Optional[str] = None,
) -> PageDtoCommonConversationDto:
        """
        Operation id: searchByProject
        Search conversation by project
        This endpoint is allowed only to PM and ADMIN roles.
        :param find_conversations_for_project_dto: FindConversationsForProjectDto (required), body. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: PageDtoCommonConversationDto
        """
        endpoint = f"/api2/v1/jobs/conversations/searchByProject"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = find_conversations_for_project_dto

        r = await self.client.make_request(
            "POST",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return PageDtoCommonConversationDto(**r.json())
        


    async def update_lqa_comment_v2(
        self,
        add_comment_dto: AddCommentDto,
        comment_id: str,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> LQAConversationDto:
        """
        Operation id: updateLQACommentV2
        Edit LQA comment
        
        :param add_comment_dto: AddCommentDto (required), body. 
        :param comment_id: str (required), path. 
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: LQAConversationDto
        """
        endpoint = f"/api2/v2/jobs/{job_uid}/conversations/lqas/{conversation_id}/comments/{comment_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = add_comment_dto

        r = await self.client.make_request(
            "PUT",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return LQAConversationDto(**r.json())
        


    async def update_lqa_conversation_v2(
        self,
        edit_lqa_conversation_dto: EditLqaConversationDto,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> LQAConversationDto:
        """
        Operation id: updateLqaConversationV2
        Update LQA conversation
        
        :param edit_lqa_conversation_dto: EditLqaConversationDto (required), body. 
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: LQAConversationDto
        """
        endpoint = f"/api2/v2/jobs/{job_uid}/conversations/lqas/{conversation_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = edit_lqa_conversation_dto

        r = await self.client.make_request(
            "PUT",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return LQAConversationDto(**r.json())
        


    async def update_plain_comment_v3(
        self,
        add_comment_dto: AddCommentDto,
        comment_id: str,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> PlainConversationDto:
        """
        Operation id: updatePlainCommentV3
        Edit plain comment
        
        :param add_comment_dto: AddCommentDto (required), body. 
        :param comment_id: str (required), path. 
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: PlainConversationDto
        """
        endpoint = f"/api2/v3/jobs/{job_uid}/conversations/plains/{conversation_id}/comments/{comment_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = add_comment_dto

        r = await self.client.make_request(
            "PUT",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return PlainConversationDto(**r.json())
        


    async def update_plain_conversation(
        self,
        edit_plain_conversation_dto: EditPlainConversationDto,
        conversation_id: str,
        job_uid: str,
        phrase_token: Optional[str] = None,
) -> PlainConversationDto:
        """
        Operation id: updatePlainConversation
        Edit plain conversation
        
        :param edit_plain_conversation_dto: EditPlainConversationDto (required), body. 
        :param conversation_id: str (required), path. 
        :param job_uid: str (required), path. 
        
        :param phrase_token: string (optional) - if not supplied, client will look for token from init

        :return: PlainConversationDto
        """
        endpoint = f"/api2/v1/jobs/{job_uid}/conversations/plains/{conversation_id}"
        params = {
            
        }
        headers = {
            
        }

        content = None

        files = None

        payload = edit_plain_conversation_dto

        r = await self.client.make_request(
            "PUT",
            endpoint,
            phrase_token,
            params=params,
            payload=payload,
            files=files,
            headers=headers,
            content=content
        )

        
        return PlainConversationDto(**r.json())
        



if __name__ == '__main__':
    print("This module is not intended to be run directly.")