documente_shared 0.1.145__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- documente_shared/__init__.py +0 -0
- documente_shared/application/__init__.py +0 -0
- documente_shared/application/dates.py +7 -0
- documente_shared/application/digest.py +7 -0
- documente_shared/application/exceptions.py +23 -0
- documente_shared/application/files.py +27 -0
- documente_shared/application/json.py +45 -0
- documente_shared/application/numbers.py +7 -0
- documente_shared/application/payloads.py +29 -0
- documente_shared/application/query_params.py +133 -0
- documente_shared/application/retry_utils.py +69 -0
- documente_shared/application/time_utils.py +13 -0
- documente_shared/application/timezone.py +7 -0
- documente_shared/domain/__init__.py +0 -0
- documente_shared/domain/base_enum.py +54 -0
- documente_shared/domain/constants.py +8 -0
- documente_shared/domain/entities/__init__.py +0 -0
- documente_shared/domain/entities/document.py +410 -0
- documente_shared/domain/entities/document_metadata.py +64 -0
- documente_shared/domain/entities/in_memory_document.py +75 -0
- documente_shared/domain/entities/processing_case.py +215 -0
- documente_shared/domain/entities/processing_case_filters.py +51 -0
- documente_shared/domain/entities/processing_case_item.py +300 -0
- documente_shared/domain/entities/processing_case_item_filters.py +54 -0
- documente_shared/domain/entities/processing_documents.py +11 -0
- documente_shared/domain/entities/processing_event.py +71 -0
- documente_shared/domain/entities/scaling.py +31 -0
- documente_shared/domain/enums/__init__.py +0 -0
- documente_shared/domain/enums/circular_oficio.py +29 -0
- documente_shared/domain/enums/common.py +133 -0
- documente_shared/domain/enums/document.py +124 -0
- documente_shared/domain/enums/document_type_record.py +13 -0
- documente_shared/domain/enums/processing_case.py +66 -0
- documente_shared/domain/exceptions.py +5 -0
- documente_shared/domain/interfaces/__init__.py +0 -0
- documente_shared/domain/interfaces/scaling.py +10 -0
- documente_shared/domain/repositories/__init__.py +0 -0
- documente_shared/domain/repositories/document.py +24 -0
- documente_shared/domain/repositories/processing_case.py +36 -0
- documente_shared/domain/repositories/processing_case_item.py +49 -0
- documente_shared/infrastructure/__init__.py +0 -0
- documente_shared/infrastructure/documente_client.py +27 -0
- documente_shared/infrastructure/dynamo_table.py +75 -0
- documente_shared/infrastructure/lambdas.py +14 -0
- documente_shared/infrastructure/repositories/__init__.py +0 -0
- documente_shared/infrastructure/repositories/dynamo_document.py +43 -0
- documente_shared/infrastructure/repositories/dynamo_processing_case.py +55 -0
- documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +70 -0
- documente_shared/infrastructure/repositories/http_document.py +66 -0
- documente_shared/infrastructure/repositories/http_processing_case.py +82 -0
- documente_shared/infrastructure/repositories/http_processing_case_item.py +118 -0
- documente_shared/infrastructure/repositories/mem_document.py +46 -0
- documente_shared/infrastructure/repositories/mem_processing_case.py +44 -0
- documente_shared/infrastructure/repositories/mem_processing_case_item.py +52 -0
- documente_shared/infrastructure/s3_bucket.py +58 -0
- documente_shared/infrastructure/services/__init__.py +0 -0
- documente_shared/infrastructure/services/http_scaling.py +25 -0
- documente_shared/infrastructure/sqs_queue.py +48 -0
- documente_shared/presentation/__init__.py +0 -0
- documente_shared/presentation/presenters.py +16 -0
- documente_shared-0.1.145.dist-info/METADATA +39 -0
- documente_shared-0.1.145.dist-info/RECORD +63 -0
- documente_shared-0.1.145.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from documente_shared.application.time_utils import get_datetime_from_data
|
|
6
|
+
from documente_shared.domain.entities.document import DocumentProcessing
|
|
7
|
+
from documente_shared.domain.entities.processing_case import ProcessingCase
|
|
8
|
+
from documente_shared.domain.enums.common import ProcessingType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class ProcessingEvent(object):
|
|
13
|
+
processing_type: ProcessingType
|
|
14
|
+
instance: DocumentProcessing | ProcessingCase | None
|
|
15
|
+
timestamp: Optional[datetime] = None
|
|
16
|
+
|
|
17
|
+
def __eq__(self, other: 'ProcessingEvent') -> bool:
|
|
18
|
+
if not other:
|
|
19
|
+
return False
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
self.processing_type == other.processing_type
|
|
23
|
+
and self.instance == other.instance
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def is_processing_case(self) -> bool:
|
|
28
|
+
return self.processing_type == ProcessingType.PROCESSING_CASE
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def is_document(self) -> bool:
|
|
32
|
+
return self.processing_type == ProcessingType.DOCUMENT
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def uuid(self) -> Optional[str]:
|
|
36
|
+
if self.is_document:
|
|
37
|
+
return self.instance.digest
|
|
38
|
+
elif self.is_processing_case:
|
|
39
|
+
return self.instance.uuid
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def to_dict(self) -> dict:
|
|
44
|
+
return {
|
|
45
|
+
'processing_type': str(self.processing_type),
|
|
46
|
+
'instance': self.instance.to_dict,
|
|
47
|
+
'timestamp': self.timestamp.isoformat() if self.timestamp else None,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def to_queue_dict(self) -> dict:
|
|
52
|
+
dict_data = self.to_dict
|
|
53
|
+
dict_data['instance'] = self.instance.to_queue_dict
|
|
54
|
+
return dict_data
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_dict(cls, data: dict) -> 'ProcessingEvent':
|
|
58
|
+
processing_type = ProcessingType.from_value(data.get('processing_type'))
|
|
59
|
+
|
|
60
|
+
if processing_type.is_document:
|
|
61
|
+
processing_instance = DocumentProcessing.from_dict(data.get('instance'))
|
|
62
|
+
elif processing_type.is_processing_case:
|
|
63
|
+
processing_instance = ProcessingCase.from_dict(data.get('instance'))
|
|
64
|
+
else:
|
|
65
|
+
processing_instance = None
|
|
66
|
+
|
|
67
|
+
return cls(
|
|
68
|
+
processing_type=processing_type,
|
|
69
|
+
instance=processing_instance,
|
|
70
|
+
timestamp=get_datetime_from_data(input_datetime=data.get('timestamp')),
|
|
71
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class ScalingRequirements(object):
|
|
7
|
+
lg_documents: Optional[int] = 0
|
|
8
|
+
md_documents: Optional[int] = 0
|
|
9
|
+
documents: Optional[int] = 0
|
|
10
|
+
processing_cases: Optional[int] = 0
|
|
11
|
+
processing_case_items: Optional[int] = 0
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def to_dict(self):
|
|
15
|
+
return {
|
|
16
|
+
"lg_documents": self.lg_documents,
|
|
17
|
+
"md_documents": self.md_documents,
|
|
18
|
+
"documents": self.documents,
|
|
19
|
+
"processing_cases": self.processing_cases,
|
|
20
|
+
"processing_case_items": self.processing_case_items,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def from_dict(cls, data: dict) -> "ScalingRequirements":
|
|
25
|
+
return cls(
|
|
26
|
+
lg_documents=data.get("lg_documents", 0),
|
|
27
|
+
md_documents=data.get("md_documents", 0),
|
|
28
|
+
documents=data.get("documents", 0),
|
|
29
|
+
processing_cases=data.get("processing_cases", 0),
|
|
30
|
+
processing_case_items=data.get("processing_case_items", 0),
|
|
31
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from documente_shared.domain.base_enum import BaseEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CircularOficioType(BaseEnum):
|
|
5
|
+
RETENCION = "RETENCION"
|
|
6
|
+
SUSPENSION = "SUSPENSION"
|
|
7
|
+
REMISION = "REMISION"
|
|
8
|
+
INFORMATIVA = "INFORMATIVA"
|
|
9
|
+
NORMATIVA = "NORMATIVA"
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def is_normativa(self) -> bool:
|
|
13
|
+
return self == CircularOficioType.NORMATIVA
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def is_retencion(self):
|
|
17
|
+
return self == CircularOficioType.RETENCION
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def is_remision(self):
|
|
21
|
+
return self == CircularOficioType.REMISION
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def is_informativa(self):
|
|
25
|
+
return self == CircularOficioType.INFORMATIVA
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def is_suspension(self) -> bool:
|
|
29
|
+
return self == CircularOficioType.SUSPENSION
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from documente_shared.domain.base_enum import BaseEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ProcessingSource(BaseEnum):
|
|
7
|
+
AGENT_UI = 'AGENT_UI'
|
|
8
|
+
AGENT_CRAWLER = 'AGENT_CRAWLER'
|
|
9
|
+
PLATFORM_UI = 'PLATFORM_UI'
|
|
10
|
+
PLATFORM_API = 'PLATFORM_API'
|
|
11
|
+
AWS_CONSOLE = 'AWS_CONSOLE'
|
|
12
|
+
LOCAL_MANUAL = 'LOCAL_MANUAL'
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def is_agent_ui(self):
|
|
16
|
+
return self == ProcessingSource.AGENT_UI
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def is_agent_crawler(self):
|
|
20
|
+
return self == ProcessingSource.AGENT_CRAWLER
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def is_platform_ui(self):
|
|
24
|
+
return self == ProcessingSource.PLATFORM_UI
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def is_platform_api(self):
|
|
28
|
+
return self == ProcessingSource.PLATFORM_API
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def is_aws_console(self):
|
|
32
|
+
return self == ProcessingSource.AWS_CONSOLE
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def is_local_manual(self):
|
|
36
|
+
return self == ProcessingSource.LOCAL_MANUAL
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ProcessingStatus(BaseEnum):
|
|
40
|
+
PENDING = 'PENDING'
|
|
41
|
+
ENQUEUED = 'ENQUEUED'
|
|
42
|
+
PROCESSING = 'PROCESSING'
|
|
43
|
+
COMPLETED = 'COMPLETED'
|
|
44
|
+
INCOMPLETE = 'INCOMPLETE'
|
|
45
|
+
FAILED = 'FAILED'
|
|
46
|
+
DELETED = 'DELETED'
|
|
47
|
+
CANCELLED = 'CANCELLED'
|
|
48
|
+
IN_REVIEW = 'IN_REVIEW'
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def procesable_statuses(self) -> List['ProcessingStatus']:
|
|
52
|
+
return [
|
|
53
|
+
ProcessingStatus.PENDING,
|
|
54
|
+
ProcessingStatus.ENQUEUED,
|
|
55
|
+
ProcessingStatus.PROCESSING,
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def final_statuses(self) -> List['ProcessingStatus']:
|
|
60
|
+
return [
|
|
61
|
+
ProcessingStatus.COMPLETED,
|
|
62
|
+
ProcessingStatus.FAILED,
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def is_pending(self):
|
|
67
|
+
return self == ProcessingStatus.PENDING
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def is_enqueued(self):
|
|
71
|
+
return self == ProcessingStatus.ENQUEUED
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def is_processing(self):
|
|
75
|
+
return self == ProcessingStatus.PROCESSING
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def is_completed(self):
|
|
79
|
+
return self == ProcessingStatus.COMPLETED
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def is_incomplete(self):
|
|
83
|
+
return self == ProcessingStatus.INCOMPLETE
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def is_failed(self):
|
|
87
|
+
return self == ProcessingStatus.FAILED
|
|
88
|
+
|
|
89
|
+
@property
|
|
90
|
+
def is_deleted(self):
|
|
91
|
+
return self == ProcessingStatus.DELETED
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def is_cancelled(self):
|
|
95
|
+
return self == ProcessingStatus.CANCELLED
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def is_in_review(self):
|
|
99
|
+
return self == ProcessingStatus.IN_REVIEW
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class ProcessingType(BaseEnum):
|
|
103
|
+
DOCUMENT = 'DOCUMENT'
|
|
104
|
+
PROCESSING_CASE = 'PROCESSING_CASE'
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def is_document(self):
|
|
108
|
+
return self == ProcessingType.DOCUMENT
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def is_processing_case(self):
|
|
112
|
+
return self == ProcessingType.PROCESSING_CASE
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class TaskResultStatus(BaseEnum):
|
|
116
|
+
PENDING = "PENDING"
|
|
117
|
+
SUCCESS = "SUCCESS"
|
|
118
|
+
IN_PROGRESS = "IN_PROGRESS"
|
|
119
|
+
FAILURE = "FAILURE"
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class DocumentViewFormat(BaseEnum):
|
|
123
|
+
PUBLIC_URL = 'PUBLIC_URL'
|
|
124
|
+
STORAGE_KEY = 'STORAGE_KEY'
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def is_public_url(self):
|
|
128
|
+
return self == DocumentViewFormat.PUBLIC_URL
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def is_object_storage(self):
|
|
132
|
+
return self == DocumentViewFormat.STORAGE_KEY
|
|
133
|
+
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from documente_shared.domain.base_enum import BaseEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DocumentProcessingStatus(BaseEnum):
|
|
7
|
+
PENDING = 'PENDING'
|
|
8
|
+
ENQUEUED = 'ENQUEUED'
|
|
9
|
+
PROCESSING = 'PROCESSING'
|
|
10
|
+
COMPLETED = 'COMPLETED'
|
|
11
|
+
INCOMPLETE = 'INCOMPLETE'
|
|
12
|
+
FAILED = 'FAILED'
|
|
13
|
+
DELETED = 'DELETED'
|
|
14
|
+
CANCELLED = 'CANCELLED'
|
|
15
|
+
IN_REVIEW = 'IN_REVIEW'
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def procesable_statuses(self) -> List['DocumentProcessingStatus']:
|
|
19
|
+
return [
|
|
20
|
+
DocumentProcessingStatus.PENDING,
|
|
21
|
+
DocumentProcessingStatus.ENQUEUED,
|
|
22
|
+
DocumentProcessingStatus.PROCESSING,
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def final_statuses(self) -> List['DocumentProcessingStatus']:
|
|
27
|
+
return [
|
|
28
|
+
DocumentProcessingStatus.COMPLETED,
|
|
29
|
+
DocumentProcessingStatus.FAILED,
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def is_pending(self):
|
|
34
|
+
return self == DocumentProcessingStatus.PENDING
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def is_enqueued(self):
|
|
38
|
+
return self == DocumentProcessingStatus.ENQUEUED
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def is_processing(self):
|
|
42
|
+
return self == DocumentProcessingStatus.PROCESSING
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def is_completed(self):
|
|
46
|
+
return self == DocumentProcessingStatus.COMPLETED
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def is_incomplete(self):
|
|
50
|
+
return self == DocumentProcessingStatus.INCOMPLETE
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def is_failed(self):
|
|
54
|
+
return self == DocumentProcessingStatus.FAILED
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def is_deleted(self):
|
|
58
|
+
return self == DocumentProcessingStatus.DELETED
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def is_cancelled(self):
|
|
62
|
+
return self == DocumentProcessingStatus.CANCELLED
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def is_in_review(self):
|
|
66
|
+
return self == DocumentProcessingStatus.IN_REVIEW
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class DocumentProcessingCategory(BaseEnum):
|
|
70
|
+
CIRCULAR = 'CIRCULAR'
|
|
71
|
+
DESGRAVAMEN = 'DESGRAVAMEN'
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def is_circular(self):
|
|
75
|
+
return self == DocumentProcessingCategory.CIRCULAR
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def is_desgravamen(self):
|
|
79
|
+
return self == DocumentProcessingCategory.DESGRAVAMEN
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class DocumentProcessingSource(BaseEnum):
|
|
83
|
+
AGENT_UI = 'AGENT_UI'
|
|
84
|
+
AGENT_CRAWLER = 'AGENT_CRAWLER'
|
|
85
|
+
PLATFORM_UI = 'PLATFORM_UI'
|
|
86
|
+
PLATFORM_API = 'PLATFORM_API'
|
|
87
|
+
AWS_CONSOLE = 'AWS_CONSOLE'
|
|
88
|
+
LOCAL_MANUAL = 'LOCAL_MANUAL'
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def is_agent_ui(self):
|
|
92
|
+
return self == DocumentProcessingSource.AGENT_UI
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def is_agent_crawler(self):
|
|
96
|
+
return self == DocumentProcessingSource.AGENT_CRAWLER
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def is_platform_ui(self):
|
|
100
|
+
return self == DocumentProcessingSource.PLATFORM_UI
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def is_platform_api(self):
|
|
104
|
+
return self == DocumentProcessingSource.PLATFORM_API
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def is_aws_console(self):
|
|
108
|
+
return self == DocumentProcessingSource.AWS_CONSOLE
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def is_local_manual(self):
|
|
112
|
+
return self == DocumentProcessingSource.LOCAL_MANUAL
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class DocumentProcessingSubCategory(BaseEnum):
|
|
116
|
+
# Circulares
|
|
117
|
+
CC_COMBINADA = 'CC_COMBINADA'
|
|
118
|
+
CC_NORMATIVA = 'CC_NORMATIVA'
|
|
119
|
+
CC_INFORMATIVA = 'CC_INFORMATIVA'
|
|
120
|
+
CC_RETENCION_SUSPENSION_REMISION = 'CC_RETENCION_SUSPENSION_REMISION'
|
|
121
|
+
|
|
122
|
+
# Desgravamenes
|
|
123
|
+
DS_CREDISEGURO = 'DS_CREDISEGURO'
|
|
124
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from src.common.domain.base_enum import BaseEnum
|
|
2
|
+
|
|
3
|
+
class DocumentTypeRecord(BaseEnum):
|
|
4
|
+
DOCUMENT_PROCESSING = 'DOCUMENT_PROCESSING'
|
|
5
|
+
PROCESSING_CASE_ITEM = 'PROCESSING_CASE_ITEM'
|
|
6
|
+
|
|
7
|
+
@property
|
|
8
|
+
def is_document_processing(self):
|
|
9
|
+
return self == DocumentTypeRecord.DOCUMENT_PROCESSING
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def is_processing_case_item(self):
|
|
13
|
+
return self == DocumentTypeRecord.PROCESSING_CASE_ITEM
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from documente_shared.domain.base_enum import BaseEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ProcessingCaseType(BaseEnum):
|
|
5
|
+
BCP_MICROCREDITO = 'BCP_MICROCREDITO'
|
|
6
|
+
UNIVIDA_SOAT = 'UNIVIDA_SOAT'
|
|
7
|
+
AGNOSTIC = 'AGNOSTIC'
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def is_bcp_microcredito(self):
|
|
11
|
+
return self == ProcessingCaseType.BCP_MICROCREDITO
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def is_univida_soat(self):
|
|
15
|
+
return self == ProcessingCaseType.UNIVIDA_SOAT
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def is_agnostic(self):
|
|
19
|
+
return self == ProcessingCaseType.AGNOSTIC
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ProcessingDocumentType(BaseEnum):
|
|
25
|
+
REVIEW_CHECKLIST = 'REVISION_CHECKLIST'
|
|
26
|
+
SOLICITUD_DE_CREDITO = 'SOLICITUD_DE_CREDITO'
|
|
27
|
+
RESOLUCION_DE_CREDITO = 'RESOLUCION_DE_CREDITO'
|
|
28
|
+
CEDULA_DE_IDENTIDAD = 'CEDULA_DE_IDENTIDAD'
|
|
29
|
+
NIT = 'NIT'
|
|
30
|
+
FICHA_VERIFICACION = 'FICHA_VERIFICACION'
|
|
31
|
+
FACTURA_ELECTRICIDAD = 'FACTURA_ELECTRICIDAD'
|
|
32
|
+
CARTA_CLIENTE = 'CARTA_CLIENTE'
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def is_review_checklist(self):
|
|
36
|
+
return self == ProcessingDocumentType.REVIEW_CHECKLIST
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def is_solicitud_de_credito(self):
|
|
40
|
+
return self == ProcessingDocumentType.SOLICITUD_DE_CREDITO
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def is_resolucion_de_credito(self):
|
|
44
|
+
return self == ProcessingDocumentType.RESOLUCION_DE_CREDITO
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def is_cedula_de_identidad(self):
|
|
48
|
+
return self == ProcessingDocumentType.CEDULA_DE_IDENTIDAD
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def is_nit(self):
|
|
52
|
+
return self == ProcessingDocumentType.NIT
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def is_ficha_verificacion(self):
|
|
56
|
+
return self == ProcessingDocumentType.FICHA_VERIFICACION
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def is_factura_electricidad(self):
|
|
60
|
+
return self == ProcessingDocumentType.FACTURA_ELECTRICIDAD
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def is_carta_cliente(self):
|
|
64
|
+
return self == ProcessingDocumentType.CARTA_CLIENTE
|
|
65
|
+
|
|
66
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Optional, List
|
|
3
|
+
|
|
4
|
+
from documente_shared.domain.entities.document import DocumentProcessing
|
|
5
|
+
from documente_shared.domain.enums.document import DocumentProcessingStatus
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DocumentProcessingRepository(ABC):
|
|
9
|
+
|
|
10
|
+
@abstractmethod
|
|
11
|
+
def find(self, digest: str, read_bytes: bool = False) -> Optional[DocumentProcessing]:
|
|
12
|
+
raise NotImplementedError
|
|
13
|
+
|
|
14
|
+
@abstractmethod
|
|
15
|
+
def persist(self, instance: DocumentProcessing, read_bytes: bool = False) -> DocumentProcessing:
|
|
16
|
+
raise NotImplementedError
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def remove(self, instance: DocumentProcessing):
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def filter(self, statuses: List[DocumentProcessingStatus]) -> List[DocumentProcessing]:
|
|
24
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Optional, List
|
|
3
|
+
|
|
4
|
+
from documente_shared.domain.entities.processing_case import ProcessingCase
|
|
5
|
+
from documente_shared.domain.entities.processing_case_filters import ProcessingCaseFilters
|
|
6
|
+
from documente_shared.domain.enums.common import DocumentViewFormat
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ProcessingCaseRepository(ABC):
|
|
10
|
+
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def find(
|
|
13
|
+
self,
|
|
14
|
+
uuid: str,
|
|
15
|
+
include_items: bool = False,
|
|
16
|
+
include_items_bytes: bool = False,
|
|
17
|
+
view_format: DocumentViewFormat = DocumentViewFormat.PUBLIC_URL,
|
|
18
|
+
) -> Optional[ProcessingCase]:
|
|
19
|
+
raise NotImplementedError
|
|
20
|
+
|
|
21
|
+
@abstractmethod
|
|
22
|
+
def persist(
|
|
23
|
+
self,
|
|
24
|
+
instance: ProcessingCase,
|
|
25
|
+
persist_items: bool = False,
|
|
26
|
+
view_format: DocumentViewFormat = DocumentViewFormat.PUBLIC_URL,
|
|
27
|
+
) -> ProcessingCase:
|
|
28
|
+
raise NotImplementedError
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def remove(self, instance: ProcessingCase):
|
|
32
|
+
raise NotImplementedError
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def filter(self, filters: ProcessingCaseFilters) -> List[ProcessingCase]:
|
|
36
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Optional, List
|
|
3
|
+
|
|
4
|
+
from documente_shared.domain.entities.processing_case_item import ProcessingCaseItem
|
|
5
|
+
from documente_shared.domain.entities.processing_case_item_filters import ProcessingCaseItemFilters
|
|
6
|
+
from documente_shared.domain.enums.common import DocumentViewFormat
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ProcessingCaseItemRepository(ABC):
|
|
10
|
+
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def find(
|
|
13
|
+
self,
|
|
14
|
+
uuid: str,
|
|
15
|
+
read_bytes: bool = False,
|
|
16
|
+
view_format: DocumentViewFormat = DocumentViewFormat.PUBLIC_URL,
|
|
17
|
+
) -> Optional[ProcessingCaseItem]:
|
|
18
|
+
raise NotImplementedError
|
|
19
|
+
|
|
20
|
+
@abstractmethod
|
|
21
|
+
def find_by_digest(
|
|
22
|
+
self,
|
|
23
|
+
digest: str,
|
|
24
|
+
read_bytes: bool = False,
|
|
25
|
+
view_format: DocumentViewFormat = DocumentViewFormat.PUBLIC_URL,
|
|
26
|
+
) -> Optional[ProcessingCaseItem]:
|
|
27
|
+
raise NotImplementedError
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def persist(
|
|
31
|
+
self,
|
|
32
|
+
instance: ProcessingCaseItem,
|
|
33
|
+
read_bytes: bool = False,
|
|
34
|
+
persist_bytes: bool = False,
|
|
35
|
+
view_format: DocumentViewFormat = DocumentViewFormat.PUBLIC_URL,
|
|
36
|
+
) -> ProcessingCaseItem:
|
|
37
|
+
raise NotImplementedError
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def remove(self, instance: ProcessingCaseItem):
|
|
41
|
+
raise NotImplementedError
|
|
42
|
+
|
|
43
|
+
@abstractmethod
|
|
44
|
+
def filter(
|
|
45
|
+
self,
|
|
46
|
+
filters: ProcessingCaseItemFilters,
|
|
47
|
+
view_format: DocumentViewFormat = DocumentViewFormat.PUBLIC_URL,
|
|
48
|
+
) -> List[ProcessingCaseItem]:
|
|
49
|
+
raise NotImplementedError
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from requests import Session
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class DocumenteClientMixin(object):
|
|
8
|
+
api_url: str
|
|
9
|
+
api_key: str
|
|
10
|
+
tenant: Optional[str] = None
|
|
11
|
+
session: Optional[Session] = None
|
|
12
|
+
|
|
13
|
+
def __post_init__(self):
|
|
14
|
+
if self.session is None:
|
|
15
|
+
self.session = Session()
|
|
16
|
+
self.session.headers.update(self.get_common_headers())
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_common_headers(self) -> dict:
|
|
20
|
+
common_headers = {
|
|
21
|
+
"X-Api-Key": self.api_key,
|
|
22
|
+
"Content-Type": "application/json"
|
|
23
|
+
}
|
|
24
|
+
if self.tenant:
|
|
25
|
+
common_headers.update({"X-Tenant": self.tenant})
|
|
26
|
+
return common_headers
|
|
27
|
+
|