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

// CreateMailPublicMailboxAlias 创建公共邮箱别名。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/mail-v1/public_mailbox-alias/create
// new doc: https://open.feishu.cn/document/server-docs/mail-v1/public-mailbox/public_mailbox-alias/create
func (r *MailService) CreateMailPublicMailboxAlias(ctx context.Context, request *CreateMailPublicMailboxAliasReq, options ...MethodOptionFunc) (*CreateMailPublicMailboxAliasResp, *Response, error) {
	if r.cli.mock.mockMailCreateMailPublicMailboxAlias != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Mail#CreateMailPublicMailboxAlias mock enable")
		return r.cli.mock.mockMailCreateMailPublicMailboxAlias(ctx, request, options...)
	}

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

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

// MockMailCreateMailPublicMailboxAlias mock MailCreateMailPublicMailboxAlias method
func (r *Mock) MockMailCreateMailPublicMailboxAlias(f func(ctx context.Context, request *CreateMailPublicMailboxAliasReq, options ...MethodOptionFunc) (*CreateMailPublicMailboxAliasResp, *Response, error)) {
	r.mockMailCreateMailPublicMailboxAlias = f
}

// UnMockMailCreateMailPublicMailboxAlias un-mock MailCreateMailPublicMailboxAlias method
func (r *Mock) UnMockMailCreateMailPublicMailboxAlias() {
	r.mockMailCreateMailPublicMailboxAlias = nil
}

// CreateMailPublicMailboxAliasReq ...
type CreateMailPublicMailboxAliasReq struct {
	PublicMailboxID string  `path:"public_mailbox_id" json:"-"` // 公共邮箱id或公共邮箱地址, 示例值: "xxxxxx 或 xxx@xx.xxx"
	EmailAlias      *string `json:"email_alias,omitempty"`      // 邮箱别名, 示例值: "xxx@xx.xxx"
}

// CreateMailPublicMailboxAliasResp ...
type CreateMailPublicMailboxAliasResp struct {
	PublicMailboxAlias *CreateMailPublicMailboxAliasRespPublicMailboxAlias `json:"public_mailbox_alias,omitempty"` // 公共邮箱别名
}

// CreateMailPublicMailboxAliasRespPublicMailboxAlias ...
type CreateMailPublicMailboxAliasRespPublicMailboxAlias struct {
	PrimaryEmail string `json:"primary_email,omitempty"` // 主邮箱地址
	EmailAlias   string `json:"email_alias,omitempty"`   // 邮箱别名
}

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