# 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.get_user_mailbox_message_request import GetUserMailboxMessageRequest
from ..model.get_user_mailbox_message_response import GetUserMailboxMessageResponse
from ..model.get_by_card_user_mailbox_message_request import GetByCardUserMailboxMessageRequest
from ..model.get_by_card_user_mailbox_message_response import GetByCardUserMailboxMessageResponse
from ..model.list_user_mailbox_message_request import ListUserMailboxMessageRequest
from ..model.list_user_mailbox_message_response import ListUserMailboxMessageResponse
from ..model.send_user_mailbox_message_request import SendUserMailboxMessageRequest
from ..model.send_user_mailbox_message_response import SendUserMailboxMessageResponse


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

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

        return response

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

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

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

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

        return response

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

        return response

    async def aget_by_card(self, request: GetByCardUserMailboxMessageRequest,
                           option: Optional[RequestOption] = None) -> GetByCardUserMailboxMessageResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response

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

        return response

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

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

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

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

        return response

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

        return response

    async def asend(self, request: SendUserMailboxMessageRequest,
                    option: Optional[RequestOption] = None) -> SendUserMailboxMessageResponse:
        if option is None:
            option = RequestOption()

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

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

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

        return response
