gitee.com/larksuite/oapi-sdk-go/v3@v3.0.3/service/gray_test_open_sg/v1/model.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  	"fmt"
    18  
    19  	"context"
    20  	"errors"
    21  
    22  	"gitee.com/larksuite/oapi-sdk-go/v3/core"
    23  )
    24  
    25  type Level struct {
    26  	Level *string `json:"level,omitempty"` // string
    27  	Body  *string `json:"body,omitempty"`  // body
    28  	Type  *string `json:"type,omitempty"`  // type
    29  }
    30  
    31  type LevelBuilder struct {
    32  	level     string // string
    33  	levelFlag bool
    34  	body      string // body
    35  	bodyFlag  bool
    36  	type_     string // type
    37  	typeFlag  bool
    38  }
    39  
    40  func NewLevelBuilder() *LevelBuilder {
    41  	builder := &LevelBuilder{}
    42  	return builder
    43  }
    44  
    45  // string
    46  //
    47  // 示例值:
    48  func (builder *LevelBuilder) Level(level string) *LevelBuilder {
    49  	builder.level = level
    50  	builder.levelFlag = true
    51  	return builder
    52  }
    53  
    54  // body
    55  //
    56  // 示例值:
    57  func (builder *LevelBuilder) Body(body string) *LevelBuilder {
    58  	builder.body = body
    59  	builder.bodyFlag = true
    60  	return builder
    61  }
    62  
    63  // type
    64  //
    65  // 示例值:
    66  func (builder *LevelBuilder) Type(type_ string) *LevelBuilder {
    67  	builder.type_ = type_
    68  	builder.typeFlag = true
    69  	return builder
    70  }
    71  
    72  func (builder *LevelBuilder) Build() *Level {
    73  	req := &Level{}
    74  	if builder.levelFlag {
    75  		req.Level = &builder.level
    76  
    77  	}
    78  	if builder.bodyFlag {
    79  		req.Body = &builder.body
    80  
    81  	}
    82  	if builder.typeFlag {
    83  		req.Type = &builder.type_
    84  
    85  	}
    86  	return req
    87  }
    88  
    89  type Moto struct {
    90  	MotoId   *string `json:"moto_id,omitempty"`   // desc
    91  	Id       *string `json:"id,omitempty"`        // desc2
    92  	UserName *string `json:"user_name,omitempty"` // name
    93  	Type     *string `json:"type,omitempty"`      // type
    94  }
    95  
    96  type MotoBuilder struct {
    97  	motoId       string // desc
    98  	motoIdFlag   bool
    99  	id           string // desc2
   100  	idFlag       bool
   101  	userName     string // name
   102  	userNameFlag bool
   103  	type_        string // type
   104  	typeFlag     bool
   105  }
   106  
   107  func NewMotoBuilder() *MotoBuilder {
   108  	builder := &MotoBuilder{}
   109  	return builder
   110  }
   111  
   112  // desc
   113  //
   114  // 示例值:
   115  func (builder *MotoBuilder) MotoId(motoId string) *MotoBuilder {
   116  	builder.motoId = motoId
   117  	builder.motoIdFlag = true
   118  	return builder
   119  }
   120  
   121  // desc2
   122  //
   123  // 示例值:
   124  func (builder *MotoBuilder) Id(id string) *MotoBuilder {
   125  	builder.id = id
   126  	builder.idFlag = true
   127  	return builder
   128  }
   129  
   130  // name
   131  //
   132  // 示例值:
   133  func (builder *MotoBuilder) UserName(userName string) *MotoBuilder {
   134  	builder.userName = userName
   135  	builder.userNameFlag = true
   136  	return builder
   137  }
   138  
   139  // type
   140  //
   141  // 示例值:
   142  func (builder *MotoBuilder) Type(type_ string) *MotoBuilder {
   143  	builder.type_ = type_
   144  	builder.typeFlag = true
   145  	return builder
   146  }
   147  
   148  func (builder *MotoBuilder) Build() *Moto {
   149  	req := &Moto{}
   150  	if builder.motoIdFlag {
   151  		req.MotoId = &builder.motoId
   152  
   153  	}
   154  	if builder.idFlag {
   155  		req.Id = &builder.id
   156  
   157  	}
   158  	if builder.userNameFlag {
   159  		req.UserName = &builder.userName
   160  
   161  	}
   162  	if builder.typeFlag {
   163  		req.Type = &builder.type_
   164  
   165  	}
   166  	return req
   167  }
   168  
   169  type CreateMotoReqBuilder struct {
   170  	apiReq *larkcore.ApiReq
   171  	level  *Level
   172  }
   173  
   174  func NewCreateMotoReqBuilder() *CreateMotoReqBuilder {
   175  	builder := &CreateMotoReqBuilder{}
   176  	builder.apiReq = &larkcore.ApiReq{
   177  		PathParams:  larkcore.PathParams{},
   178  		QueryParams: larkcore.QueryParams{},
   179  	}
   180  	return builder
   181  }
   182  
   183  // desc
   184  //
   185  // 示例值:
   186  func (builder *CreateMotoReqBuilder) DepartmentIdType(departmentIdType string) *CreateMotoReqBuilder {
   187  	builder.apiReq.QueryParams.Set("department_id_type", fmt.Sprint(departmentIdType))
   188  	return builder
   189  }
   190  
   191  //
   192  func (builder *CreateMotoReqBuilder) Level(level *Level) *CreateMotoReqBuilder {
   193  	builder.level = level
   194  	return builder
   195  }
   196  
   197  func (builder *CreateMotoReqBuilder) Build() *CreateMotoReq {
   198  	req := &CreateMotoReq{}
   199  	req.apiReq = &larkcore.ApiReq{}
   200  	req.apiReq.QueryParams = builder.apiReq.QueryParams
   201  	req.apiReq.Body = builder.level
   202  	return req
   203  }
   204  
   205  type CreateMotoReq struct {
   206  	apiReq *larkcore.ApiReq
   207  	Level  *Level `body:""`
   208  }
   209  
   210  type CreateMotoRespData struct {
   211  	Moto *Moto `json:"moto,omitempty"` // desc22222
   212  }
   213  
   214  type CreateMotoResp struct {
   215  	*larkcore.ApiResp `json:"-"`
   216  	larkcore.CodeError
   217  	Data *CreateMotoRespData `json:"data"` // 业务数据
   218  }
   219  
   220  func (resp *CreateMotoResp) Success() bool {
   221  	return resp.Code == 0
   222  }
   223  
   224  type GetMotoReqBuilder struct {
   225  	apiReq *larkcore.ApiReq
   226  }
   227  
   228  func NewGetMotoReqBuilder() *GetMotoReqBuilder {
   229  	builder := &GetMotoReqBuilder{}
   230  	builder.apiReq = &larkcore.ApiReq{
   231  		PathParams:  larkcore.PathParams{},
   232  		QueryParams: larkcore.QueryParams{},
   233  	}
   234  	return builder
   235  }
   236  
   237  // desc33333
   238  //
   239  // 示例值:
   240  func (builder *GetMotoReqBuilder) MotoId(motoId string) *GetMotoReqBuilder {
   241  	builder.apiReq.PathParams.Set("moto_id", fmt.Sprint(motoId))
   242  	return builder
   243  }
   244  
   245  // desc
   246  //
   247  // 示例值:
   248  func (builder *GetMotoReqBuilder) BodyLevel(bodyLevel string) *GetMotoReqBuilder {
   249  	builder.apiReq.QueryParams.Set("body_level", fmt.Sprint(bodyLevel))
   250  	return builder
   251  }
   252  
   253  func (builder *GetMotoReqBuilder) Build() *GetMotoReq {
   254  	req := &GetMotoReq{}
   255  	req.apiReq = &larkcore.ApiReq{}
   256  	req.apiReq.PathParams = builder.apiReq.PathParams
   257  	req.apiReq.QueryParams = builder.apiReq.QueryParams
   258  	return req
   259  }
   260  
   261  type GetMotoReq struct {
   262  	apiReq *larkcore.ApiReq
   263  }
   264  
   265  type GetMotoRespData struct {
   266  	Moto *Moto `json:"moto,omitempty"` // desc
   267  }
   268  
   269  type GetMotoResp struct {
   270  	*larkcore.ApiResp `json:"-"`
   271  	larkcore.CodeError
   272  	Data *GetMotoRespData `json:"data"` // 业务数据
   273  }
   274  
   275  func (resp *GetMotoResp) Success() bool {
   276  	return resp.Code == 0
   277  }
   278  
   279  type ListMotoReqBuilder struct {
   280  	apiReq *larkcore.ApiReq
   281  	limit  int // 最大返回多少记录,当使用迭代器访问时才有效
   282  }
   283  
   284  func NewListMotoReqBuilder() *ListMotoReqBuilder {
   285  	builder := &ListMotoReqBuilder{}
   286  	builder.apiReq = &larkcore.ApiReq{
   287  		PathParams:  larkcore.PathParams{},
   288  		QueryParams: larkcore.QueryParams{},
   289  	}
   290  	return builder
   291  }
   292  
   293  // 最大返回多少记录,当使用迭代器访问时才有效
   294  func (builder *ListMotoReqBuilder) Limit(limit int) *ListMotoReqBuilder {
   295  	builder.limit = limit
   296  	return builder
   297  }
   298  
   299  // 分页大小
   300  //
   301  // 示例值:
   302  func (builder *ListMotoReqBuilder) PageSize(pageSize int) *ListMotoReqBuilder {
   303  	builder.apiReq.QueryParams.Set("page_size", fmt.Sprint(pageSize))
   304  	return builder
   305  }
   306  
   307  // 分页标记,第一次请求不填,表示从头开始遍历;分页查询结果还有更多项时会同时返回新的 page_token,下次遍历可采用该 page_token 获取查询结果
   308  //
   309  // 示例值:
   310  func (builder *ListMotoReqBuilder) PageToken(pageToken string) *ListMotoReqBuilder {
   311  	builder.apiReq.QueryParams.Set("page_token", fmt.Sprint(pageToken))
   312  	return builder
   313  }
   314  
   315  // level
   316  //
   317  // 示例值:
   318  func (builder *ListMotoReqBuilder) Level(level int) *ListMotoReqBuilder {
   319  	builder.apiReq.QueryParams.Set("level", fmt.Sprint(level))
   320  	return builder
   321  }
   322  
   323  func (builder *ListMotoReqBuilder) Build() *ListMotoReq {
   324  	req := &ListMotoReq{}
   325  	req.apiReq = &larkcore.ApiReq{}
   326  	req.Limit = builder.limit
   327  	req.apiReq.QueryParams = builder.apiReq.QueryParams
   328  	return req
   329  }
   330  
   331  type ListMotoReq struct {
   332  	apiReq *larkcore.ApiReq
   333  	Limit  int // 最多返回多少记录,只有在使用迭代器访问时,才有效
   334  
   335  }
   336  
   337  type ListMotoRespData struct {
   338  	Items     []string `json:"items,omitempty"`      // desc
   339  	PageToken *string  `json:"page_token,omitempty"` //
   340  	HasMore   *bool    `json:"has_more,omitempty"`   //
   341  }
   342  
   343  type ListMotoResp struct {
   344  	*larkcore.ApiResp `json:"-"`
   345  	larkcore.CodeError
   346  	Data *ListMotoRespData `json:"data"` // 业务数据
   347  }
   348  
   349  func (resp *ListMotoResp) Success() bool {
   350  	return resp.Code == 0
   351  }
   352  
   353  type ListMotoIterator struct {
   354  	nextPageToken *string
   355  	items         []string
   356  	index         int
   357  	limit         int
   358  	ctx           context.Context
   359  	req           *ListMotoReq
   360  	listFunc      func(ctx context.Context, req *ListMotoReq, options ...larkcore.RequestOptionFunc) (*ListMotoResp, error)
   361  	options       []larkcore.RequestOptionFunc
   362  	curlNum       int
   363  }
   364  
   365  func (iterator *ListMotoIterator) Next() (bool, string, error) {
   366  	// 达到最大量,则返回
   367  	if iterator.limit > 0 && iterator.curlNum >= iterator.limit {
   368  		return false, "", nil
   369  	}
   370  
   371  	// 为0则拉取数据
   372  	if iterator.index == 0 || iterator.index >= len(iterator.items) {
   373  		if iterator.index != 0 && iterator.nextPageToken == nil {
   374  			return false, "", nil
   375  		}
   376  		if iterator.nextPageToken != nil {
   377  			iterator.req.apiReq.QueryParams.Set("page_token", *iterator.nextPageToken)
   378  		}
   379  		resp, err := iterator.listFunc(iterator.ctx, iterator.req, iterator.options...)
   380  		if err != nil {
   381  			return false, "", err
   382  		}
   383  
   384  		if resp.Code != 0 {
   385  			return false, "", errors.New(fmt.Sprintf("Code:%d,Msg:%s", resp.Code, resp.Msg))
   386  		}
   387  
   388  		if len(resp.Data.Items) == 0 {
   389  			return false, "", nil
   390  		}
   391  
   392  		iterator.nextPageToken = resp.Data.PageToken
   393  		iterator.items = resp.Data.Items
   394  		iterator.index = 0
   395  	}
   396  
   397  	block := iterator.items[iterator.index]
   398  	iterator.index++
   399  	iterator.curlNum++
   400  	return true, block, nil
   401  }
   402  
   403  func (iterator *ListMotoIterator) NextPageToken() *string {
   404  	return iterator.nextPageToken
   405  }