// Code generated by Lark OpenAPI.

package larkworkplace

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

type V1 struct {
	CustomWorkplaceAccessData *customWorkplaceAccessData // custom_workplace_access_data
	WorkplaceAccessData       *workplaceAccessData       // workplace_access_data
	WorkplaceBlockAccessData  *workplaceBlockAccessData  // workplace_block_access_data
}

func New(config *larkcore.Config) *V1 {
	return &V1{
		CustomWorkplaceAccessData: &customWorkplaceAccessData{config: config},
		WorkplaceAccessData:       &workplaceAccessData{config: config},
		WorkplaceBlockAccessData:  &workplaceBlockAccessData{config: config},
	}
}

type customWorkplaceAccessData struct {
	config *larkcore.Config
}
type workplaceAccessData struct {
	config *larkcore.Config
}
type workplaceBlockAccessData struct {
	config *larkcore.Config
}

// Search
//
// -
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=search&project=workplace&resource=custom_workplace_access_data&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/workplacev1/search_customWorkplaceAccessData.go
func (c *customWorkplaceAccessData) Search(ctx context.Context, req *SearchCustomWorkplaceAccessDataReq, options ...larkcore.RequestOptionFunc) (*SearchCustomWorkplaceAccessDataResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/workplace/v1/custom_workplace_access_data/search"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &SearchCustomWorkplaceAccessDataResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Search
//
// -
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=search&project=workplace&resource=workplace_access_data&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/workplacev1/search_workplaceAccessData.go
func (w *workplaceAccessData) Search(ctx context.Context, req *SearchWorkplaceAccessDataReq, options ...larkcore.RequestOptionFunc) (*SearchWorkplaceAccessDataResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/workplace/v1/workplace_access_data/search"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, w.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &SearchWorkplaceAccessDataResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, w.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Search
//
// -
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=search&project=workplace&resource=workplace_block_access_data&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/workplacev1/search_workplaceBlockAccessData.go
func (w *workplaceBlockAccessData) Search(ctx context.Context, req *SearchWorkplaceBlockAccessDataReq, options ...larkcore.RequestOptionFunc) (*SearchWorkplaceBlockAccessDataResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/workplace/v1/workplace_block_access_data/search"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, w.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &SearchWorkplaceBlockAccessDataResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, w.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
