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

// CreateIMTag 创建标签并返回标签 ID。
//
// doc: https://open.larkoffice.com/document/uAjLw4CM/ukTMukTMukTM/group/im-v2/tag/create
func (r *MessageService) CreateIMTag(ctx context.Context, request *CreateIMTagReq, options ...MethodOptionFunc) (*CreateIMTagResp, *Response, error) {
	if r.cli.mock.mockMessageCreateIMTag != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Message#CreateIMTag mock enable")
		return r.cli.mock.mockMessageCreateIMTag(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Message",
		API:                   "CreateIMTag",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/im/v2/tags",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
	}
	resp := new(createIMTagResp)

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

// MockMessageCreateIMTag mock MessageCreateIMTag method
func (r *Mock) MockMessageCreateIMTag(f func(ctx context.Context, request *CreateIMTagReq, options ...MethodOptionFunc) (*CreateIMTagResp, *Response, error)) {
	r.mockMessageCreateIMTag = f
}

// UnMockMessageCreateIMTag un-mock MessageCreateIMTag method
func (r *Mock) UnMockMessageCreateIMTag() {
	r.mockMessageCreateIMTag = nil
}

// CreateIMTagReq ...
type CreateIMTagReq struct {
	CreateTag *CreateIMTagReqCreateTag `json:"create_tag,omitempty"` // 创建标签
}

// CreateIMTagReqCreateTag ...
type CreateIMTagReqCreateTag struct {
	TagType   string                             `json:"tag_type,omitempty"`   // 标签类型, 示例值: "tenant", 可选值有: tenant: 租户类型标签
	Name      string                             `json:"name,omitempty"`       // 标签默认名称, 示例值: "default name"
	I18nNames []*CreateIMTagReqCreateTagI18nName `json:"i18n_names,omitempty"` // i18n多语言标签名称集合, 长度范围: `0` ～ `40`
}

// CreateIMTagReqCreateTagI18nName ...
type CreateIMTagReqCreateTagI18nName struct {
	Locale string  `json:"locale,omitempty"` // 语言, 示例值: "zh_cn"
	Name   *string `json:"name,omitempty"`   // 名称, 示例值: "标签1"
}

// CreateIMTagResp ...
type CreateIMTagResp struct {
	ID                  string                              `json:"id,omitempty"`                     // 创建的 tag 的 ID
	CreateTagFailReason *CreateIMTagRespCreateTagFailReason `json:"create_tag_fail_reason,omitempty"` // 创建失败原因
}

// CreateIMTagRespCreateTagFailReason ...
type CreateIMTagRespCreateTagFailReason struct {
	DuplicateID string `json:"duplicate_id,omitempty"` // 名称重复的标签id
}

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