# 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.batch_query_agency_request import BatchQueryAgencyRequest
from ..model.batch_query_agency_response import BatchQueryAgencyResponse
from ..model.get_agency_request import GetAgencyRequest
from ..model.get_agency_response import GetAgencyResponse
from ..model.get_agency_account_agency_request import GetAgencyAccountAgencyRequest
from ..model.get_agency_account_agency_response import GetAgencyAccountAgencyResponse
from ..model.operate_agency_account_agency_request import OperateAgencyAccountAgencyRequest
from ..model.operate_agency_account_agency_response import OperateAgencyAccountAgencyResponse
from ..model.protect_agency_request import ProtectAgencyRequest
from ..model.protect_agency_response import ProtectAgencyResponse
from ..model.protect_search_agency_request import ProtectSearchAgencyRequest
from ..model.protect_search_agency_response import ProtectSearchAgencyResponse
from ..model.query_agency_request import QueryAgencyRequest
from ..model.query_agency_response import QueryAgencyResponse


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

    def batch_query(self, request: BatchQueryAgencyRequest,
                    option: Optional[RequestOption] = None) -> BatchQueryAgencyResponse:
        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: BatchQueryAgencyResponse = JSON.unmarshal(str(resp.content, UTF_8), BatchQueryAgencyResponse)
        response.raw = resp

        return response

    async def abatch_query(self, request: BatchQueryAgencyRequest,
                           option: Optional[RequestOption] = None) -> BatchQueryAgencyResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

    def get(self, request: GetAgencyRequest, option: Optional[RequestOption] = None) -> GetAgencyResponse:
        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: GetAgencyResponse = JSON.unmarshal(str(resp.content, UTF_8), GetAgencyResponse)
        response.raw = resp

        return response

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

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

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

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

        return response

    def get_agency_account(self, request: GetAgencyAccountAgencyRequest,
                           option: Optional[RequestOption] = None) -> GetAgencyAccountAgencyResponse:
        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: GetAgencyAccountAgencyResponse = JSON.unmarshal(str(resp.content, UTF_8),
                                                                  GetAgencyAccountAgencyResponse)
        response.raw = resp

        return response

    async def aget_agency_account(self, request: GetAgencyAccountAgencyRequest,
                                  option: Optional[RequestOption] = None) -> GetAgencyAccountAgencyResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

    def operate_agency_account(self, request: OperateAgencyAccountAgencyRequest,
                               option: Optional[RequestOption] = None) -> OperateAgencyAccountAgencyResponse:
        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: OperateAgencyAccountAgencyResponse = JSON.unmarshal(str(resp.content, UTF_8),
                                                                      OperateAgencyAccountAgencyResponse)
        response.raw = resp

        return response

    async def aoperate_agency_account(self, request: OperateAgencyAccountAgencyRequest,
                                      option: Optional[RequestOption] = None) -> OperateAgencyAccountAgencyResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

    def protect(self, request: ProtectAgencyRequest, option: Optional[RequestOption] = None) -> ProtectAgencyResponse:
        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: ProtectAgencyResponse = JSON.unmarshal(str(resp.content, UTF_8), ProtectAgencyResponse)
        response.raw = resp

        return response

    async def aprotect(self, request: ProtectAgencyRequest,
                       option: Optional[RequestOption] = None) -> ProtectAgencyResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

    def protect_search(self, request: ProtectSearchAgencyRequest,
                       option: Optional[RequestOption] = None) -> ProtectSearchAgencyResponse:
        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: ProtectSearchAgencyResponse = JSON.unmarshal(str(resp.content, UTF_8), ProtectSearchAgencyResponse)
        response.raw = resp

        return response

    async def aprotect_search(self, request: ProtectSearchAgencyRequest,
                              option: Optional[RequestOption] = None) -> ProtectSearchAgencyResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

    def query(self, request: QueryAgencyRequest, option: Optional[RequestOption] = None) -> QueryAgencyResponse:
        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: QueryAgencyResponse = JSON.unmarshal(str(resp.content, UTF_8), QueryAgencyResponse)
        response.raw = resp

        return response

    async def aquery(self, request: QueryAgencyRequest, option: Optional[RequestOption] = None) -> QueryAgencyResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response
