brynq-sdk-zoho 2.0.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_zoho
3
- Version: 2.0.3
3
+ Version: 3.0.0
4
4
  Summary: ZOHO wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  import sys
3
3
  import pandas as pd
4
- from typing import Union, List
4
+ from typing import Union, List, Optional, Literal
5
5
  import requests
6
6
  import json
7
7
  from brynq_sdk_brynq import BrynQ
@@ -12,28 +12,28 @@ sys.path.append(basedir)
12
12
 
13
13
  class ExtractZohoDesk(BrynQ):
14
14
 
15
- def __init__(self, label: Union[str, List], debug: bool = False):
15
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug: bool = False):
16
16
  """
17
17
  For the full documentation, see: https://avisi-apps.gitbook.io/tracket/api/
18
18
  """
19
19
  super().__init__()
20
- self.headers = self._get_authentication(label=label)
20
+ self.headers = self._get_authentication(system_type)
21
21
  self.base_url = "https://desk.zoho.com/api/v1/"
22
22
  self.payload = {}
23
+ self.timeout = 3600
23
24
 
24
- def _get_authentication(self, label):
25
+ def _get_authentication(self, system_type):
25
26
  """
26
27
  Get the credentials for the Tracket API from BrynQ, with those credentials, get the access_token for Tracket.
27
28
  Return the headers with the access_token.
28
29
  """
29
30
  # Get credentials from BrynQ
30
- credentials = self.get_system_credential(system='zoho-desk', label=label)
31
+ credentials = self.interfaces.credentials.get(system="zoho-desk", system_type=system_type)
32
+ credentials = credentials.get('data')
31
33
 
32
34
  # With those credentials, get the access_token from Tracket
33
- zoho_system_id = credentials["id"]
34
- token = BrynQ().refresh_system_credential(system="zoho-desk", system_id=zoho_system_id)["access_token"]
35
35
  headers = {
36
- 'Authorization': f'Zoho-oauthtoken {token}'
36
+ 'Authorization': f'Zoho-oauthtoken {credentials.get("access_token")}'
37
37
  }
38
38
  return headers
39
39
 
@@ -156,9 +156,9 @@ class ExtractZohoDesk(BrynQ):
156
156
  This function helps the API calls to do a single call in one function
157
157
  :return:
158
158
  """
159
- response = requests.request("GET", url, headers=self.headers, data=self.payload)
159
+ response = requests.request("GET", url, headers=self.headers, data=self.payload, timeout=self.timeout)
160
160
  if response.status_code == 401:
161
- response = requests.request("GET", url, headers=self.headers, data=self.payload)
161
+ response = requests.request("GET", url, headers=self.headers, data=self.payload, timeout=self.timeout)
162
162
  if response.status_code == 200:
163
163
  df = response.json()
164
164
  if 'data' in df:
@@ -1,38 +1,36 @@
1
1
  import os
2
2
  import sys
3
3
  import pandas as pd
4
- from typing import Union, List
4
+ from typing import Union, List, Optional, Literal
5
5
  import requests
6
6
  import json
7
7
  from brynq_sdk_brynq import BrynQ
8
-
9
8
  basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10
9
  sys.path.append(basedir)
11
10
 
12
11
 
13
12
  class UploadZohoDesk(BrynQ):
14
13
 
15
- def __init__(self, label: Union[str, List], debug: bool = False):
14
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug: bool = False):
16
15
  """
17
16
  For the full documentation, see: https://avisi-apps.gitbook.io/tracket/api/
18
17
  """
19
18
  super().__init__()
20
- self.headers = self._get_authentication(label=label)
19
+ self.headers = self._get_authentication(system_type)
21
20
  self.base_url = "https://desk.zoho.com/api/v1/"
21
+ self.timeout = 3600
22
22
 
23
- def _get_authentication(self, label):
23
+ def _get_authentication(self, system_type):
24
24
  """
25
25
  Get the credentials for the Traket API from BrynQ, with those credentials, get the access_token for Tracket.
26
26
  Return the headers with the access_token.
27
27
  """
28
28
  # Get credentials from BrynQ
29
- credentials = self.get_system_credential(system='zoho-desk', label=label)
29
+ credentials = self.interfaces.credentials.get(system="zoho-desk", system_type=system_type)
30
+ credentials = credentials.get('data')
30
31
 
31
- # With those credentials, get the access_token from Tracket
32
- zoho_system_id = credentials["id"]
33
- token = BrynQ().refresh_system_credential(system="zoho-desk", system_id=zoho_system_id)["access_token"]
34
32
  headers = {
35
- 'Authorization': f'Zoho-oauthtoken {token}',
33
+ 'Authorization': f'Zoho-oauthtoken {credentials.get("access_token")}',
36
34
  'Content-Type': 'application/json'
37
35
  }
38
36
  return headers
@@ -45,5 +43,5 @@ class UploadZohoDesk(BrynQ):
45
43
  :param payload: dict
46
44
  """
47
45
  url = f"{self.base_url}tickets/{ticket_id}/timeEntry/{time_entry_id}"
48
- response = requests.request("PATCH", url, headers=self.headers, data=json.dumps(payload))
46
+ response = requests.request("PATCH", url, headers=self.headers, data=json.dumps(payload), timeout=self.timeout)
49
47
  return response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-zoho
3
- Version: 2.0.3
3
+ Version: 3.0.0
4
4
  Summary: ZOHO wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_zoho',
5
- version='2.0.3',
5
+ version='3.0.0',
6
6
  description='ZOHO wrapper from BrynQ',
7
7
  long_description='ZOHO wrapper from BrynQ',
8
8
  author='BrynQ',
File without changes