// Package passport code generated by 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 larkpassport

import (
	"fmt"

	"github.com/larksuite/oapi-sdk-go/v3/core"
)

const (
	KiteUserID          = 1 // UserID
	KiteIdpCredentialID = 2 // IdpCredentialID
	KiteSessionUUID     = 3 // Session 标识符

)

const (
	LogoutUserIDTypeOpenId  = "open_id"  // open_id
	LogoutUserIDTypeUnionId = "union_id" // union_id
	LogoutUserIDTypeUserId  = "user_id"  // user_id
)

const (
	MGetMaskSessionsByUserIDsUserIDTypeOpenId  = "open_id"  // 用户的 open id
	MGetMaskSessionsByUserIDsUserIDTypeUnionId = "union_id" // 用户的 union id
	MGetMaskSessionsByUserIDsUserIDTypeUserId  = "user_id"  // 用户的 user id
)

type Credentials struct {
	Email *string `json:"email,omitempty"` // 邮箱

	Mobile *string `json:"mobile,omitempty"` // 手机号

	UserId *string `json:"user_id,omitempty"` // 用户id
}

type CredentialsBuilder struct {
	email     string // 邮箱
	emailFlag bool

	mobile     string // 手机号
	mobileFlag bool

	userId     string // 用户id
	userIdFlag bool
}

func NewCredentialsBuilder() *CredentialsBuilder {
	builder := &CredentialsBuilder{}
	return builder
}

// 邮箱
//
// 示例值：q*****@qq.com
func (builder *CredentialsBuilder) Email(email string) *CredentialsBuilder {
	builder.email = email
	builder.emailFlag = true
	return builder
}

// 手机号
//
// 示例值：186*****01
func (builder *CredentialsBuilder) Mobile(mobile string) *CredentialsBuilder {
	builder.mobile = mobile
	builder.mobileFlag = true
	return builder
}

// 用户id
//
// 示例值：
func (builder *CredentialsBuilder) UserId(userId string) *CredentialsBuilder {
	builder.userId = userId
	builder.userIdFlag = true
	return builder
}

func (builder *CredentialsBuilder) Build() *Credentials {
	req := &Credentials{}
	if builder.emailFlag {
		req.Email = &builder.email

	}
	if builder.mobileFlag {
		req.Mobile = &builder.mobile

	}
	if builder.userIdFlag {
		req.UserId = &builder.userId

	}
	return req
}

type DepartmentId struct {
	DepartmentId *string `json:"department_id,omitempty"` //

	OpenDepartmentId *string `json:"open_department_id,omitempty"` //
}

type DepartmentIdBuilder struct {
	departmentId     string //
	departmentIdFlag bool

	openDepartmentId     string //
	openDepartmentIdFlag bool
}

func NewDepartmentIdBuilder() *DepartmentIdBuilder {
	builder := &DepartmentIdBuilder{}
	return builder
}

//
//
// 示例值：
func (builder *DepartmentIdBuilder) DepartmentId(departmentId string) *DepartmentIdBuilder {
	builder.departmentId = departmentId
	builder.departmentIdFlag = true
	return builder
}

//
//
// 示例值：
func (builder *DepartmentIdBuilder) OpenDepartmentId(openDepartmentId string) *DepartmentIdBuilder {
	builder.openDepartmentId = openDepartmentId
	builder.openDepartmentIdFlag = true
	return builder
}

func (builder *DepartmentIdBuilder) Build() *DepartmentId {
	req := &DepartmentId{}
	if builder.departmentIdFlag {
		req.DepartmentId = &builder.departmentId

	}
	if builder.openDepartmentIdFlag {
		req.OpenDepartmentId = &builder.openDepartmentId

	}
	return req
}

type Device struct {
	DeviceId *string `json:"device_id,omitempty"` // 当前设备ID

	LegacyDeviceId *string `json:"legacy_device_id,omitempty"` // 历史使用的设备ID
}

type DeviceBuilder struct {
	deviceId     string // 当前设备ID
	deviceIdFlag bool

	legacyDeviceId     string // 历史使用的设备ID
	legacyDeviceIdFlag bool
}

func NewDeviceBuilder() *DeviceBuilder {
	builder := &DeviceBuilder{}
	return builder
}

// 当前设备ID
//
// 示例值：1234
func (builder *DeviceBuilder) DeviceId(deviceId string) *DeviceBuilder {
	builder.deviceId = deviceId
	builder.deviceIdFlag = true
	return builder
}

// 历史使用的设备ID
//
// 示例值：4567
func (builder *DeviceBuilder) LegacyDeviceId(legacyDeviceId string) *DeviceBuilder {
	builder.legacyDeviceId = legacyDeviceId
	builder.legacyDeviceIdFlag = true
	return builder
}

func (builder *DeviceBuilder) Build() *Device {
	req := &Device{}
	if builder.deviceIdFlag {
		req.DeviceId = &builder.deviceId

	}
	if builder.legacyDeviceIdFlag {
		req.LegacyDeviceId = &builder.legacyDeviceId

	}
	return req
}

type IdpCredential struct {
}

type IdpCredentialBuilder struct {
}

func NewIdpCredentialBuilder() *IdpCredentialBuilder {
	builder := &IdpCredentialBuilder{}
	return builder
}

func (builder *IdpCredentialBuilder) Build() *IdpCredential {
	req := &IdpCredential{}
	return req
}

type IdpCredentialId struct {
	IdpCredentialId *string `json:"idp_credential_id,omitempty"` // idp侧租户唯一标识
}

type IdpCredentialIdBuilder struct {
	idpCredentialId     string // idp侧租户唯一标识
	idpCredentialIdFlag bool
}

func NewIdpCredentialIdBuilder() *IdpCredentialIdBuilder {
	builder := &IdpCredentialIdBuilder{}
	return builder
}

// idp侧租户唯一标识
//
// 示例值：
func (builder *IdpCredentialIdBuilder) IdpCredentialId(idpCredentialId string) *IdpCredentialIdBuilder {
	builder.idpCredentialId = idpCredentialId
	builder.idpCredentialIdFlag = true
	return builder
}

func (builder *IdpCredentialIdBuilder) Build() *IdpCredentialId {
	req := &IdpCredentialId{}
	if builder.idpCredentialIdFlag {
		req.IdpCredentialId = &builder.idpCredentialId

	}
	return req
}

type MaskSession struct {
	CreateTime *string `json:"create_time,omitempty"` // 创建时间

	TerminalType *int `json:"terminal_type,omitempty"` // 客户端类型

	UserId *string `json:"user_id,omitempty"` // 用户ID

	Sid *string `json:"sid,omitempty"` // 需要登出的 session 标识符
}

type MaskSessionBuilder struct {
	createTime     string // 创建时间
	createTimeFlag bool

	terminalType     int // 客户端类型
	terminalTypeFlag bool

	userId     string // 用户ID
	userIdFlag bool

	sid     string // 需要登出的 session 标识符
	sidFlag bool
}

func NewMaskSessionBuilder() *MaskSessionBuilder {
	builder := &MaskSessionBuilder{}
	return builder
}

// 创建时间
//
// 示例值：1724233829
func (builder *MaskSessionBuilder) CreateTime(createTime string) *MaskSessionBuilder {
	builder.createTime = createTime
	builder.createTimeFlag = true
	return builder
}

// 客户端类型
//
// 示例值：2
func (builder *MaskSessionBuilder) TerminalType(terminalType int) *MaskSessionBuilder {
	builder.terminalType = terminalType
	builder.terminalTypeFlag = true
	return builder
}

// 用户ID
//
// 示例值：ou_7dab8a3d3cdcc9da365777c7ad535d62
func (builder *MaskSessionBuilder) UserId(userId string) *MaskSessionBuilder {
	builder.userId = userId
	builder.userIdFlag = true
	return builder
}

// 需要登出的 session 标识符
//
// 示例值：AAAAAAAAAANll6nQoIAAFA==
func (builder *MaskSessionBuilder) Sid(sid string) *MaskSessionBuilder {
	builder.sid = sid
	builder.sidFlag = true
	return builder
}

func (builder *MaskSessionBuilder) Build() *MaskSession {
	req := &MaskSession{}
	if builder.createTimeFlag {
		req.CreateTime = &builder.createTime

	}
	if builder.terminalTypeFlag {
		req.TerminalType = &builder.terminalType

	}
	if builder.userIdFlag {
		req.UserId = &builder.userId

	}
	if builder.sidFlag {
		req.Sid = &builder.sid

	}
	return req
}

type LogoutSessionReqBodyBuilder struct {
	idpCredentialId     string // idp 侧的唯一标识
	idpCredentialIdFlag bool

	logoutType     int // 登出的方式
	logoutTypeFlag bool

	terminalType     []int // 登出的客户端类型，默认全部登出，1-桌面端，2-网页端，3-安卓移动端，4-Apple移动端 5-服务端 6-旧版小程序端 8-其他移动端
	terminalTypeFlag bool

	userId     string // user_id
	userIdFlag bool

	logoutReason     int // 登出原因
	logoutReasonFlag bool

	sid     string // 需要精确登出的 session 标识符
	sidFlag bool
}

func NewLogoutSessionReqBodyBuilder() *LogoutSessionReqBodyBuilder {
	builder := &LogoutSessionReqBodyBuilder{}
	return builder
}

// idp 侧的唯一标识
//
//示例值：1
func (builder *LogoutSessionReqBodyBuilder) IdpCredentialId(idpCredentialId string) *LogoutSessionReqBodyBuilder {
	builder.idpCredentialId = idpCredentialId
	builder.idpCredentialIdFlag = true
	return builder
}

// 登出的方式
//
//示例值：1
func (builder *LogoutSessionReqBodyBuilder) LogoutType(logoutType int) *LogoutSessionReqBodyBuilder {
	builder.logoutType = logoutType
	builder.logoutTypeFlag = true
	return builder
}

// 登出的客户端类型，默认全部登出，1-桌面端，2-网页端，3-安卓移动端，4-Apple移动端 5-服务端 6-旧版小程序端 8-其他移动端
//
//示例值：
func (builder *LogoutSessionReqBodyBuilder) TerminalType(terminalType []int) *LogoutSessionReqBodyBuilder {
	builder.terminalType = terminalType
	builder.terminalTypeFlag = true
	return builder
}

// user_id
//
//示例值：1
func (builder *LogoutSessionReqBodyBuilder) UserId(userId string) *LogoutSessionReqBodyBuilder {
	builder.userId = userId
	builder.userIdFlag = true
	return builder
}

// 登出原因
//
//示例值：34: 修改密码；35: 登陆态失效；36: 密码过期
func (builder *LogoutSessionReqBodyBuilder) LogoutReason(logoutReason int) *LogoutSessionReqBodyBuilder {
	builder.logoutReason = logoutReason
	builder.logoutReasonFlag = true
	return builder
}

// 需要精确登出的 session 标识符
//
//示例值：AAAAAAAAAANll6nQoIAAFA==
func (builder *LogoutSessionReqBodyBuilder) Sid(sid string) *LogoutSessionReqBodyBuilder {
	builder.sid = sid
	builder.sidFlag = true
	return builder
}

func (builder *LogoutSessionReqBodyBuilder) Build() *LogoutSessionReqBody {
	req := &LogoutSessionReqBody{}
	if builder.idpCredentialIdFlag {
		req.IdpCredentialId = &builder.idpCredentialId
	}
	if builder.logoutTypeFlag {
		req.LogoutType = &builder.logoutType
	}
	if builder.terminalTypeFlag {
		req.TerminalType = builder.terminalType
	}
	if builder.userIdFlag {
		req.UserId = &builder.userId
	}
	if builder.logoutReasonFlag {
		req.LogoutReason = &builder.logoutReason
	}
	if builder.sidFlag {
		req.Sid = &builder.sid
	}
	return req
}

type LogoutSessionPathReqBodyBuilder struct {
	idpCredentialId     string
	idpCredentialIdFlag bool
	logoutType          int
	logoutTypeFlag      bool
	terminalType        []int
	terminalTypeFlag    bool
	userId              string
	userIdFlag          bool
	logoutReason        int
	logoutReasonFlag    bool
	sid                 string
	sidFlag             bool
}

func NewLogoutSessionPathReqBodyBuilder() *LogoutSessionPathReqBodyBuilder {
	builder := &LogoutSessionPathReqBodyBuilder{}
	return builder
}

// idp 侧的唯一标识
//
// 示例值：1
func (builder *LogoutSessionPathReqBodyBuilder) IdpCredentialId(idpCredentialId string) *LogoutSessionPathReqBodyBuilder {
	builder.idpCredentialId = idpCredentialId
	builder.idpCredentialIdFlag = true
	return builder
}

// 登出的方式
//
// 示例值：1
func (builder *LogoutSessionPathReqBodyBuilder) LogoutType(logoutType int) *LogoutSessionPathReqBodyBuilder {
	builder.logoutType = logoutType
	builder.logoutTypeFlag = true
	return builder
}

// 登出的客户端类型，默认全部登出，1-桌面端，2-网页端，3-安卓移动端，4-Apple移动端 5-服务端 6-旧版小程序端 8-其他移动端
//
// 示例值：
func (builder *LogoutSessionPathReqBodyBuilder) TerminalType(terminalType []int) *LogoutSessionPathReqBodyBuilder {
	builder.terminalType = terminalType
	builder.terminalTypeFlag = true
	return builder
}

// user_id
//
// 示例值：1
func (builder *LogoutSessionPathReqBodyBuilder) UserId(userId string) *LogoutSessionPathReqBodyBuilder {
	builder.userId = userId
	builder.userIdFlag = true
	return builder
}

// 登出原因
//
// 示例值：34: 修改密码；35: 登陆态失效；36: 密码过期
func (builder *LogoutSessionPathReqBodyBuilder) LogoutReason(logoutReason int) *LogoutSessionPathReqBodyBuilder {
	builder.logoutReason = logoutReason
	builder.logoutReasonFlag = true
	return builder
}

// 需要精确登出的 session 标识符
//
// 示例值：AAAAAAAAAANll6nQoIAAFA==
func (builder *LogoutSessionPathReqBodyBuilder) Sid(sid string) *LogoutSessionPathReqBodyBuilder {
	builder.sid = sid
	builder.sidFlag = true
	return builder
}

func (builder *LogoutSessionPathReqBodyBuilder) Build() (*LogoutSessionReqBody, error) {
	req := &LogoutSessionReqBody{}
	if builder.idpCredentialIdFlag {
		req.IdpCredentialId = &builder.idpCredentialId
	}
	if builder.logoutTypeFlag {
		req.LogoutType = &builder.logoutType
	}
	if builder.terminalTypeFlag {
		req.TerminalType = builder.terminalType
	}
	if builder.userIdFlag {
		req.UserId = &builder.userId
	}
	if builder.logoutReasonFlag {
		req.LogoutReason = &builder.logoutReason
	}
	if builder.sidFlag {
		req.Sid = &builder.sid
	}
	return req, nil
}

type LogoutSessionReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *LogoutSessionReqBody
}

func NewLogoutSessionReqBuilder() *LogoutSessionReqBuilder {
	builder := &LogoutSessionReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// user_id_type
//
// 示例值：open_id
func (builder *LogoutSessionReqBuilder) UserIdType(userIdType string) *LogoutSessionReqBuilder {
	builder.apiReq.QueryParams.Set("user_id_type", fmt.Sprint(userIdType))
	return builder
}

//
func (builder *LogoutSessionReqBuilder) Body(body *LogoutSessionReqBody) *LogoutSessionReqBuilder {
	builder.body = body
	return builder
}

func (builder *LogoutSessionReqBuilder) Build() *LogoutSessionReq {
	req := &LogoutSessionReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.body
	return req
}

type LogoutSessionReqBody struct {
	IdpCredentialId *string `json:"idp_credential_id,omitempty"` // idp 侧的唯一标识

	LogoutType *int `json:"logout_type,omitempty"` // 登出的方式

	TerminalType []int `json:"terminal_type,omitempty"` // 登出的客户端类型，默认全部登出，1-桌面端，2-网页端，3-安卓移动端，4-Apple移动端 5-服务端 6-旧版小程序端 8-其他移动端

	UserId *string `json:"user_id,omitempty"` // user_id

	LogoutReason *int `json:"logout_reason,omitempty"` // 登出原因

	Sid *string `json:"sid,omitempty"` // 需要精确登出的 session 标识符
}

type LogoutSessionReq struct {
	apiReq *larkcore.ApiReq
	Body   *LogoutSessionReqBody `body:""`
}

type LogoutSessionResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
}

func (resp *LogoutSessionResp) Success() bool {
	return resp.Code == 0
}

type QuerySessionReqBodyBuilder struct {
	userIds     []string // 用户 ID
	userIdsFlag bool
}

func NewQuerySessionReqBodyBuilder() *QuerySessionReqBodyBuilder {
	builder := &QuerySessionReqBodyBuilder{}
	return builder
}

// 用户 ID
//
//示例值：["47f621ff"]
func (builder *QuerySessionReqBodyBuilder) UserIds(userIds []string) *QuerySessionReqBodyBuilder {
	builder.userIds = userIds
	builder.userIdsFlag = true
	return builder
}

func (builder *QuerySessionReqBodyBuilder) Build() *QuerySessionReqBody {
	req := &QuerySessionReqBody{}
	if builder.userIdsFlag {
		req.UserIds = builder.userIds
	}
	return req
}

type QuerySessionPathReqBodyBuilder struct {
	userIds     []string
	userIdsFlag bool
}

func NewQuerySessionPathReqBodyBuilder() *QuerySessionPathReqBodyBuilder {
	builder := &QuerySessionPathReqBodyBuilder{}
	return builder
}

// 用户 ID
//
// 示例值：["47f621ff"]
func (builder *QuerySessionPathReqBodyBuilder) UserIds(userIds []string) *QuerySessionPathReqBodyBuilder {
	builder.userIds = userIds
	builder.userIdsFlag = true
	return builder
}

func (builder *QuerySessionPathReqBodyBuilder) Build() (*QuerySessionReqBody, error) {
	req := &QuerySessionReqBody{}
	if builder.userIdsFlag {
		req.UserIds = builder.userIds
	}
	return req, nil
}

type QuerySessionReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *QuerySessionReqBody
}

func NewQuerySessionReqBuilder() *QuerySessionReqBuilder {
	builder := &QuerySessionReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 用户id类型
//
// 示例值：open_id
func (builder *QuerySessionReqBuilder) UserIdType(userIdType string) *QuerySessionReqBuilder {
	builder.apiReq.QueryParams.Set("user_id_type", fmt.Sprint(userIdType))
	return builder
}

// 该接口用于查询用户的登录信息
func (builder *QuerySessionReqBuilder) Body(body *QuerySessionReqBody) *QuerySessionReqBuilder {
	builder.body = body
	return builder
}

func (builder *QuerySessionReqBuilder) Build() *QuerySessionReq {
	req := &QuerySessionReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.body
	return req
}

type QuerySessionReqBody struct {
	UserIds []string `json:"user_ids,omitempty"` // 用户 ID
}

type QuerySessionReq struct {
	apiReq *larkcore.ApiReq
	Body   *QuerySessionReqBody `body:""`
}

type QuerySessionRespData struct {
	MaskSessions []*MaskSession `json:"mask_sessions,omitempty"` // 用户登录信息
}

type QuerySessionResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *QuerySessionRespData `json:"data"` // 业务数据
}

func (resp *QuerySessionResp) Success() bool {
	return resp.Code == 0
}
