// Code generated by Lark OpenAPI.

package larkhire

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

type V2 struct {
	InterviewRecord *interviewRecord // interview_record
	Talent          *talent          // 人才
}

func New(config *larkcore.Config) *V2 {
	return &V2{
		InterviewRecord: &interviewRecord{config: config},
		Talent:          &talent{config: config},
	}
}

type interviewRecord struct {
	config *larkcore.Config
}
type talent struct {
	config *larkcore.Config
}

// Get
//
// -
//
// - 官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=hire&resource=interview_record&version=v2
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/hirev2/get_interviewRecord.go
func (i *interviewRecord) Get(ctx context.Context, req *GetInterviewRecordReq, options ...larkcore.RequestOptionFunc) (*GetInterviewRecordResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/hire/v2/interview_records/:interview_record_id"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, i.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetInterviewRecordResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, i.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=hire&resource=interview_record&version=v2
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/hirev2/list_interviewRecord.go
func (i *interviewRecord) List(ctx context.Context, req *ListInterviewRecordReq, options ...larkcore.RequestOptionFunc) (*ListInterviewRecordResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/hire/v2/interview_records"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser, larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, i.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListInterviewRecordResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, i.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (i *interviewRecord) ListByIterator(ctx context.Context, req *ListInterviewRecordReq, options ...larkcore.RequestOptionFunc) (*ListInterviewRecordIterator, error) {
	return &ListInterviewRecordIterator{
		ctx:      ctx,
		req:      req,
		listFunc: i.List,
		options:  options,
		limit:    req.Limit}, nil
}

// Get 获取人才信息V2
//
// - 根据人才 ID 获取人才信息
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/hire-v2/talent/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/hirev2/get_talent.go
func (t *talent) Get(ctx context.Context, req *GetTalentReq, options ...larkcore.RequestOptionFunc) (*GetTalentResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/hire/v2/talents/:talent_id"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetTalentResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
