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

// RecognizeAIVatInvoice 增值税发票识别接口, 支持JPG/JPEG/PNG/PDF/BMP/OFD六种文件类型的一次性的识别。
//
// 单租户限流: 10QPS, 同租户下的应用没有限流, 共享本租户的 10QPS 限流
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/ai/document_ai-v1/vat_invoice/recognize
func (r *AIService) RecognizeAIVatInvoice(ctx context.Context, request *RecognizeAIVatInvoiceReq, options ...MethodOptionFunc) (*RecognizeAIVatInvoiceResp, *Response, error) {
	if r.cli.mock.mockAIRecognizeAIVatInvoice != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] AI#RecognizeAIVatInvoice mock enable")
		return r.cli.mock.mockAIRecognizeAIVatInvoice(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "AI",
		API:                   "RecognizeAIVatInvoice",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/document_ai/v1/vat_invoice/recognize",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		IsFile:                true,
	}
	resp := new(recognizeAIVatInvoiceResp)

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

// MockAIRecognizeAIVatInvoice mock AIRecognizeAIVatInvoice method
func (r *Mock) MockAIRecognizeAIVatInvoice(f func(ctx context.Context, request *RecognizeAIVatInvoiceReq, options ...MethodOptionFunc) (*RecognizeAIVatInvoiceResp, *Response, error)) {
	r.mockAIRecognizeAIVatInvoice = f
}

// UnMockAIRecognizeAIVatInvoice un-mock AIRecognizeAIVatInvoice method
func (r *Mock) UnMockAIRecognizeAIVatInvoice() {
	r.mockAIRecognizeAIVatInvoice = nil
}

// RecognizeAIVatInvoiceReq ...
type RecognizeAIVatInvoiceReq struct {
	File io.Reader `json:"file,omitempty"` // 识别的增值税发票文件（支持JPG/JPEG/PNG/PDF/BMP/OFD）, 示例值: file binary
}

// RecognizeAIVatInvoiceResp ...
type RecognizeAIVatInvoiceResp struct {
	VatInvoices []*RecognizeAIVatInvoiceRespVatInvoice `json:"vat_invoices,omitempty"` // 增值税发票信息
}

// RecognizeAIVatInvoiceRespVatInvoice ...
type RecognizeAIVatInvoiceRespVatInvoice struct {
	Entities []*RecognizeAIVatInvoiceRespVatInvoiceEntity `json:"entities,omitempty"` // 识别出的实体列表
}

// RecognizeAIVatInvoiceRespVatInvoiceEntity ...
type RecognizeAIVatInvoiceRespVatInvoiceEntity struct {
	Type  string `json:"type,omitempty"`  // 识别的实体类型, 可选值有: invoice_name: 发票抬头, invoice_code: 发票代码, invoice_no: 发票号码, invoice_date: 开票日期, total_price: 合计金额（不含税）, total_tax: 合计税额, big_total_price_and_tax: 合计总额（大写）, check_code: 校验码, total_price_and_tax: 合计总额, buyer_name: 购买方名称, buyer_taxpayer_no: 购买方纳税人识别号, buyer_address_phone: 购买方地址&电话所有人, buyer_account: 购买方开户行&账号, seller_name: 销售方名称, seller_taxpayer_no: 销售方纳税人识别号, seller_address_phone: 销售方地址&电话, seller_account: 销售方开户行&账号, payee: 收款人
	Value string `json:"value,omitempty"` // 识别出字段的文本信息
}

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