Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lark_oapi/api/message/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from utils.feishu.message import v4
9 changes: 9 additions & 0 deletions lark_oapi/api/message/service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Code generated by Lark OpenAPI.

from lark_oapi.core.model import Config
from utils.feishu.message.v4.version import V4


class MessageService(object):
def __init__(self, config: Config) -> None:
self.v4: V4 = V4(config)
1 change: 1 addition & 0 deletions lark_oapi/api/message/v4/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from utils.feishu.message.v4.model import *
4 changes: 4 additions & 0 deletions lark_oapi/api/message/v4/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from utils.feishu.message.v4.model.create_batch_send_request import *
from utils.feishu.message.v4.model.create_batch_send_request_body import *
from utils.feishu.message.v4.model.create_batch_send_response import *
from utils.feishu.message.v4.model.create_batch_send_response_body import *
44 changes: 44 additions & 0 deletions lark_oapi/api/message/v4/model/create_batch_send_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Code generated by Lark OpenAPI.

from typing import Optional

from lark_oapi.core.enum import AccessTokenType, HttpMethod
from lark_oapi.core.model import BaseRequest

from utils.feishu.message.v4.model.create_batch_send_request_body import (
CreateBatchSendRequestBody,
)


class CreateBatchSendRequest(BaseRequest):
def __init__(self) -> None:
super().__init__()
self.receive_id_type: Optional[str] = None
self.request_body: Optional[CreateBatchSendRequestBody] = None

@staticmethod
def builder() -> "CreateBatchSendRequestBuilder":
return CreateBatchSendRequestBuilder()


class CreateBatchSendRequestBuilder(object):

def __init__(self) -> None:
create_message_request = CreateBatchSendRequest()
create_message_request.http_method = HttpMethod.POST
create_message_request.uri = "/open-apis/message/v4/batch_send"
create_message_request.token_types = {
AccessTokenType.TENANT,
AccessTokenType.USER,
}
self._create_message_request: CreateBatchSendRequest = create_message_request

def request_body(
self, request_body: CreateBatchSendRequestBody
) -> "CreateBatchSendRequestBuilder":
self._create_message_request.request_body = request_body
self._create_message_request.body = request_body
return self

def build(self) -> CreateBatchSendRequest:
return self._create_message_request
73 changes: 73 additions & 0 deletions lark_oapi/api/message/v4/model/create_batch_send_request_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Code generated by Lark OpenAPI.

from typing import Iterable, Optional

from lark_oapi.core.construct import init


class CreateBatchSendRequestBody(object):
_types = {
"msg_type": str,
"content": dict,
"card": dict,
"department_ids": Iterable[str],
"open_ids": Iterable[str],
"bot_id_list": Iterable[str],
"user_ids": Iterable[str],
"union_ids": Iterable[str],
}

def __init__(self, d=None):
self.msg_type: Optional[str] = None
self.content: Optional[dict] = None
self.card: Optional[dict] = None
self.department_ids: Optional[Iterable[str]] = None
self.open_ids: Optional[Iterable[str]] = None
self.bot_id_list: Optional[Iterable[str]] = None
self.user_ids: Optional[Iterable[str]] = None
self.union_ids: Optional[Iterable[str]] = None
init(self, d, self._types)

@staticmethod
def builder() -> "CreateBatchSendRequestBodyBuilder":
return CreateBatchSendRequestBodyBuilder()


class CreateBatchSendRequestBodyBuilder(object):
def __init__(self) -> None:
self._create_batch_send_request_body = CreateBatchSendRequestBody()

def msg_type(self, msg_type: str) -> "CreateBatchSendRequestBodyBuilder":
self._create_batch_send_request_body.msg_type = msg_type
return self

def content(self, content: dict) -> "CreateBatchSendRequestBodyBuilder":
self._create_batch_send_request_body.content = content
return self

def card(self, card: dict) -> "CreateBatchSendRequestBodyBuilder":
self._create_batch_send_request_body.card = card
return self

def department_ids(
self, department_ids: Iterable[str]
) -> "CreateBatchSendRequestBodyBuilder":
self._create_batch_send_request_body.department_ids = department_ids
return self

def open_ids(self, open_ids: Iterable[str]) -> "CreateBatchSendRequestBodyBuilder":
self._create_batch_send_request_body.open_ids = open_ids
return self

def user_ids(self, user_ids: Iterable[str]) -> "CreateBatchSendRequestBodyBuilder":
self._create_batch_send_request_body.user_ids = user_ids
return self

def union_ids(
self, union_ids: Iterable[str]
) -> "CreateBatchSendRequestBodyBuilder":
self._create_batch_send_request_body.union_ids = union_ids
return self

def build(self) -> "CreateBatchSendRequestBody":
return self._create_batch_send_request_body
19 changes: 19 additions & 0 deletions lark_oapi/api/message/v4/model/create_batch_send_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Code generated by Lark OpenAPI.

from typing import Optional

from lark_oapi.core.construct import init
from lark_oapi.core.model import BaseResponse

from utils.feishu.message.v4.model.create_batch_send_response_body import (
CreateBatchSendResponseBody,
)


class CreateBatchSendResponse(BaseResponse):
_types = {"data": CreateBatchSendResponseBody}

def __init__(self, d=None):
super().__init__(d)
self.data: Optional[CreateBatchSendResponseBody] = None
init(self, d, self._types)
65 changes: 65 additions & 0 deletions lark_oapi/api/message/v4/model/create_batch_send_response_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Code generated by Lark OpenAPI.

from typing import Iterable, Optional

from lark_oapi.core.construct import init


class CreateBatchSendResponseBody(object):
_types = {
"message_id": str,
"invalid_department_ids": Iterable[str],
"invalid_open_ids": Iterable[str],
"invalid_user_ids": Iterable[str],
"invalid_union_ids": Iterable[str],
}

def __init__(self, d=None):
self.message_id: Optional[str] = None
self.invalid_department_ids: Optional[Iterable[str]] = None
self.invalid_open_ids: Optional[Iterable[str]] = None
self.invalid_user_ids: Optional[Iterable[str]] = None
self.invalid_union_ids: Optional[Iterable[str]] = None
init(self, d, self._types)

@staticmethod
def builder() -> "CreateBatchSendResponseBodyBuilder":
return CreateBatchSendResponseBodyBuilder()


class CreateBatchSendResponseBodyBuilder(object):
def __init__(self) -> None:
self._create_batch_send_response_body = CreateBatchSendResponseBody()

def message_id(self, message_id: str) -> "CreateBatchSendResponseBodyBuilder":
self._create_batch_send_response_body.message_id = message_id
return self

def invalid_department_ids(
self, invalid_department_ids: Iterable[str]
) -> "CreateBatchSendResponseBodyBuilder":
self._create_batch_send_response_body.invalid_department_ids = (
invalid_department_ids
)
return self

def invalid_open_ids(
self, invalid_open_ids: Iterable[str]
) -> "CreateBatchSendResponseBodyBuilder":
self._create_batch_send_response_body.invalid_open_ids = invalid_open_ids
return self

def invalid_user_ids(
self, invalid_user_ids: Iterable[str]
) -> "CreateBatchSendResponseBodyBuilder":
self._create_batch_send_response_body.invalid_user_ids = invalid_user_ids
return self

def invalid_union_ids(
self, invalid_union_ids: Iterable[str]
) -> "CreateBatchSendResponseBodyBuilder":
self._create_batch_send_response_body.invalid_union_ids = invalid_union_ids
return self

def build(self) -> "CreateBatchSendResponseBody":
return self._create_batch_send_response_body
1 change: 1 addition & 0 deletions lark_oapi/api/message/v4/resource/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from utils.feishu.message.v4.resource.batch_send import *
44 changes: 44 additions & 0 deletions lark_oapi/api/message/v4/resource/batch_send.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Code generated by Lark OpenAPI.

from typing import Optional

from lark_oapi.core import JSON
from lark_oapi.core.const import APPLICATION_JSON, CONTENT_TYPE, UTF_8
from lark_oapi.core.http import Transport
from lark_oapi.core.model import Config, RawResponse, RequestOption
from lark_oapi.core.token import verify
from utils.feishu.message.v4.model.create_batch_send_request import (
CreateBatchSendRequest,
)
from utils.feishu.message.v4.model.create_batch_send_response import (
CreateBatchSendResponse,
)


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

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

return response
6 changes: 6 additions & 0 deletions lark_oapi/api/message/v4/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from utils.feishu.message.v4.resource import *


class V4(object):
def __init__(self, config: Config) -> None:
self.batch_send: BatchSend = BatchSend(config)
12 changes: 9 additions & 3 deletions lark_oapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from .api.optical_char_recognition.service import OpticalCharRecognitionService
from .api.attendance.service import AttendanceService
from .api.event.service import EventService
from .api.message.service import MessageService


class Client(object):
Expand Down Expand Up @@ -119,12 +120,15 @@ def __init__(self) -> None:
self.optical_char_recognition: Optional[OpticalCharRecognitionService] = None
self.attendance: Optional[AttendanceService] = None
self.event: Optional[EventService] = None
self.message: Optional[MessageService] = None

@staticmethod
def builder() -> "ClientBuilder":
return ClientBuilder()

def request(self, request: BaseRequest, option: Optional[RequestOption] = None) -> BaseResponse:
def request(
self, request: BaseRequest, option: Optional[RequestOption] = None
) -> BaseResponse:
if option is None:
option = RequestOption()

Expand All @@ -145,7 +149,9 @@ def request(self, request: BaseRequest, option: Optional[RequestOption] = None)

return resp

async def arequest(self, request: BaseRequest, option: Optional[RequestOption] = None) -> BaseResponse:
async def arequest(
self, request: BaseRequest, option: Optional[RequestOption] = None
) -> BaseResponse:
if option is None:
option = RequestOption()

Expand Down Expand Up @@ -274,7 +280,7 @@ def build(self) -> Client:
client.optical_char_recognition = OpticalCharRecognitionService(self._config)
client.attendance = AttendanceService(self._config)
client.event = EventService(self._config)

client.message = MessageService(self._config)
return client

def _init_cache(self):
Expand Down