# -*- coding: UTF-8 -*- from larksuiteoapi.service.contact.v3 import Service as ContactService, model from larksuiteoapi import DOMAIN_FEISHU, Config, LEVEL_DEBUG, LEVEL_INFO, \ LEVEL_WARN, LEVEL_ERROR # 企业自建应用的配置 # AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) # VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key),非必需,订阅事件、消息卡片时必需 # 更多介绍请看:Github -> README.zh.md -> 如何构建应用配置(AppSettings) app_settings = Config.new_internal_app_settings( app_id='AppID', app_secret='AppSecret', verification_token='VerificationToken', encrypt_key='EncryptKey') # 当前访问的是飞书,使用默认内存存储、默认日志(Error 级别) # 更多介绍请看:Github -> README.zh.md -> 如何构建整体配置(Config) conf = Config(DOMAIN_FEISHU, app_settings, log_level=LEVEL_ERROR) service = ContactService(conf) if __name__ == '__main__': # body params body = model.User() body.name = '' body.mobile = '' department_ids_1 = [] body.department_ids = department_ids_1 body.employee_type = 0 req_call = service.users.create(body=body)
# -*- coding: UTF-8 -*- from larksuiteoapi.api import Request, FormData, FormDataFile, set_timeout, set_path_params, set_query_params, \ set_is_response_stream, set_response_stream, set_tenant_key, set_need_help_desk_auth from larksuiteoapi import Config, ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER, ACCESS_TOKEN_TYPE_APP, \ APP_TICKET_KEY_PREFIX, DOMAIN_FEISHU, LEVEL_ERROR, LEVEL_DEBUG # for Cutome APP(企业自建应用) app_settings = Config.new_internal_app_settings(app_id='cli_a04677****8d01b', app_secret='XcplX2QLU7X******VJKHd6Yzvt', verification_token='', encrypt_key='', help_desk_id='696874*****390932', help_desk_token='ht-c82db92*******f5cf6e569aa') # for redis store and logger(level=debug) # conf = test_config_with_redis_store(DOMAIN_FEISHU, app_settings) # for memory store and logger(level=debug) conf = Config("https://open.feishu-boe.cn", app_settings, log_level=LEVEL_DEBUG) def test_ticket_detail(): req = Request('/open-apis/helpdesk/v1/tickets/6971250929135779860', 'GET', ACCESS_TOKEN_TYPE_TENANT, None, request_opts=[set_timeout(3), set_need_help_desk_auth()]) resp = req.do(conf) print('header = %s' % resp.get_header().items()) print('request id = %s' % resp.get_request_id()) print(resp.code) if resp.code == 0: print(resp.data)