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

// SearchApplicationCustomWorkplaceAccessData 获取定制工作台访问数据
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/workplace-v1/custom_workplace_access_data/search
func (r *ApplicationService) SearchApplicationCustomWorkplaceAccessData(ctx context.Context, request *SearchApplicationCustomWorkplaceAccessDataReq, options ...MethodOptionFunc) (*SearchApplicationCustomWorkplaceAccessDataResp, *Response, error) {
	if r.cli.mock.mockApplicationSearchApplicationCustomWorkplaceAccessData != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Application#SearchApplicationCustomWorkplaceAccessData mock enable")
		return r.cli.mock.mockApplicationSearchApplicationCustomWorkplaceAccessData(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Application",
		API:                   "SearchApplicationCustomWorkplaceAccessData",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/workplace/v1/custom_workplace_access_data/search",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
	}
	resp := new(searchApplicationCustomWorkplaceAccessDataResp)

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

// MockApplicationSearchApplicationCustomWorkplaceAccessData mock ApplicationSearchApplicationCustomWorkplaceAccessData method
func (r *Mock) MockApplicationSearchApplicationCustomWorkplaceAccessData(f func(ctx context.Context, request *SearchApplicationCustomWorkplaceAccessDataReq, options ...MethodOptionFunc) (*SearchApplicationCustomWorkplaceAccessDataResp, *Response, error)) {
	r.mockApplicationSearchApplicationCustomWorkplaceAccessData = f
}

// UnMockApplicationSearchApplicationCustomWorkplaceAccessData un-mock ApplicationSearchApplicationCustomWorkplaceAccessData method
func (r *Mock) UnMockApplicationSearchApplicationCustomWorkplaceAccessData() {
	r.mockApplicationSearchApplicationCustomWorkplaceAccessData = nil
}

// SearchApplicationCustomWorkplaceAccessDataReq ...
type SearchApplicationCustomWorkplaceAccessDataReq struct {
	FromDate          string  `query:"from_date" json:"-"`           // 数据检索开始时间, 精确到日。格式yyyy-MM-dd, 示例值: 2023-03-01
	ToDate            string  `query:"to_date" json:"-"`             // 数据检索结束时间, 精确到日。格式yyyy-MM-dd, 示例值: 2023-03-22
	PageSize          int64   `query:"page_size" json:"-"`           // 分页大小, 最小为 1, 最大为 200, 默认为 20, 示例值: 20, 默认值: `20`, 取值范围: `1` ～ `100`
	PageToken         *string `query:"page_token" json:"-"`          // 分页标记, 第一次请求不填, 表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token, 下次遍历可采用该 page_token 获取查询结果, 示例值: ddowkdkl9w2d
	CustomWorkplaceID *string `query:"custom_workplace_id" json:"-"` // 定制工作台id, 非必填。不填时, 返回所有定制工作台数据, 如何获取定制工作台ID: 可前往 飞书管理后台 > 工作台 > 定制工作台, 点击指定工作台的 设置 进入设置页面；鼠标连续点击三次顶部的 设置 字样即可出现 ID, 复制 ID 即可, 示例值: tpl_647184b585400013254c4ea6
}

// SearchApplicationCustomWorkplaceAccessDataResp ...
type SearchApplicationCustomWorkplaceAccessDataResp struct {
	Items     []*SearchApplicationCustomWorkplaceAccessDataRespItem `json:"items,omitempty"`      // 定制工作台访问数据
	HasMore   bool                                                  `json:"has_more,omitempty"`   // 是否还有更多项
	PageToken string                                                `json:"page_token,omitempty"` // 分页标记, 当 has_more 为 true 时, 会同时返回新的 page_token, 否则不返回 page_token
}

// SearchApplicationCustomWorkplaceAccessDataRespItem ...
type SearchApplicationCustomWorkplaceAccessDataRespItem struct {
	CustomWorkplaceID   string                                                                   `json:"custom_workplace_id,omitempty"`   // 定制工作台ID
	AccessData          *SearchApplicationCustomWorkplaceAccessDataRespItemAccessData            `json:"access_data,omitempty"`           // 访问数据
	Date                string                                                                   `json:"date,omitempty"`                  // 时间, 精确到天, 格式yyyy-MM-dd
	CustomWorkplaceName []*SearchApplicationCustomWorkplaceAccessDataRespItemCustomWorkplaceName `json:"custom_workplace_name,omitempty"` // 定制工作台多语言名字。
}

// SearchApplicationCustomWorkplaceAccessDataRespItemAccessData ...
type SearchApplicationCustomWorkplaceAccessDataRespItemAccessData struct {
	Pv int64 `json:"pv,omitempty"` // 访问次数
	Uv int64 `json:"uv,omitempty"` // 访问用户数(去重)
}

// SearchApplicationCustomWorkplaceAccessDataRespItemCustomWorkplaceName ...
type SearchApplicationCustomWorkplaceAccessDataRespItemCustomWorkplaceName struct {
	Language string `json:"language,omitempty"` // ISO 639-1的语言代码。比如zh表示中文。
	Name     string `json:"name,omitempty"`     // 名字
}

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