larksuite / oapi-sdk-python

Larksuite development interface SDK
MIT License
319 stars 50 forks source link

[feature request] Add some Enum types #57

Open BeautyyuYanli opened 9 months ago

BeautyyuYanli commented 9 months ago

I'm using docx.v1.ListDocumentBlockRequest to get a docx.v1.Block. Then I'd like to write:

def get_text_block_by_type(block: docx.v1.Block) -> docx.v1.Text:
    name = FeishuBlockType(block.block_type).name
    value = block.__getattribute__(name)
    if isinstance(value, docx.v1.Text):
        return value
    else:
        return None

class FeishuBlockType(Enum):
    page = 1
    text = 2
    heading1 = 3
    heading2 = 4
    heading3 = 5
    heading4 = 6
    heading5 = 7
    heading6 = 8
    heading7 = 9
    heading8 = 10
    heading9 = 11
    bullet = 12
    ordered = 13
    code = 14
    quote = 15
    equation = 16
    todo = 17
    bitable = 18
    callout = 19
    chat_card = 20
    uml_diagram = 21
    divider = 22
    file = 23
    grid = 24
    grid_column = 25
    iframe = 26
    image = 27
    isv = 28
    mindnote = 29
    sheet = 30
    table = 31
    table_cell = 32
    view = 33
    quote_container = 34
    task = 35
    okr = 36
    okr_objective = 37
    okr_key_result = 38
    okr_progress = 39
    add_ons = 40
    jira_issue = 41
    wiki_catalog = 42

I belive it will be useful for developers to have the Enum types in lark_oapi , perticularly the fields like:

image image image

Relate to https://open.feishu.cn/document/server-docs/docs/docs/docx-v1/document/list