xurrent 0.0.2.2__tar.gz → 0.0.2.4__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,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xurrent
3
- Version: 0.0.2.2
3
+ Version: 0.0.2.4
4
4
  Summary: A python module to interact with the Xurrent API.
5
5
  Author-email: Fabian Steiner <fabian@stei-ner.net>
6
- Project-URL: Homepage, https://github.com/pypa/sampleproject
7
- Project-URL: Issues, https://github.com/pypa/sampleproject/issues
6
+ Project-URL: Homepage, https://github.com/fasteiner/xurrent-python
7
+ Project-URL: Issues, https://github.com/fasteiner/xurrent-python/issues
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
@@ -43,6 +43,7 @@ This module is used to interact with the Xurrent API. It provides a set of class
43
43
  ```
44
44
 
45
45
  ### Requests
46
+
46
47
  ```python
47
48
  from xurrent.requests import Request
48
49
 
@@ -118,4 +119,19 @@ This module is used to interact with the Xurrent API. It provides a set of class
118
119
  "subject": "Example Subject"
119
120
  })
120
121
 
122
+ # get workflow of task (use expand: True to get the full workflow object)
123
+ workflow = task.get_workflow(expand=True)
124
+ # or statically
125
+ workflow = Task.get_workflow_by_template_id(x_api_helper, <id>, expand=True)
126
+
127
+ # close
128
+ task.close()
129
+ #cancel
130
+ task.cancel() # only possible before the task is started
131
+ #reject
132
+ task.reject()
133
+ #approve
134
+ task.approve()
135
+
136
+
121
137
  ```
@@ -29,6 +29,7 @@ This module is used to interact with the Xurrent API. It provides a set of class
29
29
  ```
30
30
 
31
31
  ### Requests
32
+
32
33
  ```python
33
34
  from xurrent.requests import Request
34
35
 
@@ -104,4 +105,19 @@ This module is used to interact with the Xurrent API. It provides a set of class
104
105
  "subject": "Example Subject"
105
106
  })
106
107
 
108
+ # get workflow of task (use expand: True to get the full workflow object)
109
+ workflow = task.get_workflow(expand=True)
110
+ # or statically
111
+ workflow = Task.get_workflow_by_template_id(x_api_helper, <id>, expand=True)
112
+
113
+ # close
114
+ task.close()
115
+ #cancel
116
+ task.cancel() # only possible before the task is started
117
+ #reject
118
+ task.reject()
119
+ #approve
120
+ task.approve()
121
+
122
+
107
123
  ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xurrent"
3
- version = "0.0.2.2"
3
+ version = "0.0.2.4"
4
4
  authors = [
5
5
  { name="Fabian Steiner", email="fabian@stei-ner.net" },
6
6
  ]
@@ -14,5 +14,5 @@ classifiers = [
14
14
  ]
15
15
 
16
16
  [project.urls]
17
- Homepage = "https://github.com/pypa/sampleproject"
18
- Issues = "https://github.com/pypa/sampleproject/issues"
17
+ Homepage = "https://github.com/fasteiner/xurrent-python"
18
+ Issues = "https://github.com/fasteiner/xurrent-python/issues"
@@ -1,6 +1,16 @@
1
1
  from .core import XurrentApiHelper
2
2
  from typing import Optional, List, Dict, Type, TypeVar
3
3
 
4
+ from enum import Enum
5
+
6
+ class PeoplePredefinedFilter(str, Enum):
7
+ disabled = "disabled" # List all disabled people
8
+ enabled = "enabled" # List all enabled people
9
+ internal = "internal" # List all internal people
10
+ directory = "directory" # List all people registered in the directory account of the support domain account from which the data is requested
11
+ support_domain = "support_domain" # List all people registered in the account from which the data is requested (and not the related directory account)
12
+
13
+
4
14
 
5
15
  T = TypeVar('T', bound='Person')
6
16
 
@@ -48,6 +58,16 @@ class Person():
48
58
  """
49
59
  uri = f'{connection_object.base_url}/{cls.resourceUrl}/me'
50
60
  return cls.from_data(connection_object, connection_object.api_call(uri, 'GET'))
61
+
62
+ @classmethod
63
+ def get_people(cls, connection_object: XurrentApiHelper, predefinedFilter: PeoplePredefinedFilter = None, queryfilter: dict = None) -> List[T]:
64
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}'
65
+ if predefinedFilter:
66
+ uri = f'{uri}/{predefinedFilter}'
67
+ if queryfilter:
68
+ uri += '?' + connection_object.create_filter_string(queryfilter)
69
+ response = connection_object.api_call(uri, 'GET')
70
+ return [cls.from_data(connection_object, person) for person in response]
51
71
 
52
72
  def update(self, data):
53
73
  uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}'
@@ -68,4 +88,44 @@ class Person():
68
88
  "name": f"{prefix}{self.name}{postfix}"
69
89
  })
70
90
 
91
+ def enable(self):
92
+ """
93
+ Enable the person.
94
+ """
95
+ return self.update({
96
+ 'disabled': 'false'
97
+ })
98
+
99
+ @classmethod
100
+ def create(cls, connection_object: XurrentApiHelper, data: dict):
101
+ """
102
+ Create a new person object.
103
+
104
+ :param connection_object: Xurrent Connection object
105
+ :param data: Data dictionary (containing the data for the new person)
106
+ """
107
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}'
108
+ return cls.from_data(connection_object, connection_object.api_call(uri, 'POST', data))
109
+
110
+ def archive(self):
111
+ """
112
+ Archive the person.
113
+ """
114
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/archive'
115
+ return self._connection_object.api_call(uri, 'POST')
116
+
117
+ def trash(self):
118
+ """
119
+ Trash the person.
120
+ """
121
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/trash'
122
+ return self._connection_object.api_call(uri, 'POST')
123
+
124
+ def restore(self):
125
+ """
126
+ Restore the person.
127
+ """
128
+ uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/restore'
129
+ return self._connection_object.api_call(uri, 'POST')
130
+
71
131
 
@@ -0,0 +1,175 @@
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
+ class TaskStatus(str, Enum):
18
+ registered = "registered" # Registered
19
+ declined = "declined" # Declined
20
+ assigned = "assigned" # Assigned
21
+ accepted = "accepted" # Accepted
22
+ in_progress = "in_progress" # In Progress
23
+ waiting_for = "waiting_for" # Waiting for…
24
+ waiting_for_customer = "waiting_for_customer" # Waiting for Customer
25
+ request_pending = "request_pending" # Request Pending
26
+ failed = "failed" # Failed
27
+ rejected = "rejected" # Rejected
28
+ completed = "completed" # Completed
29
+ approved = "approved" # Approved
30
+ canceled = "canceled" # Canceled
31
+
32
+
33
+ class Task():
34
+ #https://developer.4me.com/v1/tasks/
35
+ resourceUrl = 'tasks'
36
+
37
+ def __init__(self, connection_object: XurrentApiHelper, id, subject: str = None, workflow: dict = None,description: str = None, **kwargs):
38
+ self._connection_object = connection_object
39
+ self.id = id
40
+ self.subject = subject
41
+ self.workflow = workflow
42
+ for key, value in kwargs.items():
43
+ setattr(self, key, value)
44
+
45
+ def __update_object__(self, data) -> None:
46
+ if data.get('id') != self.id:
47
+ raise ValueError(f"ID mismatch: {self.id} != {data.get('id')}")
48
+ for key, value in data.items():
49
+ setattr(self, key, value)
50
+
51
+ def __str__(self) -> str:
52
+ """
53
+ Return a string representation of the object.
54
+ """
55
+ return f"Task(id={self.id}, subject={self.subject}, workflow={self.workflow})"
56
+
57
+ @classmethod
58
+ def from_data(cls, connection_object: XurrentApiHelper, data) -> T:
59
+ if not isinstance(data, dict):
60
+ raise TypeError(f"Expected 'data' to be a dictionary, got {type(data).__name__}")
61
+ if 'id' not in data:
62
+ raise ValueError("Data dictionary must contain an 'id' field.")
63
+ return cls(connection_object, **data)
64
+
65
+ @classmethod
66
+ def get_by_id(cls, connection_object: XurrentApiHelper, id) -> T:
67
+ uri = f'{connection_object.base_url}/{Task.resourceUrl}/{id}'
68
+ return cls.from_data(connection_object, connection_object.api_call(uri, 'GET'))
69
+
70
+ @classmethod
71
+ def get_tasks(cls, connection_object: XurrentApiHelper, predefinedFilter: TaskPredefinedFilter = None, queryfilter: dict = None) -> List[T]:
72
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}'
73
+ if predefinedFilter:
74
+ uri = f'{uri}/{predefinedFilter}'
75
+ if queryfilter:
76
+ uri += '?' + self._connection_object.create_filter_string(queryfilter)
77
+ return connection_object.api_call(uri, 'GET')
78
+
79
+ @staticmethod
80
+ def get_workflow_of_task(connection_object: XurrentApiHelper, id, expand: bool = False) -> Workflow:
81
+ task = Task.get_by_id(connection_object, id)
82
+ if expand:
83
+ return Workflow.get_by_id(connection_object, task.workflow.id)
84
+ return Workflow.from_data(connection_object, task.workflow)
85
+
86
+ def get_workflow(self, expand: bool = False) -> Workflow:
87
+ if task.workflow and not expand:
88
+ return Workflow.from_data(self._connection_object, self.workflow)
89
+ elif task.workflow and expand:
90
+ return Workflow.get_by_id(self._connection_object, self.workflow.id)
91
+ elif not task.workflow:
92
+ return Task.get_workflow_of_task(self._connection_object, self.id, expand)
93
+
94
+
95
+ @staticmethod
96
+ def update_by_id(connection_object: XurrentApiHelper, id, data) -> T:
97
+ task = Task(connection_object=connection_object, id=id)
98
+ return task.update(data)
99
+
100
+ def update(self, data) -> T:
101
+ uri = f'{connection_object.base_url}/{Task.resourceUrl}/{id}'
102
+ response = self._connection_object.api_call(uri, 'PATCH', data)
103
+ self.__update_object__(response)
104
+ return self
105
+
106
+ def close(self, note: str = None, member_id: int = None) -> T:
107
+ """
108
+ Close the task.
109
+
110
+ :param note: Note to add to the task
111
+ :param member_id: ID of the member who should close the task
112
+ """
113
+ if(self.category == "approval"):
114
+ raise ValueError("Approval tasks cannot be closed. Use the 'approve' or 'reject' method instead.")
115
+ return self.update({
116
+ 'status': 'completed',
117
+ 'note': note or "Task closed by API user",
118
+ 'member_id': member_id or self._connection_object.api_user.id
119
+ })
120
+
121
+ def approve(self, note: str = None, member_id: int = None) -> T:
122
+ """
123
+ Approve the task.
124
+
125
+ :param note: Note to add to the task
126
+ :param member_id: ID of the member who should approve the task
127
+ """
128
+ if(self.category != "approval"):
129
+ raise ValueError("Only approval tasks can be approved.")
130
+ return self.update({
131
+ 'status': 'approved',
132
+ 'note': note or "Task approved by API user",
133
+ 'member_id': member_id or self._connection_object.api_user.id
134
+ })
135
+
136
+ def reject(self, note: str = None, member_id: int = None) -> T:
137
+ """
138
+ Reject the task.
139
+
140
+ :param note: Note to add to the task
141
+ :param member_id: ID of the member who should reject the task
142
+ """
143
+
144
+ if(self.category != "approval"):
145
+ raise ValueError("Only approval tasks can be rejected.")
146
+ return self.update({
147
+ 'status': 'rejected',
148
+ 'note': note or "Task rejected by API user",
149
+ 'member_id': member_id or self._connection_object.api_user.id
150
+ })
151
+
152
+ def cancel(self, note: str = None, member_id: int = None) -> T:
153
+ """
154
+ Cancel the task.
155
+
156
+ :param note: Note to add to the task
157
+ :param member_id: ID of the member who should cancel the task
158
+ """
159
+ return self.update({
160
+ 'status': 'canceled',
161
+ 'note': note or "Task canceled by API user",
162
+ 'member_id': member_id or self._connection_object.api_user.id
163
+ })
164
+
165
+ @classmethod
166
+ def create(cls, connection_object: XurrentApiHelper, workflowID: int,data: dict) -> T:
167
+ """
168
+ Create a new task.
169
+
170
+ :param workflowID: ID of the workflow to create the task in
171
+ :param data: Data to create the task with
172
+ """
173
+ uri = f'{connection_object.base_url}/workflows/{workflowID}/{cls.resourceUrl}'
174
+ response = connection_object.api_call(uri, 'POST', data)
175
+ return cls.from_data(connection_object, response)
@@ -81,6 +81,19 @@ class Workflow:
81
81
  uri = f'{connection_object.base_url}/{cls.resourceUrl}/{id}'
82
82
  return cls.from_data(connection_object, connection_object.api_call(uri, 'GET'))
83
83
 
84
+ @classmethod
85
+ def get_workflows(cls, connection_object: XurrentApiHelper, predefinedFilter: WorkflowPredefinedFilter = None, queryfilter: dict = None) -> List[Workflow]:
86
+ """
87
+ Retrieve all workflows.
88
+ """
89
+ uri = f'{connection_object.base_url}/{cls.resourceUrl}'
90
+ if predefinedFilter:
91
+ uri = f'{uri}/{predefinedFilter}'
92
+ if queryfilter:
93
+ uri += '?' + connection_object.create_filter_string(queryfilter)
94
+ response = connection_object.api_call(uri, 'GET')
95
+ return [cls.from_data(connection_object, workflow) for workflow in response]
96
+
84
97
  @classmethod
85
98
  def get_workflow_tasks_by_workflow_id(cls, connection_object: XurrentApiHelper, id: int, queryfilter: dict = None) -> List[Task]:
86
99
  """
@@ -147,6 +160,13 @@ class Workflow:
147
160
  response = connection_object.api_call(uri, 'POST', data)
148
161
  return cls.from_data(connection_object, response)
149
162
 
163
+ def create_task(self, data: dict):
164
+ """
165
+ Create a new task associated with the current workflow instance.
166
+ """
167
+ from .tasks import Task
168
+ return Task.create(self._connection_object, self.id, data)
169
+
150
170
  def close(self, note="closed.", completion_reason=WorkflowCompletionReason.complete):
151
171
  """
152
172
  Close the current workflow instance.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xurrent
3
- Version: 0.0.2.2
3
+ Version: 0.0.2.4
4
4
  Summary: A python module to interact with the Xurrent API.
5
5
  Author-email: Fabian Steiner <fabian@stei-ner.net>
6
- Project-URL: Homepage, https://github.com/pypa/sampleproject
7
- Project-URL: Issues, https://github.com/pypa/sampleproject/issues
6
+ Project-URL: Homepage, https://github.com/fasteiner/xurrent-python
7
+ Project-URL: Issues, https://github.com/fasteiner/xurrent-python/issues
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
@@ -43,6 +43,7 @@ This module is used to interact with the Xurrent API. It provides a set of class
43
43
  ```
44
44
 
45
45
  ### Requests
46
+
46
47
  ```python
47
48
  from xurrent.requests import Request
48
49
 
@@ -118,4 +119,19 @@ This module is used to interact with the Xurrent API. It provides a set of class
118
119
  "subject": "Example Subject"
119
120
  })
120
121
 
122
+ # get workflow of task (use expand: True to get the full workflow object)
123
+ workflow = task.get_workflow(expand=True)
124
+ # or statically
125
+ workflow = Task.get_workflow_by_template_id(x_api_helper, <id>, expand=True)
126
+
127
+ # close
128
+ task.close()
129
+ #cancel
130
+ task.cancel() # only possible before the task is started
131
+ #reject
132
+ task.reject()
133
+ #approve
134
+ task.approve()
135
+
136
+
121
137
  ```
@@ -1,83 +0,0 @@
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
File without changes
File without changes
File without changes