Skip to content

Commit 5c4dcfd

Browse files
committed
✨ add support for shipping container v1
1 parent 47ab4e4 commit 5c4dcfd

File tree

15 files changed

+180
-62
lines changed

15 files changed

+180
-62
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from mindee import Client, documents
2+
3+
# Init a new client
4+
mindee_client = Client(api_key="my-api-key")
5+
6+
# Load a file from disk
7+
input_doc = mindee_client.doc_from_path("/path/to/the/file.ext")
8+
9+
# Parse the Shipping Container by passing the appropriate type
10+
result = input_doc.parse(documents.TypeShippingContainerV1)
11+
12+
# Print a brief summary of the parsed data
13+
print(result.document)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
autodoc_member_order = "groupwise"
6363
autodoc_class_signature = "separated"
6464
autodoc_typehints = "description"
65-
autodoc_default_options = {"undoc-members": True, "exclude-members": "__init__"}
65+
autodoc_default_options = {"exclude-members": "__init__"}
6666

6767
# -- autodoc-typehints -------------------------------------------------------
6868

docs/predictions/standard/documents/fr/carte_vitale_v1.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ Carte Vitale V1
88

99
.. autoclass:: mindee.documents.fr.CarteVitaleV1
1010
:members:
11-
:undoc-members:

docs/predictions/standard/documents/fr/id_card_v1.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ Carte Nationale d'Identité V1
88

99
.. autoclass:: mindee.documents.fr.IdCardV1
1010
:members:
11-
:undoc-members:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Shipping Container V1
2+
---------------------
3+
4+
**Sample Code:**
5+
6+
.. literalinclude:: /code_samples/shipping_container_v1.py
7+
:language: Python
8+
9+
.. autoclass:: mindee.documents.ShippingContainerV1
10+
:members:

docs/predictions/standard/fr/carte_vitale_v1.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/predictions/standard/fr/id_card_v1.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/predictions/standard/international.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ International
33

44
.. include:: ./documents/financial_document_v1.rst
55
.. include:: ./documents/passport_v1.rst
6+
.. include:: ./documents/shipping_container_v1.rst
67
.. include:: ./documents/invoice_v3.rst
78
.. include:: ./documents/invoice_v4.rst
89
.. include:: ./documents/receipt_v3.rst

mindee/cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,24 @@ class CommandConfig(Generic[TypeDoc]):
4242
help="Proof of Address",
4343
doc_class=documents.TypeProofOfAddressV1,
4444
),
45+
"shipping-container": CommandConfig(
46+
help="Shipping Container",
47+
doc_class=documents.fr.TypeIdCardV1,
48+
),
4549
"us-check": CommandConfig(
4650
help="US Bank Check",
4751
doc_class=documents.us.TypeBankCheckV1,
4852
),
4953
"fr-carte-grise": CommandConfig(
50-
help="French Carte Grise",
54+
help="FR Carte Grise",
5155
doc_class=documents.fr.TypeCarteGriseV1,
5256
),
5357
"fr-carte-vitale": CommandConfig(
54-
help="French Carte Vitale",
58+
help="FR Carte Vitale",
5559
doc_class=documents.fr.TypeCarteVitaleV1,
5660
),
5761
"fr-id-card": CommandConfig(
58-
help="French ID Card",
62+
help="FR ID Card",
5963
doc_class=documents.fr.TypeIdCardV1,
6064
),
6165
}

mindee/client.py

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
import json
22
from typing import BinaryIO, Dict, List, NamedTuple, Optional, Type
33

4-
from mindee.documents import (
5-
CropperV1,
6-
CustomV1,
7-
FinancialDocumentV1,
8-
FinancialV1,
9-
InvoiceV3,
10-
InvoiceV4,
11-
PassportV1,
12-
ProofOfAddressV1,
13-
ReceiptV3,
14-
ReceiptV4,
15-
fr,
16-
us,
17-
)
4+
from mindee import documents
185
from mindee.documents.base import Document, TypeDocument
196
from mindee.documents.config import DocumentConfig, DocumentConfigDict
207
from mindee.endpoints import OTS_OWNER, CustomEndpoint, HTTPException, StandardEndpoint
@@ -87,7 +74,7 @@ def parse(
8774
This performs a cropping operation on the server and will increase response time.
8875
"""
8976
bound_classname = get_bound_classname(document_class)
90-
if bound_classname != CustomV1.__name__:
77+
if bound_classname != documents.CustomV1.__name__:
9178
endpoint_name = get_bound_classname(document_class)
9279
elif endpoint_name is None:
9380
raise RuntimeError(
@@ -169,7 +156,7 @@ def close(self) -> None:
169156

170157

171158
class ConfigSpec(NamedTuple):
172-
klass: Type[Document]
159+
doc_class: Type[Document]
173160
url_name: str
174161
version: str
175162

@@ -212,73 +199,78 @@ def _standard_doc_config(
212199
def _init_default_endpoints(self) -> None:
213200
configs: List[ConfigSpec] = [
214201
ConfigSpec(
215-
klass=InvoiceV3,
202+
doc_class=documents.InvoiceV3,
216203
url_name="invoices",
217204
version="3",
218205
),
219206
ConfigSpec(
220-
klass=InvoiceV4,
207+
doc_class=documents.InvoiceV4,
221208
url_name="invoices",
222209
version="4",
223210
),
224211
ConfigSpec(
225-
klass=ReceiptV3,
212+
doc_class=documents.ReceiptV3,
226213
url_name="expense_receipts",
227214
version="3",
228215
),
229216
ConfigSpec(
230-
klass=ReceiptV4,
217+
doc_class=documents.ReceiptV4,
231218
url_name="expense_receipts",
232219
version="4",
233220
),
234221
ConfigSpec(
235-
klass=FinancialDocumentV1,
222+
doc_class=documents.FinancialDocumentV1,
236223
url_name="financial_document",
237224
version="1",
238225
),
239226
ConfigSpec(
240-
klass=PassportV1,
227+
doc_class=documents.PassportV1,
241228
url_name="passport",
242229
version="1",
243230
),
244231
ConfigSpec(
245-
klass=ProofOfAddressV1,
232+
doc_class=documents.ProofOfAddressV1,
246233
url_name="proof_of_address",
247234
version="1",
248235
),
249236
ConfigSpec(
250-
klass=CropperV1,
237+
doc_class=documents.CropperV1,
251238
url_name="cropper",
252239
version="1",
253240
),
254241
ConfigSpec(
255-
klass=us.BankCheckV1,
242+
doc_class=documents.us.BankCheckV1,
256243
url_name="bank_check",
257244
version="1",
258245
),
259246
ConfigSpec(
260-
klass=fr.CarteGriseV1,
247+
doc_class=documents.fr.CarteGriseV1,
261248
url_name="carte_grise",
262249
version="1",
263250
),
264251
ConfigSpec(
265-
klass=fr.IdCardV1,
252+
doc_class=documents.fr.IdCardV1,
266253
url_name="idcard_fr",
267254
version="1",
268255
),
269256
ConfigSpec(
270-
klass=fr.CarteVitaleV1,
257+
doc_class=documents.fr.CarteVitaleV1,
271258
url_name="carte_vitale",
272259
version="1",
273260
),
261+
ConfigSpec(
262+
doc_class=documents.ShippingContainerV1,
263+
url_name="shipping_containers",
264+
version="1",
265+
),
274266
]
275267
for config in configs:
276-
config_key = (OTS_OWNER, config.klass.__name__)
268+
config_key = (OTS_OWNER, config.doc_class.__name__)
277269
self._doc_configs[config_key] = self._standard_doc_config(
278-
config.klass, config.url_name, config.version
270+
config.doc_class, config.url_name, config.version
279271
)
280-
self._doc_configs[OTS_OWNER, FinancialV1.__name__] = DocumentConfig(
281-
document_class=FinancialV1,
272+
self._doc_configs[OTS_OWNER, documents.FinancialV1.__name__] = DocumentConfig(
273+
document_class=documents.FinancialV1,
282274
endpoints=[
283275
StandardEndpoint(
284276
url_name="invoices", version="3", api_key=self.api_key
@@ -294,7 +286,7 @@ def add_endpoint(
294286
account_name: str,
295287
endpoint_name: str,
296288
version: str = "1",
297-
document_class: Type[Document] = CustomV1,
289+
document_class: Type[Document] = documents.CustomV1,
298290
) -> "Client":
299291
"""
300292
Add a custom endpoint, created using the Mindee API Builder.

0 commit comments

Comments
 (0)