itk-dev-shared-components 2.0.0__tar.gz → 2.1.1__tar.gz
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.
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/PKG-INFO +1 -1
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/kmd_nova/nova_documents.py +23 -3
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/kmd_nova/nova_objects.py +1 -0
- itk_dev_shared_components-2.1.1/itk_dev_shared_components/smtp/__init__.py +0 -0
- itk_dev_shared_components-2.1.1/itk_dev_shared_components/smtp/smtp_util.py +55 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components.egg-info/PKG-INFO +1 -1
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components.egg-info/SOURCES.txt +3 -1
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/pyproject.toml +1 -1
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/LICENSE +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/README.md +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/__init__.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/graph/__init__.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/graph/authentication.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/graph/mail.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/kmd_nova/__init__.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/kmd_nova/authentication.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/kmd_nova/cpr.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/kmd_nova/nova_cases.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/kmd_nova/nova_tasks.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/kmd_nova/util.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/misc/__init__.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/misc/cpr_util.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/sap/__init__.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/sap/fmcacov.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/sap/gridview_util.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/sap/multi_session.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/sap/opret_kundekontakt.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/sap/sap_login.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/sap/sap_util.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components/sap/tree_util.py +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components.egg-info/dependency_links.txt +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components.egg-info/requires.txt +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/itk_dev_shared_components.egg-info/top_level.txt +0 -0
- {itk_dev_shared_components-2.0.0 → itk_dev_shared_components-2.1.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: itk_dev_shared_components
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: Shared components to use in RPA projects
|
|
5
5
|
Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
|
|
@@ -10,7 +10,7 @@ import urllib.parse
|
|
|
10
10
|
import requests
|
|
11
11
|
|
|
12
12
|
from itk_dev_shared_components.kmd_nova.authentication import NovaAccess
|
|
13
|
-
from itk_dev_shared_components.kmd_nova.nova_objects import Document
|
|
13
|
+
from itk_dev_shared_components.kmd_nova.nova_objects import Document, Caseworker
|
|
14
14
|
from itk_dev_shared_components.kmd_nova. util import datetime_from_iso_string
|
|
15
15
|
|
|
16
16
|
|
|
@@ -44,7 +44,8 @@ def get_documents(case_uuid: str, nova_access: NovaAccess) -> list[Document]:
|
|
|
44
44
|
"approved": True,
|
|
45
45
|
"documentDate": True,
|
|
46
46
|
"fileExtension": True,
|
|
47
|
-
"documentCategory": True
|
|
47
|
+
"documentCategory": True,
|
|
48
|
+
"caseworker": True
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -55,6 +56,16 @@ def get_documents(case_uuid: str, nova_access: NovaAccess) -> list[Document]:
|
|
|
55
56
|
|
|
56
57
|
documents = []
|
|
57
58
|
for document_dict in response.json()['documents']:
|
|
59
|
+
|
|
60
|
+
if 'caseworker' in document_dict:
|
|
61
|
+
caseworker = Caseworker(
|
|
62
|
+
uuid = document_dict['caseworker']['kspIdentity']['novaUserId'],
|
|
63
|
+
name = document_dict['caseworker']['kspIdentity']['fullName'],
|
|
64
|
+
ident = document_dict['caseworker']['kspIdentity']['racfId']
|
|
65
|
+
)
|
|
66
|
+
else:
|
|
67
|
+
caseworker = None
|
|
68
|
+
|
|
58
69
|
doc = Document(
|
|
59
70
|
uuid = document_dict['documentUuid'],
|
|
60
71
|
document_number = document_dict['documentNumber'],
|
|
@@ -66,7 +77,8 @@ def get_documents(case_uuid: str, nova_access: NovaAccess) -> list[Document]:
|
|
|
66
77
|
document_date = datetime_from_iso_string(document_dict['documentDate']),
|
|
67
78
|
file_extension = document_dict['fileExtension'],
|
|
68
79
|
category_name = document_dict.get('documentCategoryName'),
|
|
69
|
-
category_uuid = document_dict.get('documentCategoryUuid')
|
|
80
|
+
category_uuid = document_dict.get('documentCategoryUuid'),
|
|
81
|
+
caseworker=caseworker
|
|
70
82
|
)
|
|
71
83
|
documents.append(doc)
|
|
72
84
|
|
|
@@ -184,6 +196,14 @@ def attach_document_to_case(case_uuid: str, document: Document, nova_access: Nov
|
|
|
184
196
|
"accessToDocuments": True
|
|
185
197
|
}
|
|
186
198
|
|
|
199
|
+
if document.caseworker:
|
|
200
|
+
payload['caseworker'] = {
|
|
201
|
+
"kspIdentity": {
|
|
202
|
+
"racfId": document.caseworker.ident,
|
|
203
|
+
"fullName": document.caseworker.name
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
187
207
|
headers = {'Content-Type': 'application/json', 'Authorization': f"Bearer {nova_access.get_bearer_token()}"}
|
|
188
208
|
response = requests.post(url, params=params, headers=headers, json=payload, timeout=60)
|
|
189
209
|
response.raise_for_status()
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""This module contains a single function for sending emails using the SMTP protocol."""
|
|
2
|
+
|
|
3
|
+
from typing import Sequence
|
|
4
|
+
from email.message import EmailMessage
|
|
5
|
+
import smtplib
|
|
6
|
+
from io import BytesIO
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
import mimetypes
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class EmailAttachment:
|
|
13
|
+
"""A simple dataclass representing an email attachment."""
|
|
14
|
+
file: BytesIO
|
|
15
|
+
file_name: str
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def send_email(receiver: str | list[str], sender: str, subject: str, body: str, smtp_server: str, smtp_port: int,
|
|
19
|
+
html_body: bool = False, attachments: Sequence[EmailAttachment] | None = None) -> None:
|
|
20
|
+
"""Send an email using the SMTP protocol.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
receiver: The email or list of emails to send the message to.
|
|
24
|
+
sender: The sender email of the message.
|
|
25
|
+
subject: The message subject.
|
|
26
|
+
body: The message body.
|
|
27
|
+
smtp_server: The name of the smtp server.
|
|
28
|
+
smtp_port: The port of the smtp server.
|
|
29
|
+
html_body: Wether the body is html or just plain text. Defaults to False.
|
|
30
|
+
attachments: A list of Attachment objects. Defaults to None.
|
|
31
|
+
"""
|
|
32
|
+
msg = EmailMessage()
|
|
33
|
+
msg['to'] = receiver
|
|
34
|
+
msg['from'] = sender
|
|
35
|
+
msg['subject'] = subject
|
|
36
|
+
|
|
37
|
+
# Set body
|
|
38
|
+
if html_body:
|
|
39
|
+
msg.set_content("Please enable HTML to view this message.")
|
|
40
|
+
msg.add_alternative(body, subtype='html')
|
|
41
|
+
else:
|
|
42
|
+
msg.set_content(body)
|
|
43
|
+
|
|
44
|
+
# Attach files
|
|
45
|
+
if attachments:
|
|
46
|
+
for attachment in attachments:
|
|
47
|
+
mime = mimetypes.guess_type(attachment.file_name)[0]
|
|
48
|
+
main, sub = mime.split("/") if mime else ("application", "octet-stream")
|
|
49
|
+
attachment.file.seek(0)
|
|
50
|
+
msg.add_attachment(attachment.file.read(), maintype=main, subtype=sub, filename=attachment.file_name)
|
|
51
|
+
|
|
52
|
+
# Send message
|
|
53
|
+
with smtplib.SMTP(smtp_server, smtp_port) as smtp:
|
|
54
|
+
smtp.starttls()
|
|
55
|
+
smtp.send_message(msg)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: itk_dev_shared_components
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: Shared components to use in RPA projects
|
|
5
5
|
Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
|
|
@@ -27,4 +27,6 @@ itk_dev_shared_components/sap/multi_session.py
|
|
|
27
27
|
itk_dev_shared_components/sap/opret_kundekontakt.py
|
|
28
28
|
itk_dev_shared_components/sap/sap_login.py
|
|
29
29
|
itk_dev_shared_components/sap/sap_util.py
|
|
30
|
-
itk_dev_shared_components/sap/tree_util.py
|
|
30
|
+
itk_dev_shared_components/sap/tree_util.py
|
|
31
|
+
itk_dev_shared_components/smtp/__init__.py
|
|
32
|
+
itk_dev_shared_components/smtp/smtp_util.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|