88from mindee .documents .invoice import Invoice
99from mindee .documents .passport import Passport
1010from mindee .documents .receipt import Receipt
11- from mindee .endpoints import (
12- OTS_OWNER ,
13- BankCheckEndpoint ,
14- CustomEndpoint ,
15- HTTPException ,
16- InvoiceEndpoint ,
17- PassportEndpoint ,
18- ReceiptEndpoint ,
19- )
11+ from mindee .endpoints import OTS_OWNER , CustomEndpoint , HTTPException , StandardEndpoint
2012from mindee .input .page_options import PageOptions
2113from mindee .input .sources import (
2214 Base64Input ,
@@ -91,7 +83,7 @@ def parse(
9183 doc_config .check_api_keys ()
9284 if page_options and self .input_doc .is_pdf ():
9385 self .input_doc .process_pdf (
94- page_options .behavior ,
86+ page_options .operation ,
9587 page_options .on_min_pages ,
9688 page_options .page_indexes ,
9789 )
@@ -100,7 +92,7 @@ def parse(
10092 def _make_request (
10193 self , doc_config : DocumentConfig , include_words : bool , close_file : bool
10294 ) -> PredictResponse :
103- response = doc_config .constructor .request (
95+ response = doc_config .document_class .request (
10496 doc_config .endpoints ,
10597 self .input_doc ,
10698 include_words = include_words ,
@@ -147,15 +139,68 @@ def __init__(self, api_key: str = "", raise_on_error: bool = True):
147139 self ._doc_configs : Dict [tuple , DocumentConfig ] = {}
148140 self .raise_on_error = raise_on_error
149141 self .api_key = api_key
150-
151- def config_custom_doc (
142+ self ._init_default_endpoints ()
143+
144+ def _init_default_endpoints (self ) -> None :
145+ self ._doc_configs = {
146+ (OTS_OWNER , "invoice" ): DocumentConfig (
147+ document_type = "invoice" ,
148+ constructor = Invoice ,
149+ endpoints = [
150+ StandardEndpoint (
151+ url_name = "invoices" , version = "3" , api_key = self .api_key
152+ )
153+ ],
154+ ),
155+ (OTS_OWNER , "receipt" ): DocumentConfig (
156+ document_type = "receipt" ,
157+ constructor = Receipt ,
158+ endpoints = [
159+ StandardEndpoint (
160+ url_name = "expense_receipts" , version = "3" , api_key = self .api_key
161+ )
162+ ],
163+ ),
164+ (OTS_OWNER , "financial_doc" ): DocumentConfig (
165+ document_type = "financial_doc" ,
166+ constructor = FinancialDocument ,
167+ endpoints = [
168+ StandardEndpoint (
169+ url_name = "invoices" , version = "3" , api_key = self .api_key
170+ ),
171+ StandardEndpoint (
172+ url_name = "expense_receipts" , version = "3" , api_key = self .api_key
173+ ),
174+ ],
175+ ),
176+ (OTS_OWNER , "passport" ): DocumentConfig (
177+ document_type = "passport" ,
178+ constructor = Passport ,
179+ endpoints = [
180+ StandardEndpoint (
181+ url_name = "passport" , version = "1" , api_key = self .api_key
182+ )
183+ ],
184+ ),
185+ (OTS_OWNER , "bank_check" ): DocumentConfig (
186+ document_type = "bank_check" ,
187+ constructor = BankCheck ,
188+ endpoints = [
189+ StandardEndpoint (
190+ url_name = "bank_check" , version = "1" , api_key = self .api_key
191+ )
192+ ],
193+ ),
194+ }
195+
196+ def add_endpoint (
152197 self ,
153198 account_name : str ,
154199 endpoint_name : str ,
155200 version : str = "1" ,
156201 ) -> "Client" :
157202 """
158- Configure a custom document using the Mindee API Builder.
203+ Add a custom endpoint, created using the Mindee API Builder.
159204
160205 :param endpoint_name: The "API name" field in the "Settings" page of the API Builder
161206 :param account_name: Your organization's username on the API Builder
@@ -176,61 +221,6 @@ def config_custom_doc(
176221 )
177222 return self
178223
179- def config_invoice (self ) -> "Client" :
180- """Configure a Mindee Invoice document."""
181- config = DocumentConfig (
182- document_type = "invoice" ,
183- constructor = Invoice ,
184- endpoints = [InvoiceEndpoint (api_key = self .api_key )],
185- )
186- self ._doc_configs [(OTS_OWNER , "invoice" )] = config
187- return self
188-
189- def config_receipt (self ) -> "Client" :
190- """Configure a Mindee Expense Receipts document."""
191- config = DocumentConfig (
192- document_type = "receipt" ,
193- constructor = Receipt ,
194- endpoints = [ReceiptEndpoint (api_key = self .api_key )],
195- )
196- self ._doc_configs [(OTS_OWNER , "receipt" )] = config
197- return self
198-
199- def config_financial_doc (
200- self ,
201- ) -> "Client" :
202- """Configure a Mindee Financial document. Uses Invoice and Expense Receipt internally."""
203- config = DocumentConfig (
204- document_type = "financial_doc" ,
205- constructor = FinancialDocument ,
206- endpoints = [
207- InvoiceEndpoint (api_key = self .api_key ),
208- ReceiptEndpoint (api_key = self .api_key ),
209- ],
210- )
211- self ._doc_configs [(OTS_OWNER , "financial_doc" )] = config
212- return self
213-
214- def config_passport (self ) -> "Client" :
215- """Configure a Mindee Passport document."""
216- config = DocumentConfig (
217- document_type = "passport" ,
218- constructor = Passport ,
219- endpoints = [PassportEndpoint (api_key = self .api_key )],
220- )
221- self ._doc_configs [(OTS_OWNER , "passport" )] = config
222- return self
223-
224- def config_bank_check (self ) -> "Client" :
225- """Configure a Mindee Bank check document."""
226- config = DocumentConfig (
227- document_type = "bank_check" ,
228- constructor = BankCheck ,
229- endpoints = [BankCheckEndpoint (api_key = self .api_key )],
230- )
231- self ._doc_configs [(OTS_OWNER , "bank_check" )] = config
232- return self
233-
234224 def doc_from_path (
235225 self ,
236226 input_path : str ,
0 commit comments