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

// SearchCoreHRDistrict 根据区/县 ID、上级城市 ID 查询区/县信息
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/basic_info-district/search
func (r *CoreHRService) SearchCoreHRDistrict(ctx context.Context, request *SearchCoreHRDistrictReq, options ...MethodOptionFunc) (*SearchCoreHRDistrictResp, *Response, error) {
	if r.cli.mock.mockCoreHRSearchCoreHRDistrict != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] CoreHR#SearchCoreHRDistrict mock enable")
		return r.cli.mock.mockCoreHRSearchCoreHRDistrict(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "CoreHR",
		API:                   "SearchCoreHRDistrict",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/corehr/v2/basic_info/districts/search",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
	}
	resp := new(searchCoreHRDistrictResp)

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

// MockCoreHRSearchCoreHRDistrict mock CoreHRSearchCoreHRDistrict method
func (r *Mock) MockCoreHRSearchCoreHRDistrict(f func(ctx context.Context, request *SearchCoreHRDistrictReq, options ...MethodOptionFunc) (*SearchCoreHRDistrictResp, *Response, error)) {
	r.mockCoreHRSearchCoreHRDistrict = f
}

// UnMockCoreHRSearchCoreHRDistrict un-mock CoreHRSearchCoreHRDistrict method
func (r *Mock) UnMockCoreHRSearchCoreHRDistrict() {
	r.mockCoreHRSearchCoreHRDistrict = nil
}

// SearchCoreHRDistrictReq ...
type SearchCoreHRDistrictReq struct {
	PageSize       int64    `query:"page_size" json:"-"`        // 分页大小, 最大 100, 示例值: 100, 取值范围: `1` ～ `100`
	PageToken      *string  `query:"page_token" json:"-"`       // 分页标记, 第一次请求不填, 表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token, 下次遍历可采用该 page_token 获取查询结果, 示例值: 6891251722631890445
	CityIDList     []string `json:"city_id_list,omitempty"`     // 所属城市 ID 列表, 详细信息可通过[查询城市信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/basic_info-city/search), 接口查询获得, 不填写则返回全部列表, 示例值: ["6891251722121891445"], 最大长度: `100`
	DistrictIDList []string `json:"district_id_list,omitempty"` // 区/县 ID 列表, 不填写则返回全部列表, 示例值: ["6891251733121891445"], 最大长度: `100`
	StatusList     []int64  `json:"status_list,omitempty"`      // 区/县状态列表, 不填写则返回全部列表, 示例值: [1], 可选值有: 1: 生效, 0: 失效, 默认值: `[1]`, 最大长度: `2`
}

// SearchCoreHRDistrictResp ...
type SearchCoreHRDistrictResp struct {
	Items     []*SearchCoreHRDistrictRespItem `json:"items,omitempty"`      // 查询的区/县信息
	PageToken string                          `json:"page_token,omitempty"` // 分页标记, 当 has_more 为 true 时, 会同时返回新的 page_token, 否则不返回 page_token
	HasMore   bool                            `json:"has_more,omitempty"`   // 是否还有更多项
}

// SearchCoreHRDistrictRespItem ...
type SearchCoreHRDistrictRespItem struct {
	DistrictID    string                              `json:"district_id,omitempty"`    // 区/县 ID
	Name          []*SearchCoreHRDistrictRespItemName `json:"name,omitempty"`           // 名称
	CityID        string                              `json:"city_id,omitempty"`        // 所属城市 ID, 详细信息可通过[查询城市信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/basic_info-city/search)接口获得
	SubregionCode string                              `json:"subregion_code,omitempty"` // 行政区划代码
	Status        int64                               `json:"status,omitempty"`         // 状态, 可选值有: 1: 生效, 0: 失效
}

// SearchCoreHRDistrictRespItemName ...
type SearchCoreHRDistrictRespItemName struct {
	Lang  string `json:"lang,omitempty"`  // 语言
	Value string `json:"value,omitempty"` // 内容
}

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