brynq-sdk-mandrill 2.0.1__tar.gz → 3.0.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_mandrill
3
- Version: 2.0.1
3
+ Version: 3.0.1
4
4
  Summary: Mandrill wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -3,29 +3,36 @@ import os
3
3
  import mandrill
4
4
  import codecs
5
5
  import base64
6
- from typing import Union, List, Optional, BinaryIO
6
+ from typing import Union, List, Optional, BinaryIO, Literal
7
7
 
8
8
 
9
9
  class MailClient(BrynQ):
10
- def __init__(self, label: Union[str, List] = None, debug=False):
10
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug=False):
11
11
  # This is built in so you can use this class as a query generator for the BrynQ Agent
12
12
  super().__init__()
13
13
  self.debug = debug
14
- if label is not None:
15
- credentials = self.get_system_credential(system='mandrill', label=label)
14
+ try:
15
+ credentials = self.interfaces.credentials.get(system="mandrill", system_type=system_type)
16
+ credentials = credentials.get('data')
16
17
  self.api_token = credentials['token']
17
18
  self.email_from = 'support@brynq.com' if credentials['email_from'] is None else credentials['email_from']
18
19
  self.name_from = 'BrynQ' if credentials['name_from'] is None else credentials['name_from']
19
20
  if self.debug:
20
21
  print('Retrieved credentials from BrynQ')
21
- elif os.getenv("MANDRILL_TOKEN") is not None:
22
- self.api_token = os.getenv("MANDRILL_TOKEN")
23
- self.email_from = 'connect@salure.nl' if os.getenv("MANDRILL_EMAIL_FROM") is None else os.getenv("MANDRILL_EMAIL_FROM")
24
- self.name_from = 'BrynQ' if os.getenv("MANDRILL_NAME_FROM") is None else os.getenv("MANDRILL_NAME_FROM")
25
- if self.debug:
26
- print('Retrieved credentials from environment variables')
27
- else:
28
- raise ValueError('No credentials found for Mandrill. Either pass a BrynQ credential label or set the environment variables MANDRILL_TOKEN, MANDRILL_EMAIL_FROM and MANDRILL_NAME_FROM')
22
+ except ValueError as e:
23
+ print("No authorization found connected to interface, falling back to environment variables")
24
+ self.api_token = None
25
+
26
+
27
+ if self.api_token is None:
28
+ if os.getenv("MANDRILL_TOKEN") is not None:
29
+ self.api_token = os.getenv("MANDRILL_TOKEN")
30
+ self.email_from = 'connect@salure.nl' if os.getenv("MANDRILL_EMAIL_FROM") is None else os.getenv("MANDRILL_EMAIL_FROM")
31
+ self.name_from = 'BrynQ' if os.getenv("MANDRILL_NAME_FROM") is None else os.getenv("MANDRILL_NAME_FROM")
32
+ if self.debug:
33
+ print('Retrieved credentials from environment variables')
34
+ else:
35
+ raise ValueError('No credentials found for Mandrill. Either authorize Mandrill to your interface in BrynQ or set the environment variables MANDRILL_TOKEN, MANDRILL_EMAIL_FROM and MANDRILL_NAME_FROM')
29
36
 
30
37
  def send_mail(self, email_to: list, subject: str, language='NL', content: Optional[str] = None, attachment: Optional[BinaryIO | List[BinaryIO]] = None, cc: Optional[List | str] = None) -> List[dict]:
31
38
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-mandrill
3
- Version: 2.0.1
3
+ Version: 3.0.1
4
4
  Summary: Mandrill wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -1,2 +1,2 @@
1
- brynq-sdk-brynq>=2
1
+ brynq-sdk-brynq<5,>=4
2
2
  mandrill-really-maintained<=2,>=1
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_mandrill',
5
- version='2.0.1',
5
+ version='3.0.1',
6
6
  description='Mandrill wrapper from BrynQ',
7
7
  long_description='Mandrill wrapper from BrynQ',
8
8
  author='BrynQ',
@@ -11,7 +11,7 @@ setup(
11
11
  package_data={'brynq_sdk_mandrill': ['templates/*']},
12
12
  license='BrynQ License',
13
13
  install_requires=[
14
- 'brynq-sdk-brynq>=2',
14
+ 'brynq-sdk-brynq>=4,<5',
15
15
  'mandrill-really-maintained>=1,<=2'
16
16
  ],
17
17
  zip_safe=False,