From 484b71fc0f6ce3b6db15416f7510a21556ea7378 Mon Sep 17 00:00:00 2001 From: "Ing. Fabian Franz Steiner BSc." Date: Tue, 10 Dec 2024 10:45:52 +0100 Subject: [PATCH 1/2] Update project URLs in pyproject.toml to reflect repository location --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5159cfa..d6ffb6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,5 +14,5 @@ classifiers = [ ] [project.urls] -Homepage = "https://github.com/pypa/sampleproject" -Issues = "https://github.com/pypa/sampleproject/issues" \ No newline at end of file +Homepage = "https://github.com/fasteiner/xurrent-python" +Issues = "https://github.com/fasteiner/xurrent-python/issues" \ No newline at end of file From 5d3061bb1adcecf1a6ed503832f21120a8196c3e Mon Sep 17 00:00:00 2001 From: "Ing. Fabian Franz Steiner BSc." Date: Tue, 10 Dec 2024 10:58:20 +0100 Subject: [PATCH 2/2] Update changelog for version 0.0.2.4; add new non-static and static methods for People and Workflows --- ChangeLog.md | 8 ++++++ pyproject.toml | 2 +- src/xurrent/people.py | 60 ++++++++++++++++++++++++++++++++++++++++ src/xurrent/workflows.py | 13 +++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 15cfeff..53dfea5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,13 @@ # Change Log +## v0.0.2.4 + +### New Features + +- People: add non static methods: enable, archive, trash, restore +- People: add static methods: create, get_people +- Workflows: add static methods: get_workflows + ## v0.0.2.3 ### New Features diff --git a/pyproject.toml b/pyproject.toml index d6ffb6c..4abf723 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "xurrent" -version = "0.0.2.3" +version = "0.0.2.4" authors = [ { name="Fabian Steiner", email="fabian@stei-ner.net" }, ] diff --git a/src/xurrent/people.py b/src/xurrent/people.py index 6c36c2e..4c070b5 100644 --- a/src/xurrent/people.py +++ b/src/xurrent/people.py @@ -1,6 +1,16 @@ from .core import XurrentApiHelper from typing import Optional, List, Dict, Type, TypeVar +from enum import Enum + +class PeoplePredefinedFilter(str, Enum): + disabled = "disabled" # List all disabled people + enabled = "enabled" # List all enabled people + internal = "internal" # List all internal people + directory = "directory" # List all people registered in the directory account of the support domain account from which the data is requested + support_domain = "support_domain" # List all people registered in the account from which the data is requested (and not the related directory account) + + T = TypeVar('T', bound='Person') @@ -48,6 +58,16 @@ def get_me(cls, connection_object: XurrentApiHelper): """ uri = f'{connection_object.base_url}/{cls.resourceUrl}/me' return cls.from_data(connection_object, connection_object.api_call(uri, 'GET')) + + @classmethod + def get_people(cls, connection_object: XurrentApiHelper, predefinedFilter: PeoplePredefinedFilter = None, queryfilter: dict = None) -> List[T]: + uri = f'{connection_object.base_url}/{cls.resourceUrl}' + if predefinedFilter: + uri = f'{uri}/{predefinedFilter}' + if queryfilter: + uri += '?' + connection_object.create_filter_string(queryfilter) + response = connection_object.api_call(uri, 'GET') + return [cls.from_data(connection_object, person) for person in response] def update(self, data): uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}' @@ -68,4 +88,44 @@ def disable(self, prefix: str = '', postfix: str = ''): "name": f"{prefix}{self.name}{postfix}" }) + def enable(self): + """ + Enable the person. + """ + return self.update({ + 'disabled': 'false' + }) + + @classmethod + def create(cls, connection_object: XurrentApiHelper, data: dict): + """ + Create a new person object. + + :param connection_object: Xurrent Connection object + :param data: Data dictionary (containing the data for the new person) + """ + uri = f'{connection_object.base_url}/{cls.resourceUrl}' + return cls.from_data(connection_object, connection_object.api_call(uri, 'POST', data)) + + def archive(self): + """ + Archive the person. + """ + uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/archive' + return self._connection_object.api_call(uri, 'POST') + + def trash(self): + """ + Trash the person. + """ + uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/trash' + return self._connection_object.api_call(uri, 'POST') + + def restore(self): + """ + Restore the person. + """ + uri = f'{self._connection_object.base_url}/{self.resourceUrl}/{self.id}/restore' + return self._connection_object.api_call(uri, 'POST') + \ No newline at end of file diff --git a/src/xurrent/workflows.py b/src/xurrent/workflows.py index ed5c987..c72e486 100644 --- a/src/xurrent/workflows.py +++ b/src/xurrent/workflows.py @@ -81,6 +81,19 @@ def get_by_id(cls, connection_object: XurrentApiHelper, id: int) -> dict: uri = f'{connection_object.base_url}/{cls.resourceUrl}/{id}' return cls.from_data(connection_object, connection_object.api_call(uri, 'GET')) + @classmethod + def get_workflows(cls, connection_object: XurrentApiHelper, predefinedFilter: WorkflowPredefinedFilter = None, queryfilter: dict = None) -> List[Workflow]: + """ + Retrieve all workflows. + """ + uri = f'{connection_object.base_url}/{cls.resourceUrl}' + if predefinedFilter: + uri = f'{uri}/{predefinedFilter}' + if queryfilter: + uri += '?' + connection_object.create_filter_string(queryfilter) + response = connection_object.api_call(uri, 'GET') + return [cls.from_data(connection_object, workflow) for workflow in response] + @classmethod def get_workflow_tasks_by_workflow_id(cls, connection_object: XurrentApiHelper, id: int, queryfilter: dict = None) -> List[Task]: """