brynq-sdk-zermelo 2.1.0__tar.gz → 3.0.0__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.
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/PKG-INFO +1 -1
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo/zermelo.py +11 -9
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo.egg-info/PKG-INFO +1 -1
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo.egg-info/requires.txt +1 -1
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/setup.py +2 -2
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo/__init__.py +0 -0
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo.egg-info/SOURCES.txt +0 -0
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo.egg-info/dependency_links.txt +0 -0
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo.egg-info/not-zip-safe +0 -0
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo.egg-info/top_level.txt +0 -0
- {brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/setup.cfg +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from brynq_sdk_brynq import BrynQ
|
|
2
2
|
from pandas import json_normalize
|
|
3
3
|
from time import mktime
|
|
4
|
-
from typing import List, Union
|
|
4
|
+
from typing import List, Union, Literal, Optional
|
|
5
5
|
import requests
|
|
6
6
|
import pandas as pd
|
|
7
7
|
import numpy as np
|
|
@@ -12,7 +12,7 @@ import sys
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class Zermelo(BrynQ):
|
|
15
|
-
def __init__(self,
|
|
15
|
+
def __init__(self, storage_location, system_type: Optional[Literal['source', 'target']] = None, initial_zermelo_extract=False, extract_cancelled_appointments=True, debug=False):
|
|
16
16
|
"""
|
|
17
17
|
Extracts data from source based on the entered parameters
|
|
18
18
|
For documentation see: https://wartburg.zportal.nl/static/swagger/ & https://zermelo.atlassian.net/wiki/display/DEV/API+Entities
|
|
@@ -21,12 +21,14 @@ class Zermelo(BrynQ):
|
|
|
21
21
|
:param extract_cancelled_appointments: doesn't get the cancelled appointments by default. Can be changed to an empty string to get the cancelled appointments
|
|
22
22
|
"""
|
|
23
23
|
super().__init__()
|
|
24
|
-
credentials = self.
|
|
24
|
+
credentials = self.interfaces.credentials.get(system="zermelo", system_type=system_type)
|
|
25
|
+
credentials = credentials.get('data')
|
|
25
26
|
self.access_token = credentials['token']
|
|
26
27
|
self.url = f"https://{credentials['customer']}.zportal.nl/api/v3/"
|
|
27
28
|
self.storage_location = storage_location
|
|
28
29
|
self.initial_zermelo_extract = initial_zermelo_extract
|
|
29
30
|
self.debug = debug
|
|
31
|
+
self.timeout = 3600
|
|
30
32
|
if extract_cancelled_appointments:
|
|
31
33
|
self.cancelled_appointments = ''
|
|
32
34
|
else:
|
|
@@ -139,7 +141,7 @@ class Zermelo(BrynQ):
|
|
|
139
141
|
|
|
140
142
|
if nested:
|
|
141
143
|
# Get the response without any transformation
|
|
142
|
-
response = requests.get(url).json()['response']['data']
|
|
144
|
+
response = requests.get(url, timeout=self.timeout).json()['response']['data']
|
|
143
145
|
|
|
144
146
|
# From all the fields, hold only the meta_fields (the not nested fields)
|
|
145
147
|
meta_fields = fields.copy()
|
|
@@ -181,7 +183,7 @@ class Zermelo(BrynQ):
|
|
|
181
183
|
df = pd.merge(df, df_temp, how='left', on=meta_fields)
|
|
182
184
|
data = df
|
|
183
185
|
else:
|
|
184
|
-
init_response = json.loads(requests.get(url).content)
|
|
186
|
+
init_response = json.loads(requests.get(url, timeout=self.timeout).content)
|
|
185
187
|
status = init_response['response']['status']
|
|
186
188
|
if status == 200:
|
|
187
189
|
data = pd.DataFrame(init_response['response']['data'])
|
|
@@ -232,7 +234,7 @@ class Zermelo(BrynQ):
|
|
|
232
234
|
end_epoch = int(start_epoch + (3600 * 24 * 7))
|
|
233
235
|
|
|
234
236
|
url = '{0}{1}?access_token={2}&fields={3}&start={4}&end={5}'.format(self.url, endpoint, self.access_token, fields, start_epoch, end_epoch)
|
|
235
|
-
data = requests.get(url).json()['response']['data']
|
|
237
|
+
data = requests.get(url, timeout=self.timeout).json()['response']['data']
|
|
236
238
|
|
|
237
239
|
# checks if data is not empty list
|
|
238
240
|
if data:
|
|
@@ -274,7 +276,7 @@ class Zermelo(BrynQ):
|
|
|
274
276
|
end_epoch = int(start_epoch + (3600 * 24 * 7))
|
|
275
277
|
print(start_epoch, end_epoch)
|
|
276
278
|
url = '{0}{1}?access_token={2}&fields={3}&start={4}&end={5}&includeHidden=True{6}&valid=True'.format(self.url, endpoint, self.access_token, fields, start_epoch, end_epoch, self.cancelled_appointments)
|
|
277
|
-
data = requests.get(url).json()['response']['data']
|
|
279
|
+
data = requests.get(url, timeout=self.timeout).json()['response']['data']
|
|
278
280
|
|
|
279
281
|
# checks if data is not empty list
|
|
280
282
|
if data:
|
|
@@ -359,7 +361,7 @@ class Zermelo(BrynQ):
|
|
|
359
361
|
try:
|
|
360
362
|
# merge params with loop params
|
|
361
363
|
time_params = params | {'start': start_epoch, 'end': end_epoch}
|
|
362
|
-
resp = requests.get(url=url, params=time_params)
|
|
364
|
+
resp = requests.get(url=url, params=time_params, timeout=self.timeout)
|
|
363
365
|
resp.raise_for_status()
|
|
364
366
|
|
|
365
367
|
data = resp.json()['response']['data']
|
|
@@ -394,7 +396,7 @@ class Zermelo(BrynQ):
|
|
|
394
396
|
start_epoch += (3600 * 24 * 7) # Skip this block to avoid infinite retry
|
|
395
397
|
else:
|
|
396
398
|
try:
|
|
397
|
-
resp = requests.get(url=url, params=params)
|
|
399
|
+
resp = requests.get(url=url, params=params, timeout=self.timeout)
|
|
398
400
|
resp.raise_for_status()
|
|
399
401
|
data = resp.json()['response']['data']
|
|
400
402
|
df = pd.DataFrame(data)
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='brynq_sdk_zermelo',
|
|
5
|
-
version='
|
|
5
|
+
version='3.0.0',
|
|
6
6
|
description='Zermelo wrapper from BrynQ',
|
|
7
7
|
long_description='Zermelo wrapper from BrynQ',
|
|
8
8
|
author='BrynQ',
|
|
@@ -10,7 +10,7 @@ setup(
|
|
|
10
10
|
packages=find_namespace_packages(include=['brynq_sdk*']),
|
|
11
11
|
license='BrynQ License',
|
|
12
12
|
install_requires=[
|
|
13
|
-
'brynq-sdk-brynq>=
|
|
13
|
+
'brynq-sdk-brynq>=4,<5',
|
|
14
14
|
'pandas>=1,<3',
|
|
15
15
|
'requests>=2,<=3'
|
|
16
16
|
],
|
|
File without changes
|
|
File without changes
|
{brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{brynq_sdk_zermelo-2.1.0 → brynq_sdk_zermelo-3.0.0}/brynq_sdk_zermelo.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|