gitee.com/larksuite/oapi-sdk-go/v3@v3.0.3/service/optical_char_recognition/v1/model.go (about) 1 // Package optical_char_recognition code generated by oapi sdk gen 2 /* 3 * MIT License 4 * 5 * Copyright (c) 2022 Lark Technologies Pte. Ltd. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 * 9 * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 */ 13 14 package larkoptical_char_recognition 15 16 import ( 17 "gitee.com/larksuite/oapi-sdk-go/v3/core" 18 ) 19 20 type Image struct { 21 } 22 23 type BasicRecognizeImageReqBodyBuilder struct { 24 image string // base64 后的图片数据 25 imageFlag bool 26 } 27 28 func NewBasicRecognizeImageReqBodyBuilder() *BasicRecognizeImageReqBodyBuilder { 29 builder := &BasicRecognizeImageReqBodyBuilder{} 30 return builder 31 } 32 33 // base64 后的图片数据 34 // 35 //示例值:base64后的图片二进制数据 36 func (builder *BasicRecognizeImageReqBodyBuilder) Image(image string) *BasicRecognizeImageReqBodyBuilder { 37 builder.image = image 38 builder.imageFlag = true 39 return builder 40 } 41 42 func (builder *BasicRecognizeImageReqBodyBuilder) Build() *BasicRecognizeImageReqBody { 43 req := &BasicRecognizeImageReqBody{} 44 if builder.imageFlag { 45 req.Image = &builder.image 46 } 47 return req 48 } 49 50 type BasicRecognizeImagePathReqBodyBuilder struct { 51 image string // base64 后的图片数据 52 imageFlag bool 53 } 54 55 func NewBasicRecognizeImagePathReqBodyBuilder() *BasicRecognizeImagePathReqBodyBuilder { 56 builder := &BasicRecognizeImagePathReqBodyBuilder{} 57 return builder 58 } 59 60 // base64 后的图片数据 61 // 62 // 示例值:base64后的图片二进制数据 63 func (builder *BasicRecognizeImagePathReqBodyBuilder) Image(image string) *BasicRecognizeImagePathReqBodyBuilder { 64 builder.image = image 65 builder.imageFlag = true 66 return builder 67 } 68 69 func (builder *BasicRecognizeImagePathReqBodyBuilder) Build() (*BasicRecognizeImageReqBody, error) { 70 req := &BasicRecognizeImageReqBody{} 71 if builder.imageFlag { 72 req.Image = &builder.image 73 } 74 return req, nil 75 } 76 77 type BasicRecognizeImageReqBuilder struct { 78 apiReq *larkcore.ApiReq 79 body *BasicRecognizeImageReqBody 80 } 81 82 func NewBasicRecognizeImageReqBuilder() *BasicRecognizeImageReqBuilder { 83 builder := &BasicRecognizeImageReqBuilder{} 84 builder.apiReq = &larkcore.ApiReq{ 85 PathParams: larkcore.PathParams{}, 86 QueryParams: larkcore.QueryParams{}, 87 } 88 return builder 89 } 90 91 // 可识别图片中的文字,按图片中的区域划分,分段返回文本列表 92 func (builder *BasicRecognizeImageReqBuilder) Body(body *BasicRecognizeImageReqBody) *BasicRecognizeImageReqBuilder { 93 builder.body = body 94 return builder 95 } 96 97 func (builder *BasicRecognizeImageReqBuilder) Build() *BasicRecognizeImageReq { 98 req := &BasicRecognizeImageReq{} 99 req.apiReq = &larkcore.ApiReq{} 100 req.apiReq.Body = builder.body 101 return req 102 } 103 104 type BasicRecognizeImageReqBody struct { 105 Image *string `json:"image,omitempty"` // base64 后的图片数据 106 } 107 108 type BasicRecognizeImageReq struct { 109 apiReq *larkcore.ApiReq 110 Body *BasicRecognizeImageReqBody `body:""` 111 } 112 113 type BasicRecognizeImageRespData struct { 114 TextList []string `json:"text_list,omitempty"` // 按区域识别,返回文本列表 115 } 116 117 type BasicRecognizeImageResp struct { 118 *larkcore.ApiResp `json:"-"` 119 larkcore.CodeError 120 Data *BasicRecognizeImageRespData `json:"data"` // 业务数据 121 } 122 123 func (resp *BasicRecognizeImageResp) Success() bool { 124 return resp.Code == 0 125 }