# Code generated by Lark OpenAPI.

import io
from typing import Any, Optional, Union, Dict, List, Set, IO, Callable, Type
from lark_oapi.core.const import UTF_8, CONTENT_TYPE, APPLICATION_JSON
from lark_oapi.core import JSON
from lark_oapi.core.token import verify
from lark_oapi.core.http import Transport
from lark_oapi.core.model import Config, RequestOption, RawResponse
from lark_oapi.core.utils import Files
from requests_toolbelt import MultipartEncoder
from ..model.create_aily_session_request import CreateAilySessionRequest
from ..model.create_aily_session_response import CreateAilySessionResponse
from ..model.delete_aily_session_request import DeleteAilySessionRequest
from ..model.delete_aily_session_response import DeleteAilySessionResponse
from ..model.get_aily_session_request import GetAilySessionRequest
from ..model.get_aily_session_response import GetAilySessionResponse
from ..model.update_aily_session_request import UpdateAilySessionRequest
from ..model.update_aily_session_response import UpdateAilySessionResponse


class AilySession(object):
    def __init__(self, config: Config) -> None:
        self.config: Config = config

    def create(self, request: CreateAilySessionRequest,
               option: Optional[RequestOption] = None) -> CreateAilySessionResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 添加 content-type
        if request.body is not None:
            option.headers[CONTENT_TYPE] = f"{APPLICATION_JSON}; charset=utf-8"

        # 发起请求
        resp: RawResponse = Transport.execute(self.config, request, option)

        # 反序列化
        response: CreateAilySessionResponse = JSON.unmarshal(str(resp.content, UTF_8), CreateAilySessionResponse)
        response.raw = resp

        return response

    async def acreate(self, request: CreateAilySessionRequest,
                      option: Optional[RequestOption] = None) -> CreateAilySessionResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 发起请求
        resp: RawResponse = await Transport.aexecute(self.config, request, option)

        # 反序列化
        response: CreateAilySessionResponse = JSON.unmarshal(str(resp.content, UTF_8), CreateAilySessionResponse)
        response.raw = resp

        return response

    def delete(self, request: DeleteAilySessionRequest,
               option: Optional[RequestOption] = None) -> DeleteAilySessionResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 添加 content-type
        if request.body is not None:
            option.headers[CONTENT_TYPE] = f"{APPLICATION_JSON}; charset=utf-8"

        # 发起请求
        resp: RawResponse = Transport.execute(self.config, request, option)

        # 反序列化
        response: DeleteAilySessionResponse = JSON.unmarshal(str(resp.content, UTF_8), DeleteAilySessionResponse)
        response.raw = resp

        return response

    async def adelete(self, request: DeleteAilySessionRequest,
                      option: Optional[RequestOption] = None) -> DeleteAilySessionResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 发起请求
        resp: RawResponse = await Transport.aexecute(self.config, request, option)

        # 反序列化
        response: DeleteAilySessionResponse = JSON.unmarshal(str(resp.content, UTF_8), DeleteAilySessionResponse)
        response.raw = resp

        return response

    def get(self, request: GetAilySessionRequest, option: Optional[RequestOption] = None) -> GetAilySessionResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 添加 content-type
        if request.body is not None:
            option.headers[CONTENT_TYPE] = f"{APPLICATION_JSON}; charset=utf-8"

        # 发起请求
        resp: RawResponse = Transport.execute(self.config, request, option)

        # 反序列化
        response: GetAilySessionResponse = JSON.unmarshal(str(resp.content, UTF_8), GetAilySessionResponse)
        response.raw = resp

        return response

    async def aget(self, request: GetAilySessionRequest,
                   option: Optional[RequestOption] = None) -> GetAilySessionResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 发起请求
        resp: RawResponse = await Transport.aexecute(self.config, request, option)

        # 反序列化
        response: GetAilySessionResponse = JSON.unmarshal(str(resp.content, UTF_8), GetAilySessionResponse)
        response.raw = resp

        return response

    def update(self, request: UpdateAilySessionRequest,
               option: Optional[RequestOption] = None) -> UpdateAilySessionResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 添加 content-type
        if request.body is not None:
            option.headers[CONTENT_TYPE] = f"{APPLICATION_JSON}; charset=utf-8"

        # 发起请求
        resp: RawResponse = Transport.execute(self.config, request, option)

        # 反序列化
        response: UpdateAilySessionResponse = JSON.unmarshal(str(resp.content, UTF_8), UpdateAilySessionResponse)
        response.raw = resp

        return response

    async def aupdate(self, request: UpdateAilySessionRequest,
                      option: Optional[RequestOption] = None) -> UpdateAilySessionResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 发起请求
        resp: RawResponse = await Transport.aexecute(self.config, request, option)

        # 反序列化
        response: UpdateAilySessionResponse = JSON.unmarshal(str(resp.content, UTF_8), UpdateAilySessionResponse)
        response.raw = resp

        return response
