// 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"
)

// GetUserInfo 通过 `user_access_token` 获取登录用户的信息。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/authen-v1/user_info/get
// new doc: https://open.feishu.cn/document/server-docs/authentication-management/login-state-management/get
func (r *AuthService) GetUserInfo(ctx context.Context, request *GetUserInfoReq, options ...MethodOptionFunc) (*GetUserInfoResp, *Response, error) {
	if r.cli.mock.mockAuthGetUserInfo != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Auth#GetUserInfo mock enable")
		return r.cli.mock.mockAuthGetUserInfo(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:               "Auth",
		API:                 "GetUserInfo",
		Method:              "GET",
		URL:                 r.cli.openBaseURL + "/open-apis/authen/v1/user_info",
		Body:                request,
		MethodOption:        newMethodOption(options),
		NeedUserAccessToken: true,
	}
	resp := new(getUserInfoResp)

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

// MockAuthGetUserInfo mock AuthGetUserInfo method
func (r *Mock) MockAuthGetUserInfo(f func(ctx context.Context, request *GetUserInfoReq, options ...MethodOptionFunc) (*GetUserInfoResp, *Response, error)) {
	r.mockAuthGetUserInfo = f
}

// UnMockAuthGetUserInfo un-mock AuthGetUserInfo method
func (r *Mock) UnMockAuthGetUserInfo() {
	r.mockAuthGetUserInfo = nil
}

// GetUserInfoReq ...
type GetUserInfoReq struct {
}

// GetUserInfoResp ...
type GetUserInfoResp struct {
	Name            string `json:"name,omitempty"`             // 用户姓名
	EnName          string `json:"en_name,omitempty"`          // 用户英文名称
	AvatarURL       string `json:"avatar_url,omitempty"`       // 用户头像
	AvatarThumb     string `json:"avatar_thumb,omitempty"`     // 用户头像 72x72
	AvatarMiddle    string `json:"avatar_middle,omitempty"`    // 用户头像 240x240
	AvatarBig       string `json:"avatar_big,omitempty"`       // 用户头像 640x640
	OpenID          string `json:"open_id,omitempty"`          // 用户在应用内的唯一标识
	UnionID         string `json:"union_id,omitempty"`         // 用户对ISV的唯一标识, 对于同一个ISV, 用户在其名下所有应用的union_id相同
	Email           string `json:"email,omitempty"`            // 用户邮箱, 字段权限要求: 获取用户邮箱信息
	EnterpriseEmail string `json:"enterprise_email,omitempty"` // 企业邮箱, 请先确保已在管理后台启用飞书邮箱服务, 字段权限要求: 获取用户受雇信息
	UserID          string `json:"user_id,omitempty"`          // 用户 user_id, 字段权限要求: 获取用户 user ID
	Mobile          string `json:"mobile,omitempty"`           // 用户手机号, 字段权限要求: 获取用户手机号
	TenantKey       string `json:"tenant_key,omitempty"`       // 当前企业标识
	EmployeeNo      string `json:"employee_no,omitempty"`      // 用户工号, 字段权限要求: 获取用户受雇信息
}

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