// Code generated by Lark OpenAPI.

package larkpayroll

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

type V1 struct {
	AcctItem              *acctItem              // acct_item
	CostAllocationDetail  *costAllocationDetail  // cost_allocation_detail
	CostAllocationPlan    *costAllocationPlan    // cost_allocation_plan
	CostAllocationReport  *costAllocationReport  // cost_allocation_report
	Datasource            *datasource            // datasource
	DatasourceRecord      *datasourceRecord      // datasource_record
	Paygroup              *paygroup              // paygroup
	PaymentActivity       *paymentActivity       // payment_activity
	PaymentActivityDetail *paymentActivityDetail // payment_activity_detail
	PaymentDetail         *paymentDetail         // payment_detail
}

func New(config *larkcore.Config) *V1 {
	return &V1{
		AcctItem:              &acctItem{config: config},
		CostAllocationDetail:  &costAllocationDetail{config: config},
		CostAllocationPlan:    &costAllocationPlan{config: config},
		CostAllocationReport:  &costAllocationReport{config: config},
		Datasource:            &datasource{config: config},
		DatasourceRecord:      &datasourceRecord{config: config},
		Paygroup:              &paygroup{config: config},
		PaymentActivity:       &paymentActivity{config: config},
		PaymentActivityDetail: &paymentActivityDetail{config: config},
		PaymentDetail:         &paymentDetail{config: config},
	}
}

type acctItem struct {
	config *larkcore.Config
}
type costAllocationDetail struct {
	config *larkcore.Config
}
type costAllocationPlan struct {
	config *larkcore.Config
}
type costAllocationReport struct {
	config *larkcore.Config
}
type datasource struct {
	config *larkcore.Config
}
type datasourceRecord struct {
	config *larkcore.Config
}
type paygroup struct {
	config *larkcore.Config
}
type paymentActivity struct {
	config *larkcore.Config
}
type paymentActivityDetail struct {
	config *larkcore.Config
}
type paymentDetail struct {
	config *larkcore.Config
}

// List
//
// - 批量查询算薪项
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=list&project=payroll&resource=acct_item&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/list_acctItem.go
func (a *acctItem) List(ctx context.Context, req *ListAcctItemReq, options ...larkcore.RequestOptionFunc) (*ListAcctItemResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/acct_items"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListAcctItemResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (a *acctItem) ListByIterator(ctx context.Context, req *ListAcctItemReq, options ...larkcore.RequestOptionFunc) (*ListAcctItemIterator, error) {
	return &ListAcctItemIterator{
		ctx:      ctx,
		req:      req,
		listFunc: a.List,
		options:  options,
		limit:    req.Limit}, nil
}

// List
//
// - 获取成本分摊报表明细数据
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=list&project=payroll&resource=cost_allocation_detail&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/list_costAllocationDetail.go
func (c *costAllocationDetail) List(ctx context.Context, req *ListCostAllocationDetailReq, options ...larkcore.RequestOptionFunc) (*ListCostAllocationDetailResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/cost_allocation_details"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListCostAllocationDetailResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.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=payroll&resource=cost_allocation_plan&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/list_costAllocationPlan.go
func (c *costAllocationPlan) List(ctx context.Context, req *ListCostAllocationPlanReq, options ...larkcore.RequestOptionFunc) (*ListCostAllocationPlanResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/cost_allocation_plans"
	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 := &ListCostAllocationPlanResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (c *costAllocationPlan) ListByIterator(ctx context.Context, req *ListCostAllocationPlanReq, options ...larkcore.RequestOptionFunc) (*ListCostAllocationPlanIterator, error) {
	return &ListCostAllocationPlanIterator{
		ctx:      ctx,
		req:      req,
		listFunc: c.List,
		options:  options,
		limit:    req.Limit}, nil
}

// List
//
// -
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=list&project=payroll&resource=cost_allocation_report&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/list_costAllocationReport.go
func (c *costAllocationReport) List(ctx context.Context, req *ListCostAllocationReportReq, options ...larkcore.RequestOptionFunc) (*ListCostAllocationReportResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/cost_allocation_reports"
	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 := &ListCostAllocationReportResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.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=payroll&resource=datasource&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/list_datasource.go
func (d *datasource) List(ctx context.Context, req *ListDatasourceReq, options ...larkcore.RequestOptionFunc) (*ListDatasourceResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/datasources"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, d.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListDatasourceResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, d.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (d *datasource) ListByIterator(ctx context.Context, req *ListDatasourceReq, options ...larkcore.RequestOptionFunc) (*ListDatasourceIterator, error) {
	return &ListDatasourceIterator{
		ctx:      ctx,
		req:      req,
		listFunc: d.List,
		options:  options,
		limit:    req.Limit}, nil
}

// Query
//
// - 获取外部数据源记录
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=query&project=payroll&resource=datasource_record&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/query_datasourceRecord.go
func (d *datasourceRecord) Query(ctx context.Context, req *QueryDatasourceRecordReq, options ...larkcore.RequestOptionFunc) (*QueryDatasourceRecordResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/datasource_records/query"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, d.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &QueryDatasourceRecordResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, d.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (d *datasourceRecord) QueryByIterator(ctx context.Context, req *QueryDatasourceRecordReq, options ...larkcore.RequestOptionFunc) (*QueryDatasourceRecordIterator, error) {
	return &QueryDatasourceRecordIterator{
		ctx:      ctx,
		req:      req,
		listFunc: d.Query,
		options:  options,
		limit:    req.Limit}, nil
}

// Save
//
// - 外部数据记录批量保存接口
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=save&project=payroll&resource=datasource_record&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/save_datasourceRecord.go
func (d *datasourceRecord) Save(ctx context.Context, req *SaveDatasourceRecordReq, options ...larkcore.RequestOptionFunc) (*SaveDatasourceRecordResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/datasource_records/save"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, d.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &SaveDatasourceRecordResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, d.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=payroll&resource=paygroup&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/list_paygroup.go
func (p *paygroup) List(ctx context.Context, req *ListPaygroupReq, options ...larkcore.RequestOptionFunc) (*ListPaygroupResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/paygroups"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, p.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListPaygroupResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, p.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (p *paygroup) ListByIterator(ctx context.Context, req *ListPaygroupReq, options ...larkcore.RequestOptionFunc) (*ListPaygroupIterator, error) {
	return &ListPaygroupIterator{
		ctx:      ctx,
		req:      req,
		listFunc: p.List,
		options:  options,
		limit:    req.Limit}, nil
}

// Archive
//
// - 封存发薪活动
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=archive&project=payroll&resource=payment_activity&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/archive_paymentActivity.go
func (p *paymentActivity) Archive(ctx context.Context, req *ArchivePaymentActivityReq, options ...larkcore.RequestOptionFunc) (*ArchivePaymentActivityResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/payment_activitys/archive"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, p.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ArchivePaymentActivityResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, p.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=payroll&resource=payment_activity&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/list_paymentActivity.go
func (p *paymentActivity) List(ctx context.Context, req *ListPaymentActivityReq, options ...larkcore.RequestOptionFunc) (*ListPaymentActivityResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/payment_activitys"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, p.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListPaymentActivityResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, p.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (p *paymentActivity) ListByIterator(ctx context.Context, req *ListPaymentActivityReq, options ...larkcore.RequestOptionFunc) (*ListPaymentActivityIterator, error) {
	return &ListPaymentActivityIterator{
		ctx:      ctx,
		req:      req,
		listFunc: p.List,
		options:  options,
		limit:    req.Limit}, nil
}

// List
//
// - 根据发薪活动 ID 和分页参数获取发薪活动明细列表
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=list&project=payroll&resource=payment_activity_detail&version=v1
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/payrollv1/list_paymentActivityDetail.go
func (p *paymentActivityDetail) List(ctx context.Context, req *ListPaymentActivityDetailReq, options ...larkcore.RequestOptionFunc) (*ListPaymentActivityDetailResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/payroll/v1/payment_activity_details"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, p.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListPaymentActivityDetailResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, p.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

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