// Code generated by lark_sdk_gen. DO NOT EDIT.
/**
 * Copyright 2022 chyroc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package lark

import (
	"context"
)

// GetMailUser 使用邮箱状态查询接口, 可以输入邮箱地址, 查询出该邮箱地址对应的类型以及状态。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/mail-v1/user/query
// new doc: https://open.feishu.cn/document/server-docs/mail-v1/user/query
func (r *MailService) GetMailUser(ctx context.Context, request *GetMailUserReq, options ...MethodOptionFunc) (*GetMailUserResp, *Response, error) {
	if r.cli.mock.mockMailGetMailUser != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Mail#GetMailUser mock enable")
		return r.cli.mock.mockMailGetMailUser(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Mail",
		API:                   "GetMailUser",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/mail/v1/users/query",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
	}
	resp := new(getMailUserResp)

	response, err := r.cli.RawRequest(ctx, req, resp)
	return resp.Data, response, err
}

// MockMailGetMailUser mock MailGetMailUser method
func (r *Mock) MockMailGetMailUser(f func(ctx context.Context, request *GetMailUserReq, options ...MethodOptionFunc) (*GetMailUserResp, *Response, error)) {
	r.mockMailGetMailUser = f
}

// UnMockMailGetMailUser un-mock MailGetMailUser method
func (r *Mock) UnMockMailGetMailUser() {
	r.mockMailGetMailUser = nil
}

// GetMailUserReq ...
type GetMailUserReq struct {
	EmailList []string `json:"email_list,omitempty"` // 需要查询的邮箱地址列表, 示例值: ["test@a.com"]
}

// GetMailUserResp ...
type GetMailUserResp struct {
	UserList []*GetMailUserRespUser `json:"user_list,omitempty"` // 邮箱地址以及其对应的类型类型和状态
}

// GetMailUserRespUser ...
type GetMailUserRespUser struct {
	Email  string `json:"email,omitempty"`  // 邮箱地址
	Status int64  `json:"status,omitempty"` // 邮箱地址状态, 可选值有: 1: 邮箱地址格式错误, 2: 邮箱地址域名不存在, 3: 邮箱地址不存在, 4: 启用, 5: 已删除（邮箱回收站中）, 6: 禁用
	Type   int64  `json:"type,omitempty"`   // 邮箱地址类型, 可选值有: 1: 成员邮箱, 2: 成员邮箱别名, 3: 公共邮箱, 4: 公共邮箱别名, 5: 邮件组, 6: 邮件组别名
}

// getMailUserResp ...
type getMailUserResp struct {
	Code  int64            `json:"code,omitempty"` // 错误码, 非 0 表示失败
	Msg   string           `json:"msg,omitempty"`  // 错误描述
	Data  *GetMailUserResp `json:"data,omitempty"`
	Error *ErrorDetail     `json:"error,omitempty"`
}
