gitee.com/larksuite/oapi-sdk-go/v3@v3.0.3/service/application/v6/api.go (about)

     1  // Package application code generated by oapi sdk gen
     2  /*
     3   * MIT License
     4   *
     5   * Copyright (c) 2022 Lark Technologies Pte. Ltd.
     6   *
     7   * 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:
     8   *
     9   * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software.
    10   *
    11   * 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.
    12   */
    13  
    14  package larkapplication
    15  
    16  import (
    17  	"context"
    18  	"net/http"
    19  
    20  	"gitee.com/larksuite/oapi-sdk-go/v3/core"
    21  )
    22  
    23  func NewService(config *larkcore.Config) *ApplicationService {
    24  	a := &ApplicationService{config: config}
    25  	a.Application = &application{service: a}
    26  	a.ApplicationAppUsage = &applicationAppUsage{service: a}
    27  	a.ApplicationAppVersion = &applicationAppVersion{service: a}
    28  	a.ApplicationFeedback = &applicationFeedback{service: a}
    29  	a.ApplicationVisibility = &applicationVisibility{service: a}
    30  	return a
    31  }
    32  
    33  type ApplicationService struct {
    34  	config                *larkcore.Config
    35  	Application           *application           // 应用
    36  	ApplicationAppUsage   *applicationAppUsage   // 应用使用情况
    37  	ApplicationAppVersion *applicationAppVersion // 事件
    38  	ApplicationFeedback   *applicationFeedback   // 应用反馈
    39  	ApplicationVisibility *applicationVisibility // 事件
    40  }
    41  
    42  type application struct {
    43  	service *ApplicationService
    44  }
    45  type applicationAppUsage struct {
    46  	service *ApplicationService
    47  }
    48  type applicationAppVersion struct {
    49  	service *ApplicationService
    50  }
    51  type applicationFeedback struct {
    52  	service *ApplicationService
    53  }
    54  type applicationVisibility struct {
    55  	service *ApplicationService
    56  }
    57  
    58  // 获取应用信息
    59  //
    60  // - 根据app_id获取应用的基础信息
    61  //
    62  // - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application/get
    63  //
    64  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/applicationv6/get_application.go
    65  func (a *application) Get(ctx context.Context, req *GetApplicationReq, options ...larkcore.RequestOptionFunc) (*GetApplicationResp, error) {
    66  	// 发起请求
    67  	apiReq := req.apiReq
    68  	apiReq.ApiPath = "/open-apis/application/v6/applications/:app_id"
    69  	apiReq.HttpMethod = http.MethodGet
    70  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
    71  	apiResp, err := larkcore.Request(ctx, apiReq, a.service.config, options...)
    72  	if err != nil {
    73  		return nil, err
    74  	}
    75  	// 反序列响应结果
    76  	resp := &GetApplicationResp{ApiResp: apiResp}
    77  	err = apiResp.JSONUnmarshalBody(resp)
    78  	if err != nil {
    79  		return nil, err
    80  	}
    81  	return resp, err
    82  }
    83  
    84  // 更新应用分组信息
    85  //
    86  // - 更新应用的分组信息(分组会影响应用在工作台中的分类情况,请谨慎更新)
    87  //
    88  // - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application/patch
    89  //
    90  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/applicationv6/patch_application.go
    91  func (a *application) Patch(ctx context.Context, req *PatchApplicationReq, options ...larkcore.RequestOptionFunc) (*PatchApplicationResp, error) {
    92  	// 发起请求
    93  	apiReq := req.apiReq
    94  	apiReq.ApiPath = "/open-apis/application/v6/applications/:app_id"
    95  	apiReq.HttpMethod = http.MethodPatch
    96  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
    97  	apiResp, err := larkcore.Request(ctx, apiReq, a.service.config, options...)
    98  	if err != nil {
    99  		return nil, err
   100  	}
   101  	// 反序列响应结果
   102  	resp := &PatchApplicationResp{ApiResp: apiResp}
   103  	err = apiResp.JSONUnmarshalBody(resp)
   104  	if err != nil {
   105  		return nil, err
   106  	}
   107  	return resp, err
   108  }
   109  
   110  // 查看待审核的应用列表
   111  //
   112  // - 查看本企业下所有待审核的自建应用列表
   113  //
   114  // - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application/underauditlist
   115  //
   116  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/applicationv6/underauditlist_application.go
   117  func (a *application) Underauditlist(ctx context.Context, req *UnderauditlistApplicationReq, options ...larkcore.RequestOptionFunc) (*UnderauditlistApplicationResp, error) {
   118  	// 发起请求
   119  	apiReq := req.apiReq
   120  	apiReq.ApiPath = "/open-apis/application/v6/applications/underauditlist"
   121  	apiReq.HttpMethod = http.MethodGet
   122  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
   123  	apiResp, err := larkcore.Request(ctx, apiReq, a.service.config, options...)
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  	// 反序列响应结果
   128  	resp := &UnderauditlistApplicationResp{ApiResp: apiResp}
   129  	err = apiResp.JSONUnmarshalBody(resp)
   130  	if err != nil {
   131  		return nil, err
   132  	}
   133  	return resp, err
   134  }
   135  func (a *application) UnderauditlistByIterator(ctx context.Context, req *UnderauditlistApplicationReq, options ...larkcore.RequestOptionFunc) (*UnderauditlistApplicationIterator, error) {
   136  	return &UnderauditlistApplicationIterator{
   137  		ctx:      ctx,
   138  		req:      req,
   139  		listFunc: a.Underauditlist,
   140  		options:  options,
   141  		limit:    req.Limit}, nil
   142  }
   143  
   144  // 获取应用使用概览
   145  //
   146  // - 查看应用在某一天/某一周/某一个月的使用数据,可以查看租户整体对应用的使用情况,也可以分部门查看。
   147  //
   148  // - 1. 仅支持企业版/旗舰版租户使用;2. 一般每天早上10点产出前一天的数据;3. 已经支持的指标包括:应用的活跃用户数、累计用户数、新增用户数、访问页面数、打开次数;4. 数据从飞书4.10版本开始统计,使用飞书版本4.10及以下版本的用户数据不会被统计到;5. 按照部门查看数据时,会展示当前部门以及其子部门的整体使用情况;6. 调用频控为100次/分
   149  //
   150  // - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-app_usage/overview
   151  //
   152  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/applicationv6/overview_applicationAppUsage.go
   153  func (a *applicationAppUsage) Overview(ctx context.Context, req *OverviewApplicationAppUsageReq, options ...larkcore.RequestOptionFunc) (*OverviewApplicationAppUsageResp, error) {
   154  	// 发起请求
   155  	apiReq := req.apiReq
   156  	apiReq.ApiPath = "/open-apis/application/v6/applications/:app_id/app_usage/overview"
   157  	apiReq.HttpMethod = http.MethodPost
   158  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
   159  	apiResp, err := larkcore.Request(ctx, apiReq, a.service.config, options...)
   160  	if err != nil {
   161  		return nil, err
   162  	}
   163  	// 反序列响应结果
   164  	resp := &OverviewApplicationAppUsageResp{ApiResp: apiResp}
   165  	err = apiResp.JSONUnmarshalBody(resp)
   166  	if err != nil {
   167  		return nil, err
   168  	}
   169  	return resp, err
   170  }
   171  
   172  // 获取应用版本信息
   173  //
   174  // - 根据 app_id,version_id 获取对应应用版本的信息
   175  //
   176  // - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-app_version/get
   177  //
   178  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/applicationv6/get_applicationAppVersion.go
   179  func (a *applicationAppVersion) Get(ctx context.Context, req *GetApplicationAppVersionReq, options ...larkcore.RequestOptionFunc) (*GetApplicationAppVersionResp, error) {
   180  	// 发起请求
   181  	apiReq := req.apiReq
   182  	apiReq.ApiPath = "/open-apis/application/v6/applications/:app_id/app_versions/:version_id"
   183  	apiReq.HttpMethod = http.MethodGet
   184  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
   185  	apiResp, err := larkcore.Request(ctx, apiReq, a.service.config, options...)
   186  	if err != nil {
   187  		return nil, err
   188  	}
   189  	// 反序列响应结果
   190  	resp := &GetApplicationAppVersionResp{ApiResp: apiResp}
   191  	err = apiResp.JSONUnmarshalBody(resp)
   192  	if err != nil {
   193  		return nil, err
   194  	}
   195  	return resp, err
   196  }
   197  
   198  // 更新应用审核状态
   199  //
   200  // - 通过接口来更新应用版本的审核结果:通过后应用可以直接上架;拒绝后则开发者可以看到拒绝理由,并在修改后再次申请发布。
   201  //
   202  // - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-app_version/patch
   203  //
   204  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/applicationv6/patch_applicationAppVersion.go
   205  func (a *applicationAppVersion) Patch(ctx context.Context, req *PatchApplicationAppVersionReq, options ...larkcore.RequestOptionFunc) (*PatchApplicationAppVersionResp, error) {
   206  	// 发起请求
   207  	apiReq := req.apiReq
   208  	apiReq.ApiPath = "/open-apis/application/v6/applications/:app_id/app_versions/:version_id"
   209  	apiReq.HttpMethod = http.MethodPatch
   210  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
   211  	apiResp, err := larkcore.Request(ctx, apiReq, a.service.config, options...)
   212  	if err != nil {
   213  		return nil, err
   214  	}
   215  	// 反序列响应结果
   216  	resp := &PatchApplicationAppVersionResp{ApiResp: apiResp}
   217  	err = apiResp.JSONUnmarshalBody(resp)
   218  	if err != nil {
   219  		return nil, err
   220  	}
   221  	return resp, err
   222  }
   223  
   224  // 获取应用反馈列表
   225  //
   226  // - 查询应用的反馈数据
   227  //
   228  // - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-feedback/list
   229  //
   230  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/applicationv6/list_applicationFeedback.go
   231  func (a *applicationFeedback) List(ctx context.Context, req *ListApplicationFeedbackReq, options ...larkcore.RequestOptionFunc) (*ListApplicationFeedbackResp, error) {
   232  	// 发起请求
   233  	apiReq := req.apiReq
   234  	apiReq.ApiPath = "/open-apis/application/v6/applications/:app_id/feedbacks"
   235  	apiReq.HttpMethod = http.MethodGet
   236  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
   237  	apiResp, err := larkcore.Request(ctx, apiReq, a.service.config, options...)
   238  	if err != nil {
   239  		return nil, err
   240  	}
   241  	// 反序列响应结果
   242  	resp := &ListApplicationFeedbackResp{ApiResp: apiResp}
   243  	err = apiResp.JSONUnmarshalBody(resp)
   244  	if err != nil {
   245  		return nil, err
   246  	}
   247  	return resp, err
   248  }
   249  
   250  // 更新应用反馈
   251  //
   252  // - 更新应用的反馈数据
   253  //
   254  // - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-feedback/patch
   255  //
   256  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/applicationv6/patch_applicationFeedback.go
   257  func (a *applicationFeedback) Patch(ctx context.Context, req *PatchApplicationFeedbackReq, options ...larkcore.RequestOptionFunc) (*PatchApplicationFeedbackResp, error) {
   258  	// 发起请求
   259  	apiReq := req.apiReq
   260  	apiReq.ApiPath = "/open-apis/application/v6/applications/:app_id/feedbacks/:feedback_id"
   261  	apiReq.HttpMethod = http.MethodPatch
   262  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
   263  	apiResp, err := larkcore.Request(ctx, apiReq, a.service.config, options...)
   264  	if err != nil {
   265  		return nil, err
   266  	}
   267  	// 反序列响应结果
   268  	resp := &PatchApplicationFeedbackResp{ApiResp: apiResp}
   269  	err = apiResp.JSONUnmarshalBody(resp)
   270  	if err != nil {
   271  		return nil, err
   272  	}
   273  	return resp, err
   274  }