gitee.com/larksuite/oapi-sdk-go/v3@v3.0.3/service/passport/v1/model.go (about) 1 // Package passport 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 larkpassport 15 16 import ( 17 "fmt" 18 19 "gitee.com/larksuite/oapi-sdk-go/v3/core" 20 ) 21 22 const ( 23 UserIdTypeOpenId = "open_id" // 用户的 open id 24 UserIdTypeUnionId = "union_id" // 用户的 union id 25 UserIdTypeUserId = "user_id" // 用户的 user id 26 ) 27 28 type Credentials struct { 29 Email *string `json:"email,omitempty"` // 邮箱 30 Mobile *string `json:"mobile,omitempty"` // 手机号 31 UserId *string `json:"user_id,omitempty"` // 用户id 32 } 33 34 type CredentialsBuilder struct { 35 email string // 邮箱 36 emailFlag bool 37 mobile string // 手机号 38 mobileFlag bool 39 userId string // 用户id 40 userIdFlag bool 41 } 42 43 func NewCredentialsBuilder() *CredentialsBuilder { 44 builder := &CredentialsBuilder{} 45 return builder 46 } 47 48 // 邮箱 49 // 50 // 示例值:q*****@qq.com 51 func (builder *CredentialsBuilder) Email(email string) *CredentialsBuilder { 52 builder.email = email 53 builder.emailFlag = true 54 return builder 55 } 56 57 // 手机号 58 // 59 // 示例值:186*****01 60 func (builder *CredentialsBuilder) Mobile(mobile string) *CredentialsBuilder { 61 builder.mobile = mobile 62 builder.mobileFlag = true 63 return builder 64 } 65 66 // 用户id 67 // 68 // 示例值: 69 func (builder *CredentialsBuilder) UserId(userId string) *CredentialsBuilder { 70 builder.userId = userId 71 builder.userIdFlag = true 72 return builder 73 } 74 75 func (builder *CredentialsBuilder) Build() *Credentials { 76 req := &Credentials{} 77 if builder.emailFlag { 78 req.Email = &builder.email 79 80 } 81 if builder.mobileFlag { 82 req.Mobile = &builder.mobile 83 84 } 85 if builder.userIdFlag { 86 req.UserId = &builder.userId 87 88 } 89 return req 90 } 91 92 type IdpCredential struct { 93 } 94 95 type IdpCredentialId struct { 96 IdpCredentialId *string `json:"idp_credential_id,omitempty"` // idp侧租户唯一标识 97 } 98 99 type IdpCredentialIdBuilder struct { 100 idpCredentialId string // idp侧租户唯一标识 101 idpCredentialIdFlag bool 102 } 103 104 func NewIdpCredentialIdBuilder() *IdpCredentialIdBuilder { 105 builder := &IdpCredentialIdBuilder{} 106 return builder 107 } 108 109 // idp侧租户唯一标识 110 // 111 // 示例值: 112 func (builder *IdpCredentialIdBuilder) IdpCredentialId(idpCredentialId string) *IdpCredentialIdBuilder { 113 builder.idpCredentialId = idpCredentialId 114 builder.idpCredentialIdFlag = true 115 return builder 116 } 117 118 func (builder *IdpCredentialIdBuilder) Build() *IdpCredentialId { 119 req := &IdpCredentialId{} 120 if builder.idpCredentialIdFlag { 121 req.IdpCredentialId = &builder.idpCredentialId 122 123 } 124 return req 125 } 126 127 type MaskSession struct { 128 CreateTime *string `json:"create_time,omitempty"` // 创建时间 129 TerminalType *int `json:"terminal_type,omitempty"` // 客户端类型 130 UserId *string `json:"user_id,omitempty"` // 用户ID 131 } 132 133 type MaskSessionBuilder struct { 134 createTime string // 创建时间 135 createTimeFlag bool 136 terminalType int // 客户端类型 137 terminalTypeFlag bool 138 userId string // 用户ID 139 userIdFlag bool 140 } 141 142 func NewMaskSessionBuilder() *MaskSessionBuilder { 143 builder := &MaskSessionBuilder{} 144 return builder 145 } 146 147 // 创建时间 148 // 149 // 示例值: 150 func (builder *MaskSessionBuilder) CreateTime(createTime string) *MaskSessionBuilder { 151 builder.createTime = createTime 152 builder.createTimeFlag = true 153 return builder 154 } 155 156 // 客户端类型 157 // 158 // 示例值: 159 func (builder *MaskSessionBuilder) TerminalType(terminalType int) *MaskSessionBuilder { 160 builder.terminalType = terminalType 161 builder.terminalTypeFlag = true 162 return builder 163 } 164 165 // 用户ID 166 // 167 // 示例值: 168 func (builder *MaskSessionBuilder) UserId(userId string) *MaskSessionBuilder { 169 builder.userId = userId 170 builder.userIdFlag = true 171 return builder 172 } 173 174 func (builder *MaskSessionBuilder) Build() *MaskSession { 175 req := &MaskSession{} 176 if builder.createTimeFlag { 177 req.CreateTime = &builder.createTime 178 179 } 180 if builder.terminalTypeFlag { 181 req.TerminalType = &builder.terminalType 182 183 } 184 if builder.userIdFlag { 185 req.UserId = &builder.userId 186 187 } 188 return req 189 } 190 191 type QuerySessionReqBodyBuilder struct { 192 userIds []string // 用户 ID 193 userIdsFlag bool 194 } 195 196 func NewQuerySessionReqBodyBuilder() *QuerySessionReqBodyBuilder { 197 builder := &QuerySessionReqBodyBuilder{} 198 return builder 199 } 200 201 // 用户 ID 202 // 203 //示例值:["47f621ff"] 204 func (builder *QuerySessionReqBodyBuilder) UserIds(userIds []string) *QuerySessionReqBodyBuilder { 205 builder.userIds = userIds 206 builder.userIdsFlag = true 207 return builder 208 } 209 210 func (builder *QuerySessionReqBodyBuilder) Build() *QuerySessionReqBody { 211 req := &QuerySessionReqBody{} 212 if builder.userIdsFlag { 213 req.UserIds = builder.userIds 214 } 215 return req 216 } 217 218 type QuerySessionPathReqBodyBuilder struct { 219 userIds []string // 用户 ID 220 userIdsFlag bool 221 } 222 223 func NewQuerySessionPathReqBodyBuilder() *QuerySessionPathReqBodyBuilder { 224 builder := &QuerySessionPathReqBodyBuilder{} 225 return builder 226 } 227 228 // 用户 ID 229 // 230 // 示例值:["47f621ff"] 231 func (builder *QuerySessionPathReqBodyBuilder) UserIds(userIds []string) *QuerySessionPathReqBodyBuilder { 232 builder.userIds = userIds 233 builder.userIdsFlag = true 234 return builder 235 } 236 237 func (builder *QuerySessionPathReqBodyBuilder) Build() (*QuerySessionReqBody, error) { 238 req := &QuerySessionReqBody{} 239 if builder.userIdsFlag { 240 req.UserIds = builder.userIds 241 } 242 return req, nil 243 } 244 245 type QuerySessionReqBuilder struct { 246 apiReq *larkcore.ApiReq 247 body *QuerySessionReqBody 248 } 249 250 func NewQuerySessionReqBuilder() *QuerySessionReqBuilder { 251 builder := &QuerySessionReqBuilder{} 252 builder.apiReq = &larkcore.ApiReq{ 253 PathParams: larkcore.PathParams{}, 254 QueryParams: larkcore.QueryParams{}, 255 } 256 return builder 257 } 258 259 // 260 // 261 // 示例值:open_id 262 func (builder *QuerySessionReqBuilder) UserIdType(userIdType string) *QuerySessionReqBuilder { 263 builder.apiReq.QueryParams.Set("user_id_type", fmt.Sprint(userIdType)) 264 return builder 265 } 266 267 // 该接口用于查询用户的登录信息 268 func (builder *QuerySessionReqBuilder) Body(body *QuerySessionReqBody) *QuerySessionReqBuilder { 269 builder.body = body 270 return builder 271 } 272 273 func (builder *QuerySessionReqBuilder) Build() *QuerySessionReq { 274 req := &QuerySessionReq{} 275 req.apiReq = &larkcore.ApiReq{} 276 req.apiReq.QueryParams = builder.apiReq.QueryParams 277 req.apiReq.Body = builder.body 278 return req 279 } 280 281 type QuerySessionReqBody struct { 282 UserIds []string `json:"user_ids,omitempty"` // 用户 ID 283 } 284 285 type QuerySessionReq struct { 286 apiReq *larkcore.ApiReq 287 Body *QuerySessionReqBody `body:""` 288 } 289 290 type QuerySessionRespData struct { 291 MaskSessions []*MaskSession `json:"mask_sessions,omitempty"` // 用户登录信息 292 } 293 294 type QuerySessionResp struct { 295 *larkcore.ApiResp `json:"-"` 296 larkcore.CodeError 297 Data *QuerySessionRespData `json:"data"` // 业务数据 298 } 299 300 func (resp *QuerySessionResp) Success() bool { 301 return resp.Code == 0 302 }