Fresh Task is a Python package that fetches a list of tasks from Fresh Service tickets.
Project description
Freshtasks
Freshtasks is a python library that facilitates the manipulation of tasks associated with Freshservice tickets
Getting Started
Assuming that you have Python and virtualenv installed, set up your environment and install the required dependencies using pip:
pip install freshtasks
Using Freshtasks
After installing freshtasks
You need to import the main Api object and instantiate it to create a connection to freshservice:
from freshtasks.api import Api
api = Api(api_key, domain)
Here,
api_key
is your freshservice api key already converted to Base 64.
domain
is your freshservice domain in the format domain.freshservice.com
When the connection has been initiated, laoding the task is only one line away. Below is the full code to load all tasks:
from freshtasks.api import Api
api = Api(api_key, domain)
tasks = api.load_tasks(ticket)
ticket here is the freshservice ticket number in the following format `#SR-1234` or `SR-2134`
Task Model
Tasks are returned using freshtasks custom made models.
The following attributes are available for a specific task returned:
- id - The unique ID of the freshservice task
- title - The title of the freshservice task
- description - The description of the freshservice task
- agent - The agent assigned to the task
- status - The status of the task, 1-Open, 2-In Progress, 3-Completed
Task Utils
You can control the outcome of the tasks return in several ways using the Task Utils model in freshtasks.
Using Task Utils
Below is a sample code on how to use Task Utils:
from freshtasks.task_utils import TaskUtils
task_utils = TaskUtils(tasks)
Here tasks
is a list of Task models returned usign the Api model.
Using the task_utils
object, you can manipulate the outcome in several ways. Below is the full sample on how to return only open tasks
:
from freshtasks.task_utils import TaskUtils
api = Api(self.api_key, self.domain)
tasks = api.load_tasks(self.ticket)
task_utils = TaskUtils(tasks)
open_tasks = task_utils.get_open()
The available filters are defined below:
-
Get Open Tasks
This filter will extract only open tasks
Function Name
- get_open() -
Get In Progress Tasks
This filter will extract only in progress tasks
Function Name
- get_in_progress() -
Get Completed Tasks
This filter will extract only completed tasks
Function Name
- get_completed() -
Match Exactly One Keyword in Task Title
This filter will match a provided keyword exactly against a task title and will return this task.
This method returns ONLY ONE task
Function Name
- matchxact_one_by_keyword() -
Match Exactly All Keyword in Task Title
This filter will match a provided keyword exactly against a task title and will return all tasks matched.
Function Name
- matchxact_all_by_keyword() -
Match One Keyword in Task Title
This filter will match a provided keyword case insensitive against a task title and will return this task.
This method returns ONLY ONE task
Function Name
- matchword_one_by_keyword() -
Match All Keyword in Task Title
This filter will match a provided keyword case insensitive against a task title and will return all tasks matched.
Function Name
- matchword_all_by_keyword()
Closing a task
You can also close a task using freshtasks inbuilt functions. You need to provide the two parameters below for a successful call:
-
ticket
- The freshservice ticket number in the following format#SR-1234
orSR-2134
-
task_id
- The freshservice task id
Below is a full code sample:
from freshtasks.api import Api
api = Api(..., ...)
api.close_task(TICKET_HERE, TASK_ID_HERE)
Running Tests
You can run the tests by following the steps below:
- Clone or download the project to a folder
- Create a file named
secret.env
- Add the following variables as follows in the env file:
export ENV_FRESH_SERVICE_KEY_API_B64="YOUR_API_KEY"
export ENV_VALUE_DOMAIN_FRESHSERVICE_CKO="domain.freshservice.com"
- Run the tests using the command
./run_test.sh
License
Copyright Mervin Hemaraju
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file freshtasks-1.1.tar.gz
.
File metadata
- Download URL: freshtasks-1.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15ec2afb6868e077b450d549ffd3ba86de77a5e66e85dc951ad47daad4284a97 |
|
MD5 | 7a7cc7ebf3a3d474691090347128ed37 |
|
BLAKE2b-256 | 5d20cafe1a448de11588663da694f1a07bfca7ef262a87b2bffbf722954a2fde |