Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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" },
]
Expand All @@ -14,5 +14,5 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/pypa/sampleproject"
Issues = "https://github.com/pypa/sampleproject/issues"
Homepage = "https://github.com/fasteiner/xurrent-python"
Issues = "https://github.com/fasteiner/xurrent-python/issues"
60 changes: 60 additions & 0 deletions src/xurrent/people.py
Original file line number Diff line number Diff line change
@@ -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')

Expand Down Expand Up @@ -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}'
Expand All @@ -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')


13 changes: 13 additions & 0 deletions src/xurrent/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
"""
Expand Down
Loading