All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lark.oapi.service.approval.v4.resource.Approval Maven / Gradle / Ivy

// Code generated by lark suite oapi sdk gen
/*
 * MIT License
 *
 * Copyright (c) 2022 Lark Technologies Pte. Ltd.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.lark.oapi.service.approval.v4.resource;

import com.lark.oapi.core.token.AccessTokenType;
import com.lark.oapi.core.Transport;
import com.lark.oapi.core.response.RawResponse;
import com.lark.oapi.core.utils.UnmarshalRespUtil;
import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.core.utils.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.charset.StandardCharsets;

import com.lark.oapi.core.Config;
import com.lark.oapi.core.request.RequestOptions;

import java.io.ByteArrayOutputStream;

import com.lark.oapi.service.approval.v4.model.*;

import java.io.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;

public class Approval {
    private static final Logger log = LoggerFactory.getLogger(Approval.class);
    private final Config config;

    public Approval(Config config) {
        this.config = config;
    }


    /**
     * 创建审批定义,用于通过接口创建简单的审批定义,可以灵活指定定义的基础信息、表单和流程等。创建成功后,不支持从审批管理后台删除该定义。不推荐企业自建应用使用,如有需要尽量联系管理员在审批管理后台创建定义。
     * 

接口谨慎调用,创建后的审批定义无法停用/删除 ; *

官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/create ; *

使用Demo链接: https://github.com/larksuite/oapi-sdk-java/tree/v2_main/sample/src/main/java/com/lark/oapi/sample/apiall/approvalv4/CreateApprovalSample.java ; */ public CreateApprovalResp create(CreateApprovalReq req, RequestOptions reqOptions) throws Exception { // 请求参数选项 if (reqOptions == null) { reqOptions = new RequestOptions(); } // 发起请求 RawResponse httpResponse = Transport.send(config, reqOptions, "POST" , "/open-apis/approval/v4/approvals" , Sets.newHashSet(AccessTokenType.Tenant) , req); // 反序列化 CreateApprovalResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, CreateApprovalResp.class); if (resp == null) { log.error(String.format( "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", "/open-apis/approval/v4/approvals" , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), httpResponse.getStatusCode(), new String(httpResponse.getBody(), StandardCharsets.UTF_8))); throw new IllegalArgumentException("The result returned by the server is illegal"); } resp.setRawResponse(httpResponse); resp.setRequest(req); return resp; } /** * 创建审批定义,用于通过接口创建简单的审批定义,可以灵活指定定义的基础信息、表单和流程等。创建成功后,不支持从审批管理后台删除该定义。不推荐企业自建应用使用,如有需要尽量联系管理员在审批管理后台创建定义。 *

接口谨慎调用,创建后的审批定义无法停用/删除 ; *

官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/create ; *

使用Demo链接: https://github.com/larksuite/oapi-sdk-java/tree/v2_main/sample/src/main/java/com/lark/oapi/sample/apiall/approvalv4/CreateApprovalSample.java ; */ public CreateApprovalResp create(CreateApprovalReq req) throws Exception { // 请求参数选项 RequestOptions reqOptions = new RequestOptions(); // 发起请求 RawResponse httpResponse = Transport.send(config, reqOptions, "POST" , "/open-apis/approval/v4/approvals" , Sets.newHashSet(AccessTokenType.Tenant) , req); // 反序列化 CreateApprovalResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, CreateApprovalResp.class); if (resp == null) { log.error(String.format( "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", "/open-apis/approval/v4/approvals" , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), httpResponse.getStatusCode(), new String(httpResponse.getBody(), StandardCharsets.UTF_8))); throw new IllegalArgumentException("The result returned by the server is illegal"); } resp.setRawResponse(httpResponse); resp.setRequest(req); return resp; } /** * 查看审批定义,根据 Approval Code 获取某个审批定义的详情,用于构造创建审批实例的请求。 *

官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/get ; *

使用Demo链接: https://github.com/larksuite/oapi-sdk-java/tree/v2_main/sample/src/main/java/com/lark/oapi/sample/apiall/approvalv4/GetApprovalSample.java ; */ public GetApprovalResp get(GetApprovalReq req, RequestOptions reqOptions) throws Exception { // 请求参数选项 if (reqOptions == null) { reqOptions = new RequestOptions(); } // 发起请求 RawResponse httpResponse = Transport.send(config, reqOptions, "GET" , "/open-apis/approval/v4/approvals/:approval_code" , Sets.newHashSet(AccessTokenType.Tenant) , req); // 反序列化 GetApprovalResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, GetApprovalResp.class); if (resp == null) { log.error(String.format( "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", "/open-apis/approval/v4/approvals/:approval_code" , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), httpResponse.getStatusCode(), new String(httpResponse.getBody(), StandardCharsets.UTF_8))); throw new IllegalArgumentException("The result returned by the server is illegal"); } resp.setRawResponse(httpResponse); resp.setRequest(req); return resp; } /** * 查看审批定义,根据 Approval Code 获取某个审批定义的详情,用于构造创建审批实例的请求。 *

官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/get ; *

使用Demo链接: https://github.com/larksuite/oapi-sdk-java/tree/v2_main/sample/src/main/java/com/lark/oapi/sample/apiall/approvalv4/GetApprovalSample.java ; */ public GetApprovalResp get(GetApprovalReq req) throws Exception { // 请求参数选项 RequestOptions reqOptions = new RequestOptions(); // 发起请求 RawResponse httpResponse = Transport.send(config, reqOptions, "GET" , "/open-apis/approval/v4/approvals/:approval_code" , Sets.newHashSet(AccessTokenType.Tenant) , req); // 反序列化 GetApprovalResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, GetApprovalResp.class); if (resp == null) { log.error(String.format( "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", "/open-apis/approval/v4/approvals/:approval_code" , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), httpResponse.getStatusCode(), new String(httpResponse.getBody(), StandardCharsets.UTF_8))); throw new IllegalArgumentException("The result returned by the server is illegal"); } resp.setRawResponse(httpResponse); resp.setRequest(req); return resp; } /** * 订阅审批事件,应用订阅 approval_code 后,该应用就可以收到该审批定义对应实例的事件通知。同一应用只需要订阅一次,无需重复订阅。;;当应用不希望再收到审批事件时,可以使用取消订阅接口进行取消,取消后将不再给应用推送消息。;;订阅和取消订阅都是应用维度的,多个应用可以同时订阅同一个 approval_code,每个应用都能收到审批事件。 *

官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/subscribe ; *

使用Demo链接: https://github.com/larksuite/oapi-sdk-java/tree/v2_main/sample/src/main/java/com/lark/oapi/sample/apiall/approvalv4/SubscribeApprovalSample.java ; */ public SubscribeApprovalResp subscribe(SubscribeApprovalReq req, RequestOptions reqOptions) throws Exception { // 请求参数选项 if (reqOptions == null) { reqOptions = new RequestOptions(); } // 发起请求 RawResponse httpResponse = Transport.send(config, reqOptions, "POST" , "/open-apis/approval/v4/approvals/:approval_code/subscribe" , Sets.newHashSet(AccessTokenType.Tenant) , req); // 反序列化 SubscribeApprovalResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, SubscribeApprovalResp.class); if (resp == null) { log.error(String.format( "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", "/open-apis/approval/v4/approvals/:approval_code/subscribe" , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), httpResponse.getStatusCode(), new String(httpResponse.getBody(), StandardCharsets.UTF_8))); throw new IllegalArgumentException("The result returned by the server is illegal"); } resp.setRawResponse(httpResponse); resp.setRequest(req); return resp; } /** * 订阅审批事件,应用订阅 approval_code 后,该应用就可以收到该审批定义对应实例的事件通知。同一应用只需要订阅一次,无需重复订阅。;;当应用不希望再收到审批事件时,可以使用取消订阅接口进行取消,取消后将不再给应用推送消息。;;订阅和取消订阅都是应用维度的,多个应用可以同时订阅同一个 approval_code,每个应用都能收到审批事件。 *

官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/subscribe ; *

使用Demo链接: https://github.com/larksuite/oapi-sdk-java/tree/v2_main/sample/src/main/java/com/lark/oapi/sample/apiall/approvalv4/SubscribeApprovalSample.java ; */ public SubscribeApprovalResp subscribe(SubscribeApprovalReq req) throws Exception { // 请求参数选项 RequestOptions reqOptions = new RequestOptions(); // 发起请求 RawResponse httpResponse = Transport.send(config, reqOptions, "POST" , "/open-apis/approval/v4/approvals/:approval_code/subscribe" , Sets.newHashSet(AccessTokenType.Tenant) , req); // 反序列化 SubscribeApprovalResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, SubscribeApprovalResp.class); if (resp == null) { log.error(String.format( "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", "/open-apis/approval/v4/approvals/:approval_code/subscribe" , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), httpResponse.getStatusCode(), new String(httpResponse.getBody(), StandardCharsets.UTF_8))); throw new IllegalArgumentException("The result returned by the server is illegal"); } resp.setRawResponse(httpResponse); resp.setRequest(req); return resp; } /** * 取消订阅审批事件,取消订阅 approval_code 后,无法再收到该审批定义对应实例的事件通知 *

官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/unsubscribe ; *

使用Demo链接: https://github.com/larksuite/oapi-sdk-java/tree/v2_main/sample/src/main/java/com/lark/oapi/sample/apiall/approvalv4/UnsubscribeApprovalSample.java ; */ public UnsubscribeApprovalResp unsubscribe(UnsubscribeApprovalReq req, RequestOptions reqOptions) throws Exception { // 请求参数选项 if (reqOptions == null) { reqOptions = new RequestOptions(); } // 发起请求 RawResponse httpResponse = Transport.send(config, reqOptions, "POST" , "/open-apis/approval/v4/approvals/:approval_code/unsubscribe" , Sets.newHashSet(AccessTokenType.Tenant) , req); // 反序列化 UnsubscribeApprovalResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, UnsubscribeApprovalResp.class); if (resp == null) { log.error(String.format( "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", "/open-apis/approval/v4/approvals/:approval_code/unsubscribe" , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), httpResponse.getStatusCode(), new String(httpResponse.getBody(), StandardCharsets.UTF_8))); throw new IllegalArgumentException("The result returned by the server is illegal"); } resp.setRawResponse(httpResponse); resp.setRequest(req); return resp; } /** * 取消订阅审批事件,取消订阅 approval_code 后,无法再收到该审批定义对应实例的事件通知 *

官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/unsubscribe ; *

使用Demo链接: https://github.com/larksuite/oapi-sdk-java/tree/v2_main/sample/src/main/java/com/lark/oapi/sample/apiall/approvalv4/UnsubscribeApprovalSample.java ; */ public UnsubscribeApprovalResp unsubscribe(UnsubscribeApprovalReq req) throws Exception { // 请求参数选项 RequestOptions reqOptions = new RequestOptions(); // 发起请求 RawResponse httpResponse = Transport.send(config, reqOptions, "POST" , "/open-apis/approval/v4/approvals/:approval_code/unsubscribe" , Sets.newHashSet(AccessTokenType.Tenant) , req); // 反序列化 UnsubscribeApprovalResp resp = UnmarshalRespUtil.unmarshalResp(httpResponse, UnsubscribeApprovalResp.class); if (resp == null) { log.error(String.format( "%s,callError,req=%s,respHeader=%s,respStatusCode=%s,respBody=%s,", "/open-apis/approval/v4/approvals/:approval_code/unsubscribe" , Jsons.DEFAULT.toJson(req), Jsons.DEFAULT.toJson(httpResponse.getHeaders()), httpResponse.getStatusCode(), new String(httpResponse.getBody(), StandardCharsets.UTF_8))); throw new IllegalArgumentException("The result returned by the server is illegal"); } resp.setRawResponse(httpResponse); resp.setRequest(req); return resp; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy