### Get Platform Company Information (Python SDK) Source: https://open.qiyuesuo.cn/document/2657081120373346808 This Python example demonstrates how to initialize the SdkClient and request platform company details. It covers client setup and making the request. ```python # 初始化SdkClient url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) # 公司信息 response = sdkClient.request(PlatformDetailRequest()) print('获取对接方公司详情:\n', str(response), '\n') ``` -------------------------------- ### Go SDK Example for Employee List Source: https://open.qiyuesuo.cn/document/2657084093178581736 Shows how to get employee lists using the Go SDK. This example covers SDK client initialization and making the employee list request with optional parameters. ```go sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") req := request.EmployeeListRequest{} //req.TenantName = "测试11-8-1" selectLimit := 3 req.SelectLimit = &selectLimit response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) ``` -------------------------------- ### Send Contract using PHP SDK Source: https://open.qiyuesuo.cn/document/2657077065303462394 This PHP example illustrates sending a contract using the SDK. It shows how to initialize the SDK client and create `ContractSendRequest` and `Stamper` objects. The example demonstrates setting contract IDs, business IDs, and stamper details, including positioning by keyword or coordinates. Note that the example is incomplete, showing only the setup for two stampers. ```php // 初始化$sdkClient class Util { const url = "https://openapi.qiyuesuo.cn"; const accessKey = "替换为您申请的开放平台App Token"; const accessSecret = "替换为您申请的开放平台App Secret"; } $sdkClient = Util::getSDk(); $contractSendRequest = new ContractSendRequest(); $contractSendRequest->setContractId('2590758386643734529'); $contractSendRequest->setBizId("1111111"); /**个指定签署位置:关键字定位**/ $stamper1 = new Stamper(); $stamper1->setType('COMPANY'); $stamper1->setActionId('2590758390800289796'); $stamper1->setDocumentId('2590764888637018192'); $stamper1->setSealId('2555244623418466517'); $stamper1->setKeyword('劳动'); $stamper1->setKeywordIndex('2'); $stamper1->setOffsetX('0.1'); $stamper1->setOffsetY('-0.1'); /**个指定签署位置:坐标定位**/ $stamper2 = new Stamper(); $stamper2->setType('COMPANY'); ``` -------------------------------- ### Get Employee Detail - Go SDK Example Source: https://open.qiyuesuo.cn/document/2922081592338023190 This Go code example shows how to use the SDK to retrieve employee details. It initializes the SdkClient with the server URL and authentication credentials. An EmployeeDetailRequest is prepared with user contact information, and the Service method is called. Error handling is included for the API request. ```go sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") req := request.EmployeeDetailRequest{} user := model.User{} user.Contact = "10000000281" user.ContactType = "MOBILE" req.User = &user response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) ``` -------------------------------- ### Initialize SDK Client and Request Company Auth Link (Go) Source: https://open.qiyuesuo.cn/document/3174631537211932683 Initializes the SdkClient using HTTP. It prepares a CompanyAuthLicenseH5PageRequest, populating company name, applicant details, and attaching a business license file. The function then sends the request and prints the response or any errors encountered. Requires the 'qiyuesuo-sdk' library for Go. ```go package main import ( "fmt" "os" "encoding/json" "qiyuesuo-sdk/http" "qiyuesuo-sdk/model" "qiyuesuo-sdk/request" ) func main() { sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") req := request.CompanyAuthLicenseH5PageRequest{} req.CompanyName = "go测试公司-1" user := model.User{} user.Name = "宋一" user.Contact = "10000000011" user.ContactType = "MOBILE" userBs, _ := json.Marshal(user) req.ApplicantInfo = string(userBs) file, _ := os.Open("/Users/sgf/develop/临时/go/营业执照.pdf") req.License = &http.FileItem{file, ""} response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) } ``` -------------------------------- ### Get Contract List (HTTP Request Example) Source: https://open.qiyuesuo.cn/document/2657079456446812722 This snippet demonstrates how to make an HTTP GET request to the /v2/contract/list endpoint to retrieve contract information. It includes example headers required for authentication and timestamping. The request can be used to fetch a specific number of contracts starting from a given offset. ```http GET /v2/contract/list?selectOffset=0&selectLimit=1 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Add Document by Template (Java) Source: https://open.qiyuesuo.cn/document/2740884711176933883 This Java example demonstrates how to initialize the SdkClient and use it to add a document by template. It covers setting up template parameters, creating the request object, sending the request, and parsing the response to check for success or failure. ```java // 初始化sdkClient String serverUrl = "https://openapi.qiyuesuo.cn"; String accessKey = "替换为您申请的开放平台App Token"; String accessSecret = "替换为您申请的开放平台App Secret"; SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret); // 添加合同文档 List params = new ArrayList<>(); params.add(new TemplateParam("param1", "val1")); params.add(new TemplateParam("param2", "val2")); DocumentAddByTemplateRequest request = new DocumentAddByTemplateRequest(contractId, templateId, params, "文件二"); String response = sdkClient.service(request); SdkResponse responseObj = JSONUtils.toQysResponse(response, DocumentAddResult.class); if(responseObj.getCode() == 0) { DocumentAddResult result = responseObj.getResult(); logger.info("添加合同文档成功,文档ID:{}", result.getDocumentId()); } else { logger.info("请求失败,错误码:{}, 错误信息:{}", responseObj.getCode(), responseObj.getMessage()); } ``` -------------------------------- ### Get Contract Operation Records - HTTP Example Source: https://open.qiyuesuo.cn/document/3019208383061573962 Example of making an HTTP GET request to retrieve contract operation records. This includes the endpoint and required headers for authentication and timestamping. ```http GET /v2/contract/stream?contractId=2209280913857052672 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### C# SDK Example for Adding Document by File Source: https://open.qiyuesuo.cn/document/2740884487066882502 This C# example demonstrates initializing the SDK client and making a request to add a document using a local file. It includes file stream handling, request object creation, and error handling for the API response. The code parses the response to check for success and logs or throws exceptions accordingly. Ensure the SDK and necessary namespaces are included. ```csharp //初始化sdkClient string serverUrl = "https://openapi.qiyuesuo.cn"; string accessKey = "替换为您申请的开放平台App Token"; string accessSecret = "替换为您申请的开放平台App Secret"; SDKClient client = new SDKClient(accessKey, accessSecret,serverUrl); string contractId = "2589012016299597907"; // 引入待添加文件 string path = "C:\Users\Richard Cheung\Documents\契约锁\测试\人事合同.pdf"; Stream file = new FileStream(path, FileMode.Open); // 组装根据文件添加文档请求 DocumentAddByFileRequest request = new DocumentAddByFileRequest(contractId, "添加文件", file, "pdf"); string response = null; try { response = client.Service(request); } catch (Exception e) { throw new Exception(e.Message); } // 解析返回结果 SdkResponse responseObject = HttpJsonConvert.DeserializeResponse(response); if (!sdkResponse.ResponseCode.Equals("00000000")) { throw new Exception("请求失败,失败原因:" + responseObject.Message); } Console.WriteLine(“请求接口成功”); Console.WriteLine(HttpJsonConvert.SerializeObject(responseObject)); ``` -------------------------------- ### Get Contract Detail - HTTP Example Source: https://open.qiyuesuo.cn/document/2657079343800390167 This is an HTTP GET request example to retrieve the details of a specific contract using its contract ID. It includes necessary headers for authentication and timestamping. ```http GET /v2/contract/detail?contractId=2591540368898105360 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Initialize SDK Client and Request Company Auth Link (Python) Source: https://open.qiyuesuo.cn/document/3174631537211932683 Initializes the SdkClient with provided URL, access token, and secret. It then creates a CompanyAuthLicenseH5PageRequest, sets company name, applicant information, and attaches a license file before sending the request to obtain an authentication link. Requires the 'qiyuesuo-sdk' library. ```python from qiyuesuo_sdk.client import SdkClient from qiyuesuo_sdk.model.company_auth_license_h5_page_request import CompanyAuthLicenseH5PageRequest from qiyuesuo_sdk.model.user import User import json url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) companyAuthLicenseH5PageRequest = CompanyAuthLicenseH5PageRequest() companyAuthLicenseH5PageRequest.set_companyName("HZK测试企业-111") applicant = User("HZK", "151****6497", "MOBILE") print(str(applicant.to_json())) companyAuthLicenseH5PageRequest.set_applicantInfo(json.dumps(applicant.to_json())) file = open("C:\\Users\\Administrator\\Desktop\\avatar.png", "rb") companyAuthLicenseH5PageRequest.set_license(file) auth_h5_page_response = sdkClient.request(companyAuthLicenseH5PageRequest) print(auth_h5_page_response) ``` -------------------------------- ### Get Company Sub-list API Integration Examples Source: https://open.qiyuesuo.cn/document/2657081291786162714 These examples show how to integrate with the 'Get Company Sub-list' API using various programming languages. They cover SDK initialization, request construction, and response handling. ```java // 初始化sdkClient String serverUrl = "http://openapi.qiyuesuo.cn"; String accessKey = "替换为您申请的开放平台App Token"; String accessSecret = "替换为您申请的开放平台App Secret"; SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret); // 公司信息 SubCompanyListRequest request =new SubCompanyListRequest(); String response = sdkClient.service(request); SdkResponse responseObj = JSONUtils.toQysResponse(response,SubCompanyListResult.class); if("00000000".equals(responseObj.getResponseCode())) { SubCompanyListResult result = responseObj.getResult(); logger.info("子公司信息数目,数目:{}", result == null?0 : result.size()); } else { logger.info("子公司信息查询失败,错误码:{},错误信息:{}", responseObj.getCode(), responseObj.getMessage()); } ``` ```csharp // 初始化sdkClient string serverUrl = "https://openapi.qiyuesuo.cn"; string accessKey = "替换为您申请的开放平台App Token"; string accessSecret = "替换为您申请的开放平台App Secret"; SDKClient client = new SDKClient(accessKey, accessSecret, serverUrl); string response = null; try { response = client.Service(new SubCompanyListRequest()); } catch (Exception e) { throw new Exception(e.Message); } SdkResponse responseObject = HttpJsonConvert.DeserializeResponse(response); if (!responseObject.ResponseCode.Equals("00000000")) { throw new Exception("请求失败,失败原因:" + responseObject.Message); } Console.WriteLine("请求接口成功"); Console.WriteLine(HttpJsonConvert.SerializeObject(responseObject)); ``` ```php // 初始化$sdkClient class Util { const url = "https://openapi.qiyuesuo.cn"; const accessKey = "替换为您申请的开放平台App Token"; const accessSecret = "替换为您申请的开放平台App Secret"; } $sdkClient = Util::getSDk(); $subCompanyListRequest = new SubCompanyListRequest(); $result = $sdkClient->service($subCompanyListRequest); print_r($result); ``` ```python # 初始化SdkClient url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) # 子公司列表信息 response = sdkClient.request(SubCompanyListRequest()) print('获取子公司列表详情:\n', str(response), '\n') ``` ```go sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") req := request.SubCompanyListRequest{} response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) ``` -------------------------------- ### Get Personal Authentication Status (HTTP Example) Source: https://open.qiyuesuo.cn/document/2657095124558811390 This is an HTTP GET request example to query the personal real-name authentication status. It requires the Host header and authentication tokens. ```http GET /v2/personalauth/result?contact=10020033044& contactType=MOBILE HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Send Contract Copy using Java SDK Source: https://open.qiyuesuo.cn/document/2657077204122341943 Java example demonstrating how to initialize the SDK client and send a contract copy request. It includes adding receivers and handling the response. Ensure the SDK is properly configured with server URL, access key, and secret. ```java // 初始化sdkClient String serverUrl = "https://openapi.qiyuesuo.cn"; String accessKey = "替换为您申请的开放平台App Token"; String accessSecret = "替换为您申请的开放平台App Secret"; SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret); ContractCopySendRequest request = new ContractCopySendRequest(2652006623940010955L); request.addReceiver(new CopySendReceiver("张三", new User("1234567890", "MOBILE"))); request.addReceiver(new CopySendReceiver("李四", new User("1234567890", "MOBILE"))); String response = sdkClient.service(request); SdkResponse responseObj = JSONUtils.toQysResponse(response); if(responseObj.getResponseCode().equals("00000000")) { logger.info("合同抄送成功"); } else { logger.info("请求失败,错误码:{}", responseObj.getCode(), responseObj.getMessage()); } ``` -------------------------------- ### Create Employee Go SDK Example Source: https://open.qiyuesuo.cn/document/2657084184471802615 This Go code demonstrates creating an employee using the Qiyuesuo SDK. It initializes the SDK client, sets up the employee request with user details, and sends the request. Error handling is included for the service call. Remember to replace placeholder credentials. ```go sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") req := request.EmployeeCreateRequest{} user := model.User{} user.Name = "宋三" user.Contact = "10000000001" user.ContactType = "MOBILE" req.User = &user req.Number = "天宫一号" response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) ``` -------------------------------- ### HTTP GET Request Example for Template List Source: https://open.qiyuesuo.cn/document/2657083613631222427 Example of an HTTP GET request to the /v2/template/list endpoint. This shows the necessary headers, including timestamp, signature, and access token. ```http GET /v2/template/list?selectOffset=0& selectLimit=2 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Get Company Sub-list HTTP Request Example Source: https://open.qiyuesuo.cn/document/2657081291786162714 This example demonstrates the HTTP request format to retrieve a list of company subsidiaries. It includes the necessary headers for authentication and timestamping. ```http GET /v2/company/list HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Add Document by Template (C# SDK Example) Source: https://open.qiyuesuo.cn/document/2740884711176933883 This C# example illustrates using the Qiyuesuo SDK to add a document via a template. It requires initializing the SDK client with credentials and server URL. A DocumentAddByTemplateRequest is constructed, template parameters are added, and the service is called. Error handling is included, and the response is deserialized and checked. ```C# string serverUrl = "https://openapi.qiyuesuo.cn"; string accessKey = "替换为您申请的开放平台App Token"; string accessSecret = "替换为您申请的开放平台App Secret"; SDKClient client = new SDKClient(accessKey, accessSecret, serverUrl); string contractId = "2589012016299597907"; string templateId = "2562841550577214123"; // 组装根据模板创建文档请求 DocumentAddByTemplateRequest request = new DocumentAddByTemplateRequest(contractId, "添加模板", templateId); // 设置模板参数内容 request.AddTemplateParam(new TemplateParam("Sender", "契约锁")); request.AddTemplateParam(new TemplateParam("Reciver1", "开放平台")); request.AddTemplateParam(new TemplateParam("Reciver2", "对接方公司")); string response = null; try { response = client.Service(request); } catch (Exception e) { throw new Exception(e.Message); } // 解析返回内容 SdkResponse responseObject = HttpJsonConvert.DeserializeResponse(response); if (!responseObject.Code.Equals(0)) { throw new Exception("请求失败,失败原因:" + responseObject.Message); } Console.WriteLine(“请求接口成功”); Console.WriteLine(HttpJsonConvert.SerializeObject(responseObject)); ``` -------------------------------- ### Get Template Page URL HTTP Request Example Source: https://open.qiyuesuo.cn/document/2657083839569990338 This is an example of an HTTP GET request to the /v2/template/pageurl endpoint. It requires specific headers like timestamp, signature, and access token, which should be generated dynamically. ```http GET /v2/template/pageurl?templateId=2427320111455567969 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Go SDK Example for Template List Source: https://open.qiyuesuo.cn/document/2657083613631222427 An example using the Go SDK to request a template list. It demonstrates initializing the SDK client and making a service call with a TemplateListRequest object, including basic error handling. ```go sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") req := request.TemplateListRequest{} //req.ModifyTimeStart = "2020-09-09 00:00:00" response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) ``` -------------------------------- ### Get Template Page URL Python SDK Example Source: https://open.qiyuesuo.cn/document/2657083839569990338 This Python example initializes the SdkClient with URL and credentials, creates a TemplatePageRequest, and calls the request method to get the template preview page. The response is then printed. ```python # 初始化SdkClient url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) # 获取模板预览页面 pageRequest = TemplatePageRequest('2474165699643592754') response = sdkClient.request(pageRequest) print('模板预览页面:\n', str(response), '\n') ``` -------------------------------- ### Get Template Detail - Python SDK Example Source: https://open.qiyuesuo.cn/document/2657083754488533687 This Python code provides an example of how to use the Qiyuesuo SDK to get template details. It shows the initialization of the SDK client and the process of creating and sending a template detail request. ```python # 初始化$sdkClient url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) detailRequest = TemplateDetailRequest() detailRequest.set_templateId(2474165699643592754) response = sdkClient.request(pageRequest) print('模板详情:\n', str(response), '\n') ``` -------------------------------- ### Go SDK Example for Seal Auto Create Source: https://open.qiyuesuo.cn/document/2731006591867294007 This Go code provides an example of using the SDK client to create a seal automatically. It demonstrates initializing the SDK, constructing the SealAutoCreateRequest including SealImageInfo and User details, making the service call, and handling potential errors during the request. ```go sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") req := request.SealAutoCreateRequest{} req.Name = "go自动生成印章2" sii := model.SealImageInfo{} sii.Style = "UNIVERSAL_SEAL" sii.Spec = "CIRCULAR_42" sii.Foot = "shallot" req.SealImageInfo = &sii user := model.User{} user.Contact = "10000000011" user.ContactType = "MOBILE" var users []*model.User users = append(users, &user) req.Users = users response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) ``` -------------------------------- ### Submitting User Authentication Request with Python SDK Source: https://open.qiyuesuo.cn/document/2657095033840210165 This Python example shows how to use the SdkClient to make a user authentication request. It initializes the client with the server URL and credentials, creates a UserAuthPageRequest with user contact information, and then sends the request using the SDK. The response from the request is printed. Ensure the SDK is installed and accessible. ```Python # 初始化SdkClient url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) userAuthPageRequest = UserAuthPageRequest() userAuthPageRequest.set_user(User(contact='10020033044', contactType='MOBILE')) response = sdkClient.request(userAuthPageRequest) print(response) ``` -------------------------------- ### Python SDK Example for Adding Document by File Source: https://open.qiyuesuo.cn/document/2740884487066882502 This Python example demonstrates adding a document using the SdkClient and DocumentAddByFileRequest. It shows how to open a local file in binary read mode, set the file, contract ID, file suffix, and title in the request object, and then send the request. The response is parsed, and an exception is raised if the operation fails. ```python #初始化SdkClient url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) documentbyfile_request = DocumentAddByFileRequest() file = open("C:\Users\Richard Cheung\Documents\契约锁\测试\测试合同.pdf", "rb") documentbyfile_request.set_file(file) documentbyfile_request.set_contractId(draft_contractclass) # 将fileSuffix替换为将上传文件正确的文件类型 documentbyfile_request.set_fileSuffix('pdf') documentbyfile_request.set_title('本地文件上传文档') # 请求服务器 documentbyfile_response = sdkClient.request(documentbyfile_request) # 解析返回数据 documentbyfile_mapper = json.loads(documentbyfile_response) if documentbyfile_mapper['responseCode'] != '00000000': raise Exception('根据本地文件添加合同文档失败,失败原因:', documentbyfile_mapper['message']) documentbyfile_result = documentbyfile_mapper['result'] file_documentId = documentbyfile_result['documentId'] print('根据本地文件添加合同文档成功,文档ID:', file_documentId) ``` -------------------------------- ### HTTP Request Example for Deleting a Seal Source: https://open.qiyuesuo.cn/document/2923142275066495388 This is an example of an HTTP GET request to the /v2/seal/remove endpoint. It includes the necessary host and authentication headers. The sealId is provided as a query parameter. ```http GET /v2/seal/remove?sealId=2779656671141179400 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Initialize SdkClient and Request Company Auth (Python) Source: https://open.qiyuesuo.cn/document/2657095364774990124 Initializes the SdkClient with provided credentials and makes a request for company authentication. It sets up the company name and applicant details before sending the request to the SDK client. The response from the SDK client is then printed. ```python url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) auth_h5_page_request = CompanyAuthPCPageRequest() auth_h5_page_request.set_companyName('上海契约锁公司') applicant_user = User(); applicant_user.set_name('张三') applicant_user.set_contact('12312378900') applicant_user.set_contactType('MOBILE') auth_h5_page_request.set_applicant(applicant_user) auth_h5_page_response = sdkClient.request(auth_h5_page_request) print(auth_h5_page_response) ``` -------------------------------- ### Get Template Detail - HTTP Request Example Source: https://open.qiyuesuo.cn/document/2657083754488533687 This snippet shows the HTTP request structure for retrieving template details. It specifies the GET method, the endpoint, and required headers for authentication and timestamping. ```http GET /v2/template/detail?templateId=2736549088091935670 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的TimeStamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Initialize SdkClient and Request Company Auth (Go) Source: https://open.qiyuesuo.cn/document/2657095364774990124 Initializes the Go SDK client with API credentials and sends a request for company authentication. It configures the company name and applicant information, then sends the request using the SDK client. Error handling is included for the request. ```go sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") req := request.CompanyAuthPCPageRequest{} req.CompanyName = "go测试公司-1" user := model.User{} user.Name = "宋一" user.Contact = "10000000281" user.ContactType = "MOBILE" req.Applicant = &user response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) ``` -------------------------------- ### Initiate Contract Signing (Go) Source: https://open.qiyuesuo.cn/document/2835799025792581860 This Go code initializes an SDK client and prepares a contract signing request. It sets the contract ID, user contact information, and then sends the request using the SDK client, printing the response or any errors encountered. This is a common pattern for initiating contract signing workflows. ```go sdkClient := http.NewSdkClient("https://openapi.qiyuesuo.cn", "替换为您申请的开放平台App Token", "替换为您申请的开放平台App Secret") signParam := model.UserSignParam{} signParam.ContractId = "3122011527419339721" user := model.User{} user.Contact = "10000000011" user.ContactType = "MOBILE" signParam.User = &user req := request.ContractSignUserRequest{} req.Param = &signParam response, err := sdkClient.Service(req) if err != nil { fmt.Println("request failed,", err.Error()) return } fmt.Println(response) ``` -------------------------------- ### HTTP GET Request for Employee List Source: https://open.qiyuesuo.cn/document/2657084093178581736 Example of an HTTP GET request to fetch the employee list. This includes the endpoint, host, and required headers like timestamp, signature, and access token. ```http GET /v2/employee/list?selectOffset=0& selectLimit=2 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### C# SDK Example for Data Notarization Source: https://open.qiyuesuo.cn/document/3134419862076854292 This C# code illustrates initializing the SDKClient and performing file notarization. It covers setting up the client, defining notary parameters, creating a FileStream for the document, and sending the ChainNotaryRequest. Error handling and response parsing are included. Note the use of System.IO for file operations and a custom JSON deserializer. ```csharp // 初始化sdkClient string serverUrl = "https://openapi.qiyuesuo.cn"; string accessKey = "替换为您申请的开放平台App Token"; string accessSecret = "替换为您申请的开放平台App Secret"; SDKClient client = new SDKClient(accessKey, accessSecret,serverUrl); string notaryName = "存证数据测试"; string notaryDataID = "6331411786447082982"; string notaryType = "FILE"; // 存证文件 string path = "C:\\Users\\Richard Cheung\\Documents\\契约锁\\测试\\人事合同.pdf"; Stream file = new FileStream(path, FileMode.Open); // 组装根据文件添加文档请求 ChainNotaryRequest request = new ChainNotaryRequest(notaryName, notaryDataID, notaryType, file); string response = null; try { response = client.Service(request); } catch (Exception e) { throw new Exception(e.Message); } // 解析返回结果 SdkResponse responseObject = HttpJsonConvert.DeserializeResponse(response); if (!responseObject.ResponseCode.Equals("00000000")) { throw new Exception("请求失败,失败原因:" + responseObject.Message); } Console.WriteLine(“请求接口成功”); Console.WriteLine(HttpJsonConvert.SerializeObject(responseObject)); ``` -------------------------------- ### C# SDK Example for Seal Auto Create Source: https://open.qiyuesuo.cn/document/2731006591867294007 This C# example illustrates using the SDK client for automatic seal creation. It shows how to instantiate the SDK client, configure the SealAutoCreateRequest with image details, send the service request, and handle potential exceptions during the API call. Error handling for the response is also included. ```csharp // 初始化sdkClient string serverUrl = "https://openapi.qiyuesuo.cn"; string accessKey = "替换为您申请的开放平台App Token"; string accessSecret = "替换为您申请的开放平台App Secret"; SDKClient client = new SDKClient(accessKey, accessSecret, serverUrl); SealAutoCreateRequest request = new SealAutoCreateRequest(); SealImageInfo imageInfo = new SealImageInfo(); imageInfo.Style = "UNIVERSAL_SEAL"; imageInfo.Spec = "CIRCULAR_42"; request.Name = "接口自动创建"; string response = null; try { response = client.Service(request); } catch (Exception e) { throw new Exception("接口请求错误:" + e.Message); } SdkResponse sealResponse = HttpJsonConvert.DeserializeResponse(response); if(!sealResponse.ResponseCode.Equals("00000000")) { throw new Exception("接口请求错误:" + sealResponse.Code + "," + sealResponse.Message); } Console.WriteLine("生成印章成功,Id:"+sealResponse.Result.Id); ``` -------------------------------- ### Get Contract View URL via HTTP Request Source: https://open.qiyuesuo.cn/document/2657078810956009942 Example of how to make an HTTP GET request to the /v2/contract/viewurl endpoint to obtain a contract viewing URL. It requires authentication headers. ```HTTP GET /v2/contract/viewurl?contractId=2604642423930777609 HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的TimeStamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### C# SDK Example for Employee List Source: https://open.qiyuesuo.cn/document/2657084093178581736 Provides an example of using the C# SDK to fetch employee data. It includes SDK client setup, request construction, error handling, and response deserialization. ```csharp // 初始化sdkClient string serverUrl = "https://openapi.qiyuesuo.cn"; string accessKey = "替换为您申请的开放平台App Token"; string accessSecret = "替换为您申请的开放平台App Secret"; SDKClient client = new SDKClient(accessKey, accessSecret, serverUrl); // 员工列表 EmployeeListRequest request = new EmployeeListRequest(new PageBean()); string response = null; try { response = client.Service(request); } catch (Exception e) { throw new Exception(e.Message); } // 解析返回内容 SdkResponse> responseObject = HttpJsonConvert.DeserializeResponse>(response); if (!responseObject.ResponseCode.Equals("00000000")) { throw new Exception("获取员工列表失败,失败原因:" + responseObject.Message); } Console.WriteLine("获取员工列表成功"); Console.WriteLine(HttpJsonConvert.SerializeObject(responseObject)); ``` -------------------------------- ### Query Open Platform Application Information - HTTP Example Source: https://open.qiyuesuo.cn/document/3200023501004444470 This is an HTTP example demonstrating how to request application information using the GET method. It requires specific headers like Host, Timestamp, Signature, and AccessToken. ```HTTP GET /company/token/get HTTP/1.1 Host: [host] x-qys-open-timestamp: [替换为请求头生成的Timestamp] x-qys-open-signature: [替换为请求头生成的Signature] x-qys-open-accesstoken: [替换为请求头生成的Token] ``` -------------------------------- ### Send Contract using Java SDK Source: https://open.qiyuesuo.cn/document/2657077065303462394 This Java example demonstrates how to initialize the SDK client and send a contract with specified stampers. It covers setting up the client with server URL, access key, and secret, then creating and adding `Stamper` objects to a `ContractSendRequest`. Error handling for the API response is included. ```java // 初始化sdkClient String serverUrl = "https://openapi.qiyuesuo.cn"; String accessKey = "替换为您申请的开放平台App Token"; String accessSecret = "替换为您申请的开放平台App Secret"; SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret); // 发起时可以设置签署位置 Stamper stamper = new Stamper(); stamper.setActionId(2589310177048080947L); stamper.setDocumentId(2589310172379820580L); stamper.setType("COMPANY"); stamper.setPage(1); stamper.setOffsetX(0.1); stamper.setOffsetY(0.1); Stamper stamper2 = new Stamper(); stamper2.setActionId(2589310177048080947L); stamper2.setDocumentId(2589310172379820580L); stamper2.setType("COMPANY"); stamper2.setPage(1); stamper2.setOffsetX(0.2); stamper2.setOffsetY(0.1); List stampers = new ArrayList<>(); stampers.add(stamper); stampers.add(stamper2); // 发起合同 ContractSendRequest request = new ContractSendRequest(2589310172899914283L, stampers); String response = sdkClient.service(request); SdkResponse responseObj = JSONUtils.toQysResponse(response); if(responseObj.getResponseCode().equals("00000000")) { logger.info("合同发起成功"); } else { logger.info("请求失败,错误码:{},错误信息:{}", responseObj.getCode(), responseObj.getMessage()); } ``` -------------------------------- ### Python: Initialize SdkClient and Sign with Company Seal Source: https://open.qiyuesuo.cn/document/2657077740376691341 Initializes the SdkClient with API credentials, sets up signature parameters including contract and stamper details for company, timestamp, and across-page seals, and sends a company seal signature request. It then parses the response to check for errors. ```python url = "https://openapi.qiyuesuo.cn" accessToken = '替换为您申请的开放平台App Token' accessSecret = '替换为您申请的开放平台App Secret' sdkClient = SdkClient(url, accessToken, accessSecret) seal_signParam = SignParam() seal_signParam.set_contractId(draft_contractclass) # 指定签署位置 - 公章签署位置 seal_companyStamper = Stamper() seal_companyStamper.set_documentId(file_documentId) seal_companyStamper.set_sealId('2490828768980361630') seal_companyStamper.set_type('COMPANY') seal_companyStamper.set_offsetX(0.3) seal_companyStamper.set_offsetY(0.5) seal_companyStamper.set_page(1) # 指定签署位置 - 时间戳签署位置 time_companyStamper = Stamper() time_companyStamper.set_documentId(file_documentId) time_companyStamper.set_type('TIMESTAMP') time_companyStamper.set_offsetX(0.5) time_companyStamper.set_offsetY(0.3) time_companyStamper.set_page(1) # 指定签署位置 - 骑缝章签署位置(文档页数大于1页才会生效) acrosspage_companyStamper = Stamper() acrosspage_companyStamper.set_documentId(file_documentId) acrosspage_companyStamper.set_sealId('2490828768980361630') acrosspage_companyStamper.set_type('ACROSS_PAGE') acrosspage_companyStamper.set_offsetY(0.7) seal_signParam.set_stampers([seal_companyStamper, time_companyStamper, acrosspage_companyStamper]) sealsign_response = sdkClient.request(ContractSignCompanyRequest(seal_signParam)) # 解析返回参数 sealsign_mapper = json.loads(sealsign_response) if sealsign_mapper['responseCode'] != "00000000": raise Exception('公章签署失败,失败原因:', sealsign_mapper['message']) print('公章签署成功') ``` -------------------------------- ### Get Template Page URL C# SDK Example Source: https://open.qiyuesuo.cn/document/2657083839569990338 This C# example illustrates initializing the SDKClient and retrieving a template preview page URL. It includes error handling with a try-catch block and response parsing. ```csharp // 初始化sdkClient string serverUrl = "https://openapi.qiyuesuo.cn"; string accessKey = "替换为您申请的开放平台App Token"; string accessSecret = "替换为您申请的开放平台App Secret"; SDKClient client = new SDKClient(accessKey, accessSecret, serverUrl); // 模板预览页面 TemplatePageRequest request = new TemplatePageRequest(); request.TemplateId = "2474165699643592754"; string response = null; try { response = client.Service(request); } catch (Exception e) { throw new Exception(e.Message); } // 解析返回内容 SdkResponse responseObject = HttpJsonConvert.DeserializeResponse(response); if (!responseObject.ResponseCode.Equals("00000000")) { throw new Exception("获取模板预览页失败,失败原因:" + responseObject.Message); } Console.WriteLine(“获取模板预览页成功”); Console.WriteLine(HttpJsonConvert.SerializeObject(responseObject)); ```