brynq-sdk-vplan 1.0.1__tar.gz → 1.2.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.
Files changed (19) hide show
  1. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/PKG-INFO +1 -1
  2. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/__init__.py +2 -0
  3. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/item.py +1 -1
  4. brynq_sdk_vplan-1.2.1/brynq_sdk_vplan/leave.py +110 -0
  5. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/order.py +2 -2
  6. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/project.py +2 -2
  7. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/resource.py +2 -2
  8. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan.egg-info/PKG-INFO +1 -1
  9. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan.egg-info/SOURCES.txt +1 -0
  10. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/setup.py +1 -1
  11. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/activity.py +0 -0
  12. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/get_data.py +0 -0
  13. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/time_tracking.py +0 -0
  14. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan/user.py +0 -0
  15. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan.egg-info/dependency_links.txt +0 -0
  16. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan.egg-info/not-zip-safe +0 -0
  17. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan.egg-info/requires.txt +0 -0
  18. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/brynq_sdk_vplan.egg-info/top_level.txt +0 -0
  19. {brynq_sdk_vplan-1.0.1 → brynq_sdk_vplan-1.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_vplan
3
- Version: 1.0.1
3
+ Version: 1.2.1
4
4
  Summary: vPlan wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -8,6 +8,7 @@ from .project import Project
8
8
  from .resource import Resource
9
9
  from .time_tracking import TimeTracking
10
10
  from .user import User
11
+ from .leave import Leave
11
12
 
12
13
 
13
14
  class VPlan(BrynQ):
@@ -27,6 +28,7 @@ class VPlan(BrynQ):
27
28
  self.resource = Resource(self)
28
29
  self.time_tracking = TimeTracking(self)
29
30
  self.user = User(self)
31
+ self.leave = Leave(self)
30
32
 
31
33
  def _get_credentials(self, label) -> dict:
32
34
  """
@@ -114,7 +114,7 @@ class Item:
114
114
  base_body.update({"note": data['note']}) if 'note' in data else base_body
115
115
  base_body.update({"external_ref": data['external_ref']}) if 'external_ref' in data else base_body
116
116
 
117
- response = requests.request('PUT', url, headers=self.vplan.post_headers, json=base_body)
117
+ response = requests.request('PUT', url, headers=self.vplan.post_headers, data=json.dumps(base_body))
118
118
  return response
119
119
 
120
120
  def delete_item(self, item_id):
@@ -0,0 +1,110 @@
1
+ import requests
2
+ from typing import Union, List, Any
3
+ import warnings
4
+ import json
5
+ from .get_data import GetData
6
+
7
+
8
+ class Leave:
9
+ def __init__(self, vplan):
10
+ """
11
+ Initialize the GetData class.
12
+ Args: vplan: contains the vplan object with the headers and base_url
13
+ """
14
+ self.vplan = vplan
15
+ self.get_data = GetData(vplan)
16
+
17
+ def get_leave(self, resource_id: str) -> requests.Response:
18
+ """
19
+ There is no documentation for this method available
20
+
21
+ This method constructs a request URL based on the endpoint and sends a GET request
22
+ to the vPlan API.
23
+
24
+ Args: resource_id (str): The id of the resource to get the leave from
25
+
26
+ Returns: requests.Response: The response from the vPlan API.
27
+ """
28
+ url = f"{self.vplan.base_url}resource/{resource_id}/schedule_deviation"
29
+ response = requests.request('GET', url, headers=self.vplan.headers)
30
+ return response
31
+
32
+ def post_leave(self, resource_id: str, data: dict) -> requests.Response:
33
+ """
34
+ There is no documentation for this method available
35
+
36
+ This method constructs a request URL based on the endpoint and sends a POST request
37
+ to the vPlan API with the provided data.
38
+
39
+ Args: resource_id (str): The resource id of the employee to add the leave to
40
+ data (dict): The data to create the new order with.
41
+
42
+ Returns: requests.Response: The response from the vPlan API.
43
+ """
44
+ required_fields = ['type', 'time', 'description', 'start_date', 'end_date']
45
+ allowed_fields = []
46
+ self.__check_fields(data=data, required_fields=required_fields, allowed_fields=allowed_fields)
47
+
48
+ url = f"{self.vplan.base_url}resource/{resource_id}/schedule_deviation"
49
+ base_body = json.dumps({
50
+ "type": data['type'],
51
+ "time": data['time'],
52
+ "description": data['description'],
53
+ "start_date": data['start_date'],
54
+ "end_date": data['end_date']
55
+ })
56
+ response = requests.request('POST', url, headers=self.vplan.post_headers, data=base_body)
57
+ return response
58
+
59
+ def update_leave(self, resource_id: str, leave_id: str, data: dict) -> requests.Response:
60
+ """
61
+ There is no documentation for this method available
62
+
63
+ This method constructs a request URL based on the endpoint and sends a POST request
64
+ to the vPlan API with the provided data.
65
+
66
+ Args: resource_id (str): The resource id of the employee to add the leave to
67
+ leave_id (str): The id of the leave to update
68
+ data (dict): The data to create the new order with.
69
+
70
+ Returns: requests.Response: The response from the vPlan API.
71
+ """
72
+ required_fields = ['type', 'time', 'description', 'start_date', 'end_date']
73
+ allowed_fields = []
74
+ self.__check_fields(data=data, required_fields=required_fields, allowed_fields=allowed_fields)
75
+
76
+ url = f"{self.vplan.base_url}resource/{resource_id}/schedule_deviation/{leave_id}"
77
+ base_body = json.dumps({
78
+ "type": data['type'],
79
+ "time": data['time'],
80
+ "description": data['description'],
81
+ "start_date": data['start_date'],
82
+ "end_date": data['end_date']
83
+ })
84
+ response = requests.request('PUT', url, headers=self.vplan.post_headers, data=base_body)
85
+ return response
86
+
87
+ def delete_leave(self, resource_id: str, leave_id: str):
88
+ """
89
+ There is no documentation for this method available
90
+ This method constructs a request URL based on the endpoint and sends a DELETE request to the vPlan API.
91
+ :param resource_id: The resource id of the employee to delete the the leave to
92
+ :param leave_id: The id of the leave to delete
93
+ """
94
+ url = f"{self.vplan.base_url}resource/{resource_id}/schedule_deviation/{leave_id}"
95
+ response = requests.request('DELETE', url, headers=self.vplan.headers)
96
+ return response
97
+
98
+
99
+ @staticmethod
100
+ def __check_fields(data: Union[dict, List], required_fields: List, allowed_fields: List):
101
+ if isinstance(data, dict):
102
+ data = data.keys()
103
+
104
+ for field in data:
105
+ if field not in allowed_fields and field not in required_fields:
106
+ warnings.warn('Field {field} is not implemented. Optional fields are: {allowed_fields}'.format(field=field, allowed_fields=tuple(allowed_fields)))
107
+
108
+ for field in required_fields:
109
+ if field not in data:
110
+ raise ValueError('Field {field} is required. Required fields are: {required_fields}'.format(field=field, required_fields=tuple(required_fields)))
@@ -92,7 +92,7 @@ class Order:
92
92
  base_body.update({"external_ref": data['external_ref']}) if 'external_ref' in data else base_body
93
93
  base_body.update({"board_id": data['board_id']}) if 'board_id' in data else base_body
94
94
 
95
- response = requests.request('POST', url, headers=self.vplan.post_headers, data=base_body)
95
+ response = requests.request('POST', url, headers=self.vplan.post_headers, data=json.dumps(base_body))
96
96
  return response
97
97
 
98
98
  def update_order(self, order_id: str, data: dict) -> requests.Response:
@@ -139,7 +139,7 @@ class Order:
139
139
  base_body.update({"external_ref": data['external_ref']}) if 'external_ref' in data else base_body
140
140
  base_body.update({"board_id": data['board_id']}) if 'board_id' in data else base_body
141
141
 
142
- response = requests.request('PUT', url, headers=self.vplan.post_headers, json=base_body)
142
+ response = requests.request('PUT', url, headers=self.vplan.post_headers, data=json.dumps(base_body))
143
143
  return response
144
144
 
145
145
  def delete_order(self, order_id):
@@ -74,7 +74,7 @@ class Project:
74
74
  base_body.update({"description": data['description']}) if 'description' in data else base_body
75
75
  base_body.update({"external_ref": data['external_ref']}) if 'external_ref' in data else base_body
76
76
 
77
- response = requests.request('POST', url, headers=self.vplan.post_headers, data=base_body)
77
+ response = requests.request('POST', url, headers=self.vplan.post_headers, data=json.dumps(base_body))
78
78
  return response
79
79
 
80
80
  def update_project(self, project_id: str, data: dict) -> requests.Response:
@@ -103,7 +103,7 @@ class Project:
103
103
  base_body.update({"description": data['description']}) if 'description' in data else base_body
104
104
  base_body.update({"external_ref": data['external_ref']}) if 'external_ref' in data else base_body
105
105
 
106
- response = requests.request('PUT', url, headers=self.vplan.post_headers, json=base_body)
106
+ response = requests.request('PUT', url, headers=self.vplan.post_headers, data=json.dumps(base_body))
107
107
  return response
108
108
 
109
109
  def delete_project(self, project_id):
@@ -107,7 +107,7 @@ class Resource:
107
107
  base_body.update({"name": data['name']}) if 'name' in data else base_body
108
108
  base_body.update({"type": data['type']}) if 'type' in data else base_body
109
109
  base_body.update({"start_date": data['start_date']}) if 'start_date' in data else base_body
110
- base_body.update({"workdays": data['workdays']}) if 'workdays' in data else base_body
110
+ base_body.update({"workdays": eval(data['workdays'])}) if 'workdays' in data else base_body
111
111
  base_body.update({"description": data['description']}) if 'description' in data else base_body
112
112
  base_body.update({"end_date": data['end_date']}) if 'end_date' in data else base_body
113
113
  base_body.update({"integration_schedule": data['integration_schedule']}) if 'integration_schedule' in data else base_body
@@ -116,7 +116,7 @@ class Resource:
116
116
  base_body.update({"external_ref": data['external_ref']}) if 'external_ref' in data else base_body
117
117
  base_body.update({"archive": data['archive']}) if 'archive' in data else base_body
118
118
 
119
- response = requests.request('PUT', url, headers=self.vplan.post_headers, json=json.dumps(base_body))
119
+ response = requests.request('PUT', url, headers=self.vplan.post_headers, data=json.dumps(base_body))
120
120
  return response
121
121
 
122
122
  def delete_resource(self, resource_id):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-vplan
3
- Version: 1.0.1
3
+ Version: 1.2.1
4
4
  Summary: vPlan wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -3,6 +3,7 @@ brynq_sdk_vplan/__init__.py
3
3
  brynq_sdk_vplan/activity.py
4
4
  brynq_sdk_vplan/get_data.py
5
5
  brynq_sdk_vplan/item.py
6
+ brynq_sdk_vplan/leave.py
6
7
  brynq_sdk_vplan/order.py
7
8
  brynq_sdk_vplan/project.py
8
9
  brynq_sdk_vplan/resource.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_vplan',
5
- version='1.0.1',
5
+ version='1.2.1',
6
6
  description='vPlan wrapper from BrynQ',
7
7
  long_description='vPlan wrapper from BrynQ',
8
8
  author='BrynQ',