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

     1  // Package gray_test_open_sg 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 larkgray_test_open_sg
    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) *GrayTestOpenSgService {
    24  	g := &GrayTestOpenSgService{config: config}
    25  	g.Moto = &moto{service: g}
    26  	return g
    27  }
    28  
    29  type GrayTestOpenSgService struct {
    30  	config *larkcore.Config
    31  	Moto   *moto // moto
    32  }
    33  
    34  type moto struct {
    35  	service *GrayTestOpenSgService
    36  }
    37  
    38  //
    39  //
    40  // -
    41  //
    42  // - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=create&project=gray_test_open_sg&resource=moto&version=v1
    43  //
    44  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/gray_test_open_sgv1/create_moto.go
    45  func (m *moto) Create(ctx context.Context, req *CreateMotoReq, options ...larkcore.RequestOptionFunc) (*CreateMotoResp, error) {
    46  	// 发起请求
    47  	apiReq := req.apiReq
    48  	apiReq.ApiPath = "/open-apis/gray_test_open_sg/v1/motos"
    49  	apiReq.HttpMethod = http.MethodPost
    50  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
    51  	apiResp, err := larkcore.Request(ctx, apiReq, m.service.config, options...)
    52  	if err != nil {
    53  		return nil, err
    54  	}
    55  	// 反序列响应结果
    56  	resp := &CreateMotoResp{ApiResp: apiResp}
    57  	err = apiResp.JSONUnmarshalBody(resp)
    58  	if err != nil {
    59  		return nil, err
    60  	}
    61  	return resp, err
    62  }
    63  
    64  //
    65  //
    66  // -
    67  //
    68  // - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=gray_test_open_sg&resource=moto&version=v1
    69  //
    70  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/gray_test_open_sgv1/get_moto.go
    71  func (m *moto) Get(ctx context.Context, req *GetMotoReq, options ...larkcore.RequestOptionFunc) (*GetMotoResp, error) {
    72  	// 发起请求
    73  	apiReq := req.apiReq
    74  	apiReq.ApiPath = "/open-apis/gray_test_open_sg/v1/motos/:moto_id"
    75  	apiReq.HttpMethod = http.MethodGet
    76  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
    77  	apiResp, err := larkcore.Request(ctx, apiReq, m.service.config, options...)
    78  	if err != nil {
    79  		return nil, err
    80  	}
    81  	// 反序列响应结果
    82  	resp := &GetMotoResp{ApiResp: apiResp}
    83  	err = apiResp.JSONUnmarshalBody(resp)
    84  	if err != nil {
    85  		return nil, err
    86  	}
    87  	return resp, err
    88  }
    89  
    90  //
    91  //
    92  // -
    93  //
    94  // - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=list&project=gray_test_open_sg&resource=moto&version=v1
    95  //
    96  // - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/gray_test_open_sgv1/list_moto.go
    97  func (m *moto) List(ctx context.Context, req *ListMotoReq, options ...larkcore.RequestOptionFunc) (*ListMotoResp, error) {
    98  	// 发起请求
    99  	apiReq := req.apiReq
   100  	apiReq.ApiPath = "/open-apis/gray_test_open_sg/v1/motos"
   101  	apiReq.HttpMethod = http.MethodGet
   102  	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant, larkcore.AccessTokenTypeUser}
   103  	apiResp, err := larkcore.Request(ctx, apiReq, m.service.config, options...)
   104  	if err != nil {
   105  		return nil, err
   106  	}
   107  	// 反序列响应结果
   108  	resp := &ListMotoResp{ApiResp: apiResp}
   109  	err = apiResp.JSONUnmarshalBody(resp)
   110  	if err != nil {
   111  		return nil, err
   112  	}
   113  	return resp, err
   114  }
   115  func (m *moto) ListByIterator(ctx context.Context, req *ListMotoReq, options ...larkcore.RequestOptionFunc) (*ListMotoIterator, error) {
   116  	return &ListMotoIterator{
   117  		ctx:      ctx,
   118  		req:      req,
   119  		listFunc: m.List,
   120  		options:  options,
   121  		limit:    req.Limit}, nil
   122  }