// Code generated by Lark OpenAPI.

package larkmdm

import (
	"context"
	"github.com/larksuite/oapi-sdk-go/v3/core"
	"net/http"
)

type V3 struct {
	BatchCountryRegion *batchCountryRegion // batch_country_region
	CountryRegion      *countryRegion      // country_region
}

func New(config *larkcore.Config) *V3 {
	return &V3{
		BatchCountryRegion: &batchCountryRegion{config: config},
		CountryRegion:      &countryRegion{config: config},
	}
}

type batchCountryRegion struct {
	config *larkcore.Config
}
type countryRegion struct {
	config *larkcore.Config
}

// Get
//
// - 查询国家 / 地区
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=mdm&resource=batch_country_region&version=v3
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/mdmv3/get_batchCountryRegion.go
func (b *batchCountryRegion) Get(ctx context.Context, req *GetBatchCountryRegionReq, options ...larkcore.RequestOptionFunc) (*GetBatchCountryRegionResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/mdm/v3/batch_country_region"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, b.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetBatchCountryRegionResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, b.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List
//
// - 搜索国家 / 地区
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=list&project=mdm&resource=country_region&version=v3
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/mdmv3/list_countryRegion.go
func (c *countryRegion) List(ctx context.Context, req *ListCountryRegionReq, options ...larkcore.RequestOptionFunc) (*ListCountryRegionResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/mdm/v3/country_regions"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListCountryRegionResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
