Skip to content

george-martinec/GoodDay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



GoodDay

GoodDay PHP

🔑 Create and insert Token in GoodDay class.
🧙‍♂️ You can Generate API Token in your Organization under Settings > API

Created with: Unirest for



Initialize project:

<?php

declare(strict_types = 1);

use Unirest\Request as Request;

require_once __DIR__ . '/Helper.php';
require_once __DIR__ . '/GoodDay.php';

$Helper  = new Helper();
$GoodDay = new GoodDay('YOUR_API_TOKEN');

// ...

Could be usefull:


Content:

  1. 📂 Folders & Projects
  2. 📝 Tasks
  3. 📣 Events
  4. 🧔 Users
  5. ⏲️ Time Reports
  6. ✏️ Custom Fields
  7. 💻 System
  8. 🤖 Helper

1. 📂 Folders & Projects

$GoodDay->getProjects(...)

Retrieve a list of company projects:

Params Required Default Type / Format Description
archived no false bool if set to true returns archived/closed projects
rootOnly no false bool if set to true returns only root projects

$GoodDay->getProject(...)

Get project details by projectId:

Params Required Type / Format Description
projectId yes string projectId

$GoodDay->createFolder(...)

Create new folder:

Params Required Default Type / Format Description
createdByUserId yes string ID of a user, a new record is created on behalf of
name yes string Folder name
parentProjectId no null string Pass parent project ID to create a sub-folder
color no null int Folder color (1..24)

$GoodDay->createProject(...)

Create new project:

Params Required Default Type / Format     Description
createdByUserId yes string ID of a user, a new record is created on behalf of
projectTemplateId yes string Project template (type) ID you can find in Organization settings → Project templates
name yes string Project name
parentProjectId no null string Pass parent project ID to create a sub-project
color no null int Folder color (1..24)
projectOwnerUserId no null string Project owner user ID
startDate no null string / Y-m-d endDate required - Project start date
endDate no null string / Y-m-d startDate required - Project end date
deadline no null string / Y-m-d Project deadline

$GoodDay->getProjectUsers(...)

Retrieve a list of project users by projectId:

Params Required Type / Format Description
projectId yes string projectId

2. 📝 Tasks

$GoodDay->getTasks(...)

Retrieve a list of project tasks by projectId:

Params Required Default Type / Format Description
projectId yes string projectId
projectTemplateId no false bool if set to true returns all open and closed tasks
name no false bool if set to true returns tasks from project its subfolders

$GoodDay->getActionRequiredTasks(...)

Retrieve a list of action required tasks by userId:

Params Required Type / Format Description
userId yes string userId

$GoodDay->getAssignedTasks(...)

Retrieve a list of tasks assigned to user by userId:

Params Required Default Type / Format Description
userId yes string userId
closed no false bool if set to true returns all open and closed tasks

$GoodDay->getTask(...)

Retrieve task details by taskId:

Params Required Type / Format Description
taskId yes string taskId

$GoodDay->createTask(...)

Create new task:

Params Required Default Type / Format     Description
projectId yes string Task project ID
title yes string Task title
fromUserId yes string Task created by user ID
parentTaskId no null string Pass parent task ID to create a subtask
message no null string Task description / initial message
toUserId no null string Assigned To/Action required user ID
taskTypeId no null string Task type ID
startDate no null string / Y-m-d endDate required - Task start date
endDate no null string / Y-m-d startDate required - Task end date
deadline no null string / Y-m-d Task deadline (due date)
estimate no null int Task estimate in minutes
priority no null int Task priority (1-10), 50 - Blocker, 100 - Emergency

$GoodDay->getTaskMessages(...)

Retrieve a list of task messages by taskId:

Params Required Type / Format Description
taskId yes string taskId

$GoodDay->createComment(...)

Create task comment by taskId:

Params Required Default Type / Format Description
taskId yes string taskId
userId yes string User on behalf of whom API will execute update
comment no null string Comment

$GoodDay->replyOrChangeActionRequiredUser(...)

Reply or change AR user by taskId:

Params Required Default Type / Format Description
taskId yes string taskId
userId yes string User on behalf of whom API will execute update
actionRequiredUserId yes string Action required user
comment no null string Comment

$GoodDay->updateTaskStatus(...)

Update task status by taskId:

Params Required Default Type / Format Description
taskId yes string taskId
userId yes string User on behalf of whom API will execute update
statusId yes string New status ID
comment no null string Comment

$GoodDay->updateTask(...)

Update task status by taskId:

Params Required Default Type / Format     Description
taskId yes string taskId
userId yes string User on behalf of whom API will execute update
startDate no null string / Y-m-d Task start date, 'reset' to reset
endDate no null string / Y-m-d Task end date, 'reset' to reset
deadline no null string / Y-m-d Task deadline (due date), 'reset' to reset
priority no null int Task priority (1-10), 50 - Blocker, 100 - Emergency
estimate no null string / Y-m-d Task estimate in minutes, 'reset' to reset
progress no null string / Y-m-d Task progress percentage (0-100) or 'reset' to reset
title no null string Task title

$GoodDay->deleteTask(...)

Delete task by taskId:

By deleting a task you also delete all task's related data including time reports, subtasks, etc.
It is recommended to cancel tasks (by updating status) instead of deleting.

Params Required Type / Format Description
taskId yes string taskId

3. 📣 Events

$GoodDay->getEvents(...)

Retrieve list of events:

Event types: https://www.goodday.work/developers/api-v2/events

Params Required Default Type / Format                                    Description
startDate yes string / Y-m-d Events start date
endDate yes string / Y-m-d Events end date
eventTypes no null string / 'eventType1,eventType2' List of event types separated by comma, no spaces

$GoodDay->getEvent(...)

Retrieve event details by eventId:

Params Required Type / Format Description
eventId yes string eventId

$GoodDay->createEvent(...)

Create new event:

Params Required Default Type / Format     Description
createdByUserId yes string ID of a user, a new event is created on behalf of
eventType yes string Event type
name yes string / Y-m-d Event name
startDate yes string / Y-m-d Event start date
endDate depends on event types null string / Y-m-d Event end date. Not required for single-day events i.e. project-milestone
userId required for personal events null string Personal event user ID
projectId required for project events null string Project/folder ID
notes no null string Event notes
assignedToUserId no null string User ID an event is assigned to

$GoodDay->deleteEvent(...)

Delete an Event by eventId:

Params Required Type / Format Description
eventId yes string eventId

4. 🧔 Users

$GoodDay->getUsers()

Retrieve a list of users:


$GoodDay->getUser(...)

Retrieve user details by userId:

Params Required Type / Format Description
userId yes string userId

5. ⏲️ Time Reports

$GoodDay->createTimeReport(...)

Create time report by taskId:

Params Required Default Type / Format     Description
taskId yes string taskId
userId yes string User on behalf of whom API will execute update
reportedMinutes yes int Reported time in minutes
date no null string / Y-m-d Date you want to report time for, current date will be set if not passed
comment no null string Comment

$GoodDay->getUserTimeReport(...)

List of time reports for a specific user by userId:

Params Required Default Type / Format     Description
userId yes string userId
startDate no string / Y-m-d endDate required - Start date filter
endDate no string / Y-m-d startDate required - End date filter

$GoodDay->getTaskTimeReport(...)

List of time reports for a specific task by taskId:

Params Required Default Type / Format     Description
taskId yes string taskId
subtasks yes bool if set to true returns time reports for all subtasks
startDate no null string / Y-m-d endDate required - Start date filter
endDate no null string / Y-m-d startDate required - End date filter

$GoodDay->getTaskTimeReport(...)

List of time reports for a specific project by projectId:

Params Required Default Type / Format     Description
projectId yes string projectId
subtasks yes bool if set to true returns time reports for all subprojects
startDate no null string / Y-m-d endDate required - Start date filter
endDate no null string / Y-m-d startDate required - End date filter

$GoodDay->getTimeReports(...)

List of all time reports for a specified period of time:

Params Required Type / Format     Description
startDate yes string / Y-m-d endDate required - Start date filter
endDate yes string / Y-m-d startDate required - End date filter
projectIds yes array Projects filter
userIds yes array Users filter

6. ✏️ Custom Fields

$GoodDay->getCustomFields()

Retrieve a list of all custom fields.


$GoodDay->updateTaskCustomFields(...)

Update task's custom fields values by taskId:

Custom Field Types: https://www.goodday.work/developers/api-v2/custom-fields

Params Required Type / Format Description
taskId yes string taskId
customFields yes string / json Array of objects

7. 💻 System

$GoodDay->getStatuses()

Retrieve a list of all statuses within the organization.


$GoodDay->getTaskTypes()

Retrieve a list of available task types.


🤖 Helper

Usage:

// use Unirest\Request as Request;
$Helper = new Helper();
$GoodDay = new GoodDay('YOUR_API_TOKEN');

$Helper::d("My GoodDay Projects");

$projects = $GoodDay->getProjects();
$Helper::d($projects, $Helper::toObject( Request::getInfo()));

$Helper::dd("Dump&Die");

$Helper::toObject(...)

Convert array to object
Mostly used with Request::getInfo():

// use Unirest\Request as Request;
$Helper  = new Helper();
$GoodDay = new GoodDay('YOUR_API_TOKEN');

$projects = $GoodDay->getProjects();
$Helper::d($projects, $Helper::toObject( Request::getInfo() ));

$Helper::sumArrayColumn(...)

Calculate the sum of the ArrayColumn
Mostly used with timeReported:

$Helper  = new Helper();
$GoodDay = new GoodDay('YOUR_API_TOKEN');

$taskTimeReport = $GoodDay->getTaskTimeReport('TASK_ID');
$totalTaskTimeReported = (int) $Helper::sumArrayColumn($taskTimeReport->body, 'timeReported');
$Helper::d($totalTaskTimeReported);

$Helper::currentDate()

Get current date in GoodDay format
Usage: $Helper::currentDate():

$Helper  = new Helper();
$GoodDay = new GoodDay('YOUR_API_TOKEN');

$currentDate = $Helper::currentDate();
$currentEvents = $GoodDay->getEvents($currentDate, $currentDate);
$Helper::d($currentEvents);

$Helper::getDate(...)

Get date in GoodDay format
Usage: $Helper::getDate('+3 days'):

https://www.php.net/manual/en/function.strtotime.php

$Helper  = new Helper();
$GoodDay = new GoodDay('YOUR_API_TOKEN');

$currentEvents = $GoodDay->getEvents($Helper::getDate('-3 days'), $Helper::getDate('+3 days'));
$Helper::d($currentEvents);

$Helper::d(...)

Dump
Usage: $Helper::d("My GoodDay API Project");
Shortcut for:

print("<pre>");
foreach (func_get_args() as $arg) {
    print_r($arg);
}
print("</pre>");

$Helper::dd(...)

Dump&Die
Usage: $Helper::dd("Dump&Die");
Shortcut for:

print("<pre>");
foreach (func_get_args() as $arg) {
    print_r($arg);
}
print("</pre>");
exit();



Made with ❤️ by George Martinec