xurrent 0.0.2__tar.gz → 0.0.2.2__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: 2.1
2
2
  Name: xurrent
3
- Version: 0.0.2
3
+ Version: 0.0.2.2
4
4
  Summary: A python module to interact with the Xurrent API.
5
5
  Author-email: Fabian Steiner <fabian@stei-ner.net>
6
6
  Project-URL: Homepage, https://github.com/pypa/sampleproject
@@ -16,6 +16,9 @@ License-File: LICENSE
16
16
 
17
17
  This module is used to interact with the Xurrent API. It provides a set of classes to interact with the API.
18
18
 
19
+ ## Change Log
20
+
21
+ [ChangeLog.md](https://github.com/fasteiner/xurrent-python/blob/main/ChangeLog.md)
19
22
 
20
23
  ## Usage
21
24
 
@@ -33,6 +36,10 @@ This module is used to interact with the Xurrent API. It provides a set of class
33
36
 
34
37
  x_api_helper = XurrentApiHelper(baseUrl, apitoken, account)
35
38
 
39
+ # Plain API Call
40
+ uri = "/requests?subject=Example Subject"
41
+ connection_object.api_call(uri, 'GET')
42
+
36
43
  ```
37
44
 
38
45
  ### Requests
@@ -82,6 +89,23 @@ This module is used to interact with the Xurrent API. It provides a set of class
82
89
 
83
90
  ```
84
91
 
92
+ ### Workflows
93
+
94
+ ```python
95
+
96
+ from xurrent.workflows import Workflow
97
+
98
+ workflow = Workflow.get_by_id(x_api_helper, <id>)
99
+
100
+ #close
101
+ workflow.close() # completion reason: completed, note: closed
102
+ # close with completion reason
103
+ workflow.close(completion_reason="withdrawn")
104
+ #close with completion reason and note
105
+ workflow.close(completion_reason="withdrawn", note="This is a test note")
106
+
107
+ ```
108
+
85
109
  ### Tasks
86
110
 
87
111
  ```python
@@ -2,6 +2,9 @@
2
2
 
3
3
  This module is used to interact with the Xurrent API. It provides a set of classes to interact with the API.
4
4
 
5
+ ## Change Log
6
+
7
+ [ChangeLog.md](https://github.com/fasteiner/xurrent-python/blob/main/ChangeLog.md)
5
8
 
6
9
  ## Usage
7
10
 
@@ -19,6 +22,10 @@ This module is used to interact with the Xurrent API. It provides a set of class
19
22
 
20
23
  x_api_helper = XurrentApiHelper(baseUrl, apitoken, account)
21
24
 
25
+ # Plain API Call
26
+ uri = "/requests?subject=Example Subject"
27
+ connection_object.api_call(uri, 'GET')
28
+
22
29
  ```
23
30
 
24
31
  ### Requests
@@ -68,6 +75,23 @@ This module is used to interact with the Xurrent API. It provides a set of class
68
75
 
69
76
  ```
70
77
 
78
+ ### Workflows
79
+
80
+ ```python
81
+
82
+ from xurrent.workflows import Workflow
83
+
84
+ workflow = Workflow.get_by_id(x_api_helper, <id>)
85
+
86
+ #close
87
+ workflow.close() # completion reason: completed, note: closed
88
+ # close with completion reason
89
+ workflow.close(completion_reason="withdrawn")
90
+ #close with completion reason and note
91
+ workflow.close(completion_reason="withdrawn", note="This is a test note")
92
+
93
+ ```
94
+
71
95
  ### Tasks
72
96
 
73
97
  ```python
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xurrent"
3
- version = "0.0.2"
3
+ version = "0.0.2.2"
4
4
  authors = [
5
5
  { name="Fabian Steiner", email="fabian@stei-ner.net" },
6
6
  ]
@@ -1,3 +1,4 @@
1
+ from __future__ import annotations # Needed for forward references
1
2
  import logging
2
3
  import requests
3
4
  import json
@@ -26,12 +27,17 @@ class JsonSerializableDict(dict):
26
27
 
27
28
 
28
29
  class XurrentApiHelper:
30
+ api_user: Person # Forward declaration with a string
29
31
 
30
- def __init__(self, base_url, api_key, api_account):
32
+ def __init__(self, base_url, api_key, api_account, resolve_user=True):
31
33
  self.base_url = base_url
32
34
  self.api_key = api_key
33
35
  self.api_account = api_account
34
36
  self.logger = logging.getLogger(__name__)
37
+ if resolve_user:
38
+ # Import Person lazily
39
+ from .people import Person
40
+ self.api_user = Person.get_me(self)
35
41
 
36
42
  def __append_per_page(self, uri, per_page=100):
37
43
  """
@@ -39,7 +45,7 @@ class XurrentApiHelper:
39
45
  :param uri: URI to append the parameter to
40
46
  :param per_page: Number of records per page
41
47
  :return: URI with the 'per_page' parameter appended
42
- >>> helper = XurrentApiHelper('https://api.example.com', 'api_key', 'account')
48
+ >>> helper = XurrentApiHelper('https://api.example.com', 'api_key', 'account', False)
43
49
  >>> helper._XurrentApiHelper__append_per_page('https://api.example.com/tasks')
44
50
  'https://api.example.com/tasks?per_page=100'
45
51
  >>> helper._XurrentApiHelper__append_per_page('https://api.example.com/tasks?status=open')
@@ -138,7 +144,7 @@ class XurrentApiHelper:
138
144
  :param custom_fields: List of custom fields
139
145
  :return: Dictionary containing the custom fields
140
146
 
141
- >>> helper = XurrentApiHelper('https://api.example.com', 'api_key', 'account')
147
+ >>> helper = XurrentApiHelper('https://api.example.com', 'api_key', 'account', False)
142
148
  >>> helper.custom_fields_to_object([{'id': 'priority', 'value': 'high'}, {'id': 'status', 'value': 'open'}])
143
149
  {'priority': 'high', 'status': 'open'}
144
150
  """
@@ -153,7 +159,7 @@ class XurrentApiHelper:
153
159
  :param obj: Dictionary to convert
154
160
  :return: List of custom fields
155
161
 
156
- >>> helper = XurrentApiHelper('https://api.example.com', 'api_key', 'account')
162
+ >>> helper = XurrentApiHelper('https://api.example.com', 'api_key', 'account', False)
157
163
  >>> helper.object_to_custom_fields({'priority': 'high', 'status': 'open'})
158
164
  [{'id': 'priority', 'value': 'high'}, {'id': 'status', 'value': 'open'}]
159
165
  """
@@ -167,7 +173,7 @@ class XurrentApiHelper:
167
173
  Create a filter string from a dictionary.
168
174
  :param filter: Dictionary containing the filter parameters
169
175
  :return: String containing the filter parameters
170
- >>> helper = XurrentApiHelper('https://api.example.com', 'api_key', 'account')
176
+ >>> helper = XurrentApiHelper('https://api.example.com', 'api_key', 'account', False)
171
177
  >>> helper.create_filter_string({'status': 'open', 'priority': 'high'})
172
178
  'status=open&priority=high'
173
179
  >>> helper.create_filter_string({'status': 'open'})
@@ -0,0 +1,71 @@
1
+ from .core import XurrentApiHelper
2
+ from typing import Optional, List, Dict, Type, TypeVar
3
+
4
+
5
+ T = TypeVar('T', bound='Person')
6
+
7
+ class Person():
8
+ #https://developer.4me.com/v1/people/
9
+ resourceUrl = 'people'
10
+
11
+ def __init__(self, connection_object: XurrentApiHelper, id, name: str = None, primary_email: str = None,**kwargs):
12
+ self._connection_object = connection_object
13
+ self.id = id
14
+ self.name = name
15
+ self.primary_email = primary_email
16
+ for key, value in kwargs.items():
17
+ setattr(self, key, value)
18
+
19
+ def __update_object__(self, data) -> None:
20
+ if data.get('id') != self.id:
21
+ raise ValueError(f"ID mismatch: {self.id} != {data.get('id')}")
22
+ for key, value in data.items():
23
+ setattr(self, key, value)
24
+
25
+ def __str__(self) -> str:
26
+ """
27
+ Return a string representation of the object.
28
+ """
29
+ return f"Person(id={self.id}, name={self.name}, primary_email={self.primary_email})"
30
+
31
+ @classmethod
32
+ def from_data(cls, connection_object: XurrentApiHelper, data) -> T:
33
+ if not isinstance(data, dict):
34
+ raise TypeError(f"Expected 'data' to be a dictionary, got {type(data).__name__}")
35
+ if 'id' not in data:
36
+ raise ValueError("Data dictionary must contain an 'id' field.")
37
+ return cls(connection_object, **data)
38
+
39
+ @classmethod
40
+ def get_by_id(cls, connection_object: XurrentApiHelper, id):
41
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}/{id}'
42
+ return cls.from_data(connection_object, connection_object.api_call(uri, 'GET'))
43
+
44
+ @classmethod
45
+ def get_me(cls, connection_object: XurrentApiHelper):
46
+ """
47
+ Retrieve the person object for the authenticated user.
48
+ """
49
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}/me'
50
+ return cls.from_data(connection_object, connection_object.api_call(uri, 'GET'))
51
+
52
+ def update(self, data):
53
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}'
54
+ response = self._connection_object.api_call(uri, 'PATCH', data)
55
+ self.__update_object__(response)
56
+ return self
57
+
58
+ def disable(self, prefix: str = '', postfix: str = ''):
59
+ """
60
+ Disable the person and update the name.
61
+
62
+ :param prefix: Prefix to add to the name
63
+ :param postfix: Postfix to add to the name
64
+ :return: Updated person object
65
+ """
66
+ return self.update({
67
+ 'disabled': 'true',
68
+ "name": f"{prefix}{self.name}{postfix}"
69
+ })
70
+
71
+
@@ -92,8 +92,8 @@ class Request(JsonSerializableDict):
92
92
  def from_data(cls, connection_object: XurrentApiHelper, data) -> T:
93
93
  if not isinstance(data, dict):
94
94
  raise TypeError(f"Expected 'data' to be a dictionary, got {type(data).__name__}")
95
- if not 'id' in data:
96
- data['id'] = id
95
+ if 'id' not in data:
96
+ raise ValueError("Data dictionary must contain an 'id' field.")
97
97
  return cls(connection_object, **data)
98
98
 
99
99
 
@@ -111,7 +111,7 @@ class Request(JsonSerializableDict):
111
111
  return cls.from_data(connection_object, response)
112
112
 
113
113
  @classmethod
114
- def get_request(cls, connection_object: XurrentApiHelper, predefinedFiler: PredefinedFilter = None,queryfilter: dict = None) -> List[T]:
114
+ def get_requests(cls, connection_object: XurrentApiHelper, predefinedFiler: PredefinedFilter = None,queryfilter: dict = None) -> List[T]:
115
115
  """
116
116
  Retrieve a request by its ID.
117
117
  :param connection_object: Instance of XurrentApiHelper
@@ -178,6 +178,18 @@ class Request(JsonSerializableDict):
178
178
  self.__update_object__(response)
179
179
  return self
180
180
 
181
+ @staticmethod
182
+ def update_by_id(connection_object: XurrentApiHelper, id: int, data: dict) -> T:
183
+ """
184
+ Update a request by its ID.
185
+ :param connection_object: Instance of XurrentApiHelper
186
+ :param id: ID of the request to update
187
+ :param data: Dictionary containing updated data
188
+ :return: Response from the API call
189
+ """
190
+ request = Request(connection_object, id)
191
+ return request.update(data)
192
+
181
193
  def close(self, note: str, completion_reason: CompletionReason = CompletionReason.solved):
182
194
  """
183
195
  Close the current request instance.
@@ -0,0 +1,83 @@
1
+ from .core import XurrentApiHelper
2
+ from .workflows import Workflow
3
+ from enum import Enum
4
+ from typing import Optional, List, Dict, Type, TypeVar
5
+
6
+
7
+ T = TypeVar('T', bound='Task')
8
+
9
+ class TaskPredefinedFilter(str, Enum):
10
+ finished = "finished" # List all finished tasks
11
+ open = "open" # List all open tasks
12
+ managed_by_me = "managed_by_me" # List all tasks that are part of a workflow which manager is the API user
13
+ assigned_to_my_team = "assigned_to_my_team" # List all tasks that are assigned to one of the teams that the API user is a member of
14
+ assigned_to_me = "assigned_to_me" # List all tasks that are assigned to the API user
15
+ approval_by_me = "approval_by_me" # List all approval tasks that are assigned to the API user and which status is different from ‘Registered’
16
+
17
+
18
+
19
+
20
+
21
+ class Task():
22
+ #https://developer.4me.com/v1/tasks/
23
+ resourceUrl = 'tasks'
24
+
25
+ def __init__(self, connection_object: XurrentApiHelper, id, subject: str = None, workflow: dict = None,description: str = None, **kwargs):
26
+ self._connection_object = connection_object
27
+ self.id = id
28
+ self.subject = subject
29
+ self.workflow = workflow
30
+ for key, value in kwargs.items():
31
+ setattr(self, key, value)
32
+
33
+ def __update_object__(self, data) -> None:
34
+ if data.get('id') != self.id:
35
+ raise ValueError(f"ID mismatch: {self.id} != {data.get('id')}")
36
+ for key, value in data.items():
37
+ setattr(self, key, value)
38
+
39
+ def __str__(self) -> str:
40
+ """
41
+ Return a string representation of the object.
42
+ """
43
+ return f"Task(id={self.id}, subject={self.subject}, workflow={self.workflow})"
44
+
45
+ @classmethod
46
+ def from_data(cls, connection_object: XurrentApiHelper, data) -> T:
47
+ if not isinstance(data, dict):
48
+ raise TypeError(f"Expected 'data' to be a dictionary, got {type(data).__name__}")
49
+ if 'id' not in data:
50
+ raise ValueError("Data dictionary must contain an 'id' field.")
51
+ return cls(connection_object, **data)
52
+
53
+ @classmethod
54
+ def get_by_id(cls, connection_object: XurrentApiHelper, id) -> T:
55
+ uri = f'{connection_object.base_url}/{Task.resourceUrl}/{id}'
56
+ return cls.from_data(connection_object, connection_object.api_call(uri, 'GET'))
57
+
58
+ @classmethod
59
+ def get_tasks(cls, connection_object: XurrentApiHelper, predefinedFilter: TaskPredefinedFilter = None, queryfilter: dict = None) -> List[T]:
60
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}'
61
+ if predefinedFilter:
62
+ uri = f'{uri}/{predefinedFilter}'
63
+ if queryfilter:
64
+ uri = f'{uri}?{queryfilter}'
65
+ return connection_object.api_call(uri, 'GET')
66
+
67
+ @staticmethod
68
+ def get_workflow_of_task(connection_object: XurrentApiHelper, id, expand: bool = False) -> Workflow:
69
+ task = Task.get_by_id(connection_object, id)
70
+ if expand:
71
+ return Workflow.get_by_id(connection_object, task.workflow.id)
72
+ return Workflow.from_data(connection_object, task.workflow)
73
+
74
+ @staticmethod
75
+ def update_by_id(connection_object: XurrentApiHelper, id, data) -> T:
76
+ task = Task(connection_object=connection_object, id=id)
77
+ return task.update(data)
78
+
79
+ def update(self, data) -> T:
80
+ uri = f'{connection_object.base_url}/{Task.resourceUrl}/{id}'
81
+ response = self._connection_object.api_call(uri, 'PATCH', data)
82
+ self.__update_object__(response)
83
+ return self
@@ -0,0 +1,206 @@
1
+ from __future__ import annotations # Needed for forward references
2
+ from datetime import datetime
3
+ from typing import Optional, List, Dict
4
+ from .core import XurrentApiHelper
5
+ from enum import Enum
6
+
7
+ class WorkflowCompletionReason(str, Enum):
8
+ withdrawn = "withdrawn" # Withdrawn - Withdrawn by Requester
9
+ rejected = "rejected" # Rejected - Rejected by Approver
10
+ rolled_back = "rolled_back" # Rolled Back - Original Environment Restored
11
+ failed = "failed" # Failed - No Requirements Met
12
+ partial = "partial" # Partial - Not All Requirements Met
13
+ disruptive = "disruptive" # Disruptive - Caused Service Disruption
14
+ complete = "complete" # Complete - All Requirements Met
15
+
16
+ class WorkflowStatus(str, Enum):
17
+ being_created = "being_created" # Being Created
18
+ registered = "registered" # Registered
19
+ in_progress = "in_progress" # In Progress
20
+ progress_halted = "progress_halted" # Progress Halted
21
+ completed = "completed" # Completed
22
+ # risk_and_impact = "risk_and_impact" # Risk & Impact — deprecated: replaced by in_progress
23
+ # approval = "approval" # Approval — deprecated: replaced by in_progress
24
+ # implementation = "implementation" # Implementation — deprecated: replaced by in_progress
25
+
26
+ # Function to check if a value is a valid enum member
27
+ @classmethod
28
+ def is_valid_workflow_status(cls, value):
29
+ try:
30
+ cls[value]
31
+ return True
32
+ except KeyError:
33
+ return False
34
+
35
+
36
+ class WorkflowPredefinedFilter(str, Enum):
37
+ """
38
+ Predefined filters for tasks.
39
+ """
40
+ open = 'open' # /workflows/completed: List all completed workflows
41
+ completed = 'completed' #/workflows/open: List all open workflows
42
+ managed_by_me = 'managed_by_me' #/workflows/managed_by_me: List all workflows which manager is the API user
43
+
44
+
45
+ class Workflow:
46
+ # Endpoint for workflows
47
+ resourceUrl = 'workflows'
48
+
49
+ def __init__(self,
50
+ connection_object: XurrentApiHelper,
51
+ id: int,
52
+ subject: Optional[str] = None,
53
+ status: Optional[str] = None,
54
+ manager: Optional[Dict] = None,
55
+ **kwargs):
56
+ self.id = id
57
+ self._connection_object = connection_object
58
+ self.subject = subject
59
+ self.status = status
60
+ self.manager = manager
61
+ for key, value in kwargs.items():
62
+ setattr(self, key, value)
63
+
64
+ def __str__(self) -> str:
65
+ """Provide a human-readable string representation of the object."""
66
+ return (f"Workflow(id={self.id}, subject={self.subject}, status={self.status}, manager={self.manager}")
67
+
68
+ @classmethod
69
+ def from_data(cls, connection_object: XurrentApiHelper, data: dict):
70
+ if not isinstance(data, dict):
71
+ raise TypeError(f"Expected 'data' to be a dictionary, got {type(data).__name__}")
72
+ if 'id' not in data:
73
+ raise ValueError("Data dictionary must contain an 'id' field.")
74
+ return cls(connection_object, **data)
75
+
76
+ @classmethod
77
+ def get_by_id(cls, connection_object: XurrentApiHelper, id: int) -> dict:
78
+ """
79
+ Retrieve a workflow by its ID.
80
+ """
81
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}/{id}'
82
+ return cls.from_data(connection_object, connection_object.api_call(uri, 'GET'))
83
+
84
+ @classmethod
85
+ def get_workflow_tasks_by_workflow_id(cls, connection_object: XurrentApiHelper, id: int, queryfilter: dict = None) -> List[Task]:
86
+ """
87
+ Retrieve all tasks associated with a workflow by its ID.
88
+ """
89
+ workflow = Workflow(connection_object, id)
90
+ return workflow.get_tasks(queryfilter=queryfilter)
91
+
92
+ def get_tasks(self, queryfilter: dict = None) -> List[Task]:
93
+ """
94
+ Retrieve all tasks associated with the current workflow instance.
95
+ """
96
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/tasks'
97
+ if queryfilter:
98
+ uri += '?' + self._connection_object.create_filter_string(queryfilter)
99
+ response = self._connection_object.api_call(uri, 'GET')
100
+ from .tasks import Task
101
+ return [Task.from_data(self._connection_object, task) for task in response]
102
+
103
+ @classmethod
104
+ def get_workflow_task_by_template_id(cls, connection_object: XurrentApiHelper, workflowID: int, templateID: int) -> List[Task]:
105
+ """
106
+ Retrieve a specific task associated with a workflow by template ID.
107
+ """
108
+ workflow = Workflow(connection_object, workflowID)
109
+ return workflow.get_task_by_template_id(templateID)
110
+
111
+ def get_task_by_template_id(self, templateID: int) -> List[Task]:
112
+ """
113
+ Retrieve a specific task associated with the current workflow by template ID.
114
+ """
115
+ return self.get_tasks(queryfilter={
116
+ 'template': templateID
117
+ })
118
+
119
+
120
+ def update(self, data: dict):
121
+ """
122
+ Update the current workflow instance with new data.
123
+ """
124
+ if not self.id:
125
+ raise ValueError("Workflow instance must have an ID to update.")
126
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}'
127
+ if not WorkflowStatus.is_valid_workflow_status(data.get('status')):
128
+ raise ValueError(f"Invalid status: {data.get('status')}")
129
+ response = self._connection_object.api_call(uri, 'PATCH', data)
130
+ self.__update_object__(response)
131
+ return self
132
+
133
+ @staticmethod
134
+ def update_by_id(connection_object: XurrentApiHelper, id: int, data: dict) -> dict:
135
+ """
136
+ Update a workflow by its ID.
137
+ """
138
+ workflow = Workflow(connection_object, id)
139
+ return workflow.update(data)
140
+
141
+ @classmethod
142
+ def create(cls, connection_object: XurrentApiHelper, data: dict):
143
+ """
144
+ Create a new workflow.
145
+ """
146
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}'
147
+ response = connection_object.api_call(uri, 'POST', data)
148
+ return cls.from_data(connection_object, response)
149
+
150
+ def close(self, note="closed.", completion_reason=WorkflowCompletionReason.complete):
151
+ """
152
+ Close the current workflow instance.
153
+ """
154
+ if not self.id:
155
+ raise ValueError("Workflow instance must have an ID to close.")
156
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}'
157
+ response = self._connection_object.api_call(uri, 'PATCH', {
158
+ 'note': note,
159
+ 'manager_id': self._connection_object.api_user.id,
160
+ 'status': WorkflowStatus.completed,
161
+ 'completion_reason': completion_reason
162
+ })
163
+ self.__update_object__(response)
164
+ return self
165
+
166
+ def archive(self):
167
+ """
168
+ Archive the current workflow instance.
169
+ """
170
+ if not self.id:
171
+ raise ValueError("Workflow instance must have an ID to archive.")
172
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/archive'
173
+ response = self._connection_object.api_call(uri, 'POST')
174
+ self.__update_object__(response)
175
+ return self
176
+
177
+ def trash(self):
178
+ """
179
+ Trash the current workflow instance.
180
+ """
181
+ if not self.id:
182
+ raise ValueError("Workflow instance must have an ID to trash.")
183
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/trash'
184
+ response = self._connection_object.api_call(uri, 'POST')
185
+ self.__update_object__(response)
186
+ return self
187
+
188
+ def restore(self):
189
+ """
190
+ Restore the current workflow instance.
191
+ """
192
+ if not self.id:
193
+ raise ValueError("Workflow instance must have an ID to restore.")
194
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/restore'
195
+ response = self._connection_object.api_call(uri, 'POST')
196
+ self.__update_object__(response)
197
+ return self
198
+
199
+ def __update_object__(self, data):
200
+ """
201
+ Update the instance properties with new data.
202
+ """
203
+ if data.get('id') != self.id:
204
+ raise ValueError(f"ID mismatch: {self.id} != {data.get('id')}")
205
+ for key, value in data.items():
206
+ setattr(self, key, value)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xurrent
3
- Version: 0.0.2
3
+ Version: 0.0.2.2
4
4
  Summary: A python module to interact with the Xurrent API.
5
5
  Author-email: Fabian Steiner <fabian@stei-ner.net>
6
6
  Project-URL: Homepage, https://github.com/pypa/sampleproject
@@ -16,6 +16,9 @@ License-File: LICENSE
16
16
 
17
17
  This module is used to interact with the Xurrent API. It provides a set of classes to interact with the API.
18
18
 
19
+ ## Change Log
20
+
21
+ [ChangeLog.md](https://github.com/fasteiner/xurrent-python/blob/main/ChangeLog.md)
19
22
 
20
23
  ## Usage
21
24
 
@@ -33,6 +36,10 @@ This module is used to interact with the Xurrent API. It provides a set of class
33
36
 
34
37
  x_api_helper = XurrentApiHelper(baseUrl, apitoken, account)
35
38
 
39
+ # Plain API Call
40
+ uri = "/requests?subject=Example Subject"
41
+ connection_object.api_call(uri, 'GET')
42
+
36
43
  ```
37
44
 
38
45
  ### Requests
@@ -82,6 +89,23 @@ This module is used to interact with the Xurrent API. It provides a set of class
82
89
 
83
90
  ```
84
91
 
92
+ ### Workflows
93
+
94
+ ```python
95
+
96
+ from xurrent.workflows import Workflow
97
+
98
+ workflow = Workflow.get_by_id(x_api_helper, <id>)
99
+
100
+ #close
101
+ workflow.close() # completion reason: completed, note: closed
102
+ # close with completion reason
103
+ workflow.close(completion_reason="withdrawn")
104
+ #close with completion reason and note
105
+ workflow.close(completion_reason="withdrawn", note="This is a test note")
106
+
107
+ ```
108
+
85
109
  ### Tasks
86
110
 
87
111
  ```python
@@ -3,6 +3,7 @@ README.md
3
3
  pyproject.toml
4
4
  src/xurrent/__init__.py
5
5
  src/xurrent/core.py
6
+ src/xurrent/people.py
6
7
  src/xurrent/requests.py
7
8
  src/xurrent/tasks.py
8
9
  src/xurrent/workflows.py
@@ -1,28 +0,0 @@
1
- from .core import XurrentApiHelper
2
- from .workflows import Workflow
3
-
4
-
5
- class Task():
6
- #https://developer.4me.com/v1/tasks/
7
- resourceUrl = 'tasks'
8
-
9
- @staticmethod
10
- def get_by_id(connection_object: XurrentApiHelper, id):
11
- uri = f'{connection_object.base_url}/{Task.resourceUrl}/{id}'
12
- return connection_object.api_call(uri, 'GET')
13
-
14
- def get_workflow_of_task(connection_object: XurrentApiHelper, id, expand: bool = False):
15
- task = Task.get_by_id(connection_object, id)
16
- if expand:
17
- return Workflow.get_by_id(connection_object, task['workflow'].id)
18
- return task['workflow']
19
-
20
- @staticmethod
21
- def update(connection_object: XurrentApiHelper, id, data):
22
- uri = f'{connection_object.base_url}/{Task.resourceUrl}/{id}'
23
- return connection_object.api_call(uri, 'PATCH', data)
24
-
25
- @staticmethod
26
- def delete(connection_object: XurrentApiHelper, id):
27
- uri = f'{connection_object.base_url}/{Task.resourceUrl}/{id}'
28
- return connection_object.api_call(uri, 'DELETE')
@@ -1,36 +0,0 @@
1
- from .core import XurrentApiHelper
2
-
3
-
4
- class Workflow():
5
- #https://developer.4me.com/v1/workflows/
6
- resourceUrl = 'workflows'
7
-
8
- @staticmethod
9
- def get_by_id(connection_object: XurrentApiHelper, id):
10
- uri = f'{connection_object.base_url}/{Workflow.resourceUrl}/{id}'
11
- return connection_object.api_call(uri, 'GET')
12
-
13
- @staticmethod
14
- def get_workflow_task_by_template_id(connection_object: XurrentApiHelper, workflowID: int, templateID: int):
15
- uri = f'{connection_object.base_url}/{Workflow.resourceUrl}/{workflowID}/tasks?template={templateID}'
16
- tasks = connection_object.api_call(uri, 'GET')
17
- if len(tasks) == 0:
18
- return None
19
- if len(tasks) > 1:
20
- raise Exception(f"Multiple tasks found for templateID: {templateID}")
21
- return tasks[0]
22
-
23
- @staticmethod
24
- def get_workflow_tasks_by_workflow_id(connection_object: XurrentApiHelper, id: int):
25
- uri = f'{connection_object.base_url}/{Workflow.resourceUrl}/{id}/tasks'
26
- return connection_object.api_call(uri, 'GET')
27
-
28
- @staticmethod
29
- def update(connection_object: XurrentApiHelper, id, data):
30
- uri = f'{connection_object.base_url}/{Workflow.resourceUrl}/{id}'
31
- return connection_object.api_call(uri, 'PATCH', data)
32
-
33
- @staticmethod
34
- def delete(connection_object: XurrentApiHelper, id):
35
- uri = f'{connection_object.base_url}/{Workflow.resourceUrl}/{id}'
36
- return connection_object.api_call(uri, 'DELETE')
File without changes
File without changes