# 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.cancel_onboard_application_request import CancelOnboardApplicationRequest
from ..model.cancel_onboard_application_response import CancelOnboardApplicationResponse
from ..model.create_application_request import CreateApplicationRequest
from ..model.create_application_response import CreateApplicationResponse
from ..model.get_application_request import GetApplicationRequest
from ..model.get_application_response import GetApplicationResponse
from ..model.get_detail_application_request import GetDetailApplicationRequest
from ..model.get_detail_application_response import GetDetailApplicationResponse
from ..model.list_application_request import ListApplicationRequest
from ..model.list_application_response import ListApplicationResponse
from ..model.offer_application_request import OfferApplicationRequest
from ..model.offer_application_response import OfferApplicationResponse
from ..model.recover_application_request import RecoverApplicationRequest
from ..model.recover_application_response import RecoverApplicationResponse
from ..model.terminate_application_request import TerminateApplicationRequest
from ..model.terminate_application_response import TerminateApplicationResponse
from ..model.transfer_onboard_application_request import TransferOnboardApplicationRequest
from ..model.transfer_onboard_application_response import TransferOnboardApplicationResponse
from ..model.transfer_stage_application_request import TransferStageApplicationRequest
from ..model.transfer_stage_application_response import TransferStageApplicationResponse


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

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

        return response

    async def acancel_onboard(self, request: CancelOnboardApplicationRequest,
                              option: Optional[RequestOption] = None) -> CancelOnboardApplicationResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

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

        return response

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

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

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

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

        return response

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

        return response

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

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

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

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

        return response

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

        return response

    async def aget_detail(self, request: GetDetailApplicationRequest,
                          option: Optional[RequestOption] = None) -> GetDetailApplicationResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

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

        return response

    async def alist(self, request: ListApplicationRequest,
                    option: Optional[RequestOption] = None) -> ListApplicationResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

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

        return response

    async def aoffer(self, request: OfferApplicationRequest,
                     option: Optional[RequestOption] = None) -> OfferApplicationResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

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

        return response

    async def arecover(self, request: RecoverApplicationRequest,
                       option: Optional[RequestOption] = None) -> RecoverApplicationResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

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

        return response

    async def aterminate(self, request: TerminateApplicationRequest,
                         option: Optional[RequestOption] = None) -> TerminateApplicationResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

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

        return response

    async def atransfer_onboard(self, request: TransferOnboardApplicationRequest,
                                option: Optional[RequestOption] = None) -> TransferOnboardApplicationResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

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

        return response

    async def atransfer_stage(self, request: TransferStageApplicationRequest,
                              option: Optional[RequestOption] = None) -> TransferStageApplicationResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response
