| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import requests
- import esigntool
- from esigntool import esign_run_print_outer
- # 企业机构成员服务API
- config = esigntool.config() # 初始化配置类
- @esign_run_print_outer
- def create_templateseals():
- """
- 添加企业机构成员
- :return:
- """
- # 构建请求body体
- body = {
- "members": [
- {
- "psnId": "d3fcf19***0ddc60a13",
- "memberName": "成员1的姓名",
- "employeeNum": "100"
- },
- {
- "psnId": "501a277***6b19b7211",
- "memberName": "成员2的姓名",
- "employeeNum": "101"
- }
- ]
- }
- orgId = "501a277***6b19b7211"
- api_path = "/v3/organizations/{}/members".format(orgId) # 拼接请求路径
- method = esigntool.httpMethodEnum.POST # 声明请求方法
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
- method, api_path, body) # 签名并构造签名鉴权json请求头
- resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
- print(resp.text)
- return resp
- @esign_run_print_outer
- def members_delete():
- """
- 移除企业机构成员
- :return:DELETE
- """
- # 构建请求body体
- body = {
- "memberPsnIds": ['d3fcf1b***dc60a13', '8d28bfe***23b135f']
- }
- orgId = "c7e00*****541e7"
- api_path = "/v3/organizations/{}/members".format(orgId) # 拼接请求路径
- print(api_path)
- method = esigntool.httpMethodEnum.DELETE # 声明请求方法
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
- method, api_path, body) # 签名并构造签名鉴权json请求头
- resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
- print(resp.text)
- return resp
- @esign_run_print_outer
- def member_list():
- """
- 查询企业机构成员
- :return:
- """
- orgId = "11"
- pageNum = "11"
- pageSize = "22"
- api_path = "/v3/organizations/{}/member-list?pageNum={}&pageSize={}".format(orgId, pageNum,
- pageSize) # 拼接请求路径
- method = esigntool.httpMethodEnum.GET # 声明请求方法
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
- method, api_path) # 签名并构造签名鉴权json请求头
- resp = requests.request(method, config.host + api_path, json=None, headers=json_headers) # 发送请求
- print(resp.text)
- return resp
- @esign_run_print_outer
- def administrators():
- """
- 查询企业机构管理员
- :return:
- """
- orgId = "11"
- api_path = "/v3/organizations/{}/administrators".format(orgId) # 拼接请求路径
- method = esigntool.httpMethodEnum.GET # 声明请求方法
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
- method, api_path) # 签名并构造签名鉴权json请求头
- resp = requests.request(method, config.host + api_path, json=None, headers=json_headers) # 发送请求
- print(resp.text)
- return resp
- if __name__ == '__main__':
- create_templateseals() # 添加企业机构成员
- members_delete() # 移除企业机构成员
- member_list() # 查询企业机构成员
- administrators() # 查询企业机构管理员
|