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

// SearchCoreHRCity 根据上级省份/行政区 ID 、城市 ID、状态 查询城市（自治区、地区、县「美」、町、村「日」）信息
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/basic_info-city/search
func (r *CoreHRService) SearchCoreHRCity(ctx context.Context, request *SearchCoreHRCityReq, options ...MethodOptionFunc) (*SearchCoreHRCityResp, *Response, error) {
	if r.cli.mock.mockCoreHRSearchCoreHRCity != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] CoreHR#SearchCoreHRCity mock enable")
		return r.cli.mock.mockCoreHRSearchCoreHRCity(ctx, request, options...)
	}

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

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

// MockCoreHRSearchCoreHRCity mock CoreHRSearchCoreHRCity method
func (r *Mock) MockCoreHRSearchCoreHRCity(f func(ctx context.Context, request *SearchCoreHRCityReq, options ...MethodOptionFunc) (*SearchCoreHRCityResp, *Response, error)) {
	r.mockCoreHRSearchCoreHRCity = f
}

// UnMockCoreHRSearchCoreHRCity un-mock CoreHRSearchCoreHRCity method
func (r *Mock) UnMockCoreHRSearchCoreHRCity() {
	r.mockCoreHRSearchCoreHRCity = nil
}

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

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

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

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

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