Code Monkey home page Code Monkey logo

clickup-php's Introduction

Fork for the clickup-php

Fork for the original repo clickup-php | Author: howyi

A simple wrapper for ClickUp API (v1-BETA).

Fork difference:

  • Api update to version 2 (in progress)
  • Add retries when rate limit is reached (done, thanks @osiset)
  • Add tmp cache for identical requests in a short time (in the plans)

Table of Contents

Installation

composer require eduard9969/clickup-php

The package is in development status. I don't want to add another copy of the fork to https://packagist.org/

Also, You can install the package using VSC in your composer.json. Add the following code:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/Eduard9969/clickup-php.git"
    }
]

Usage

Generate client

// create Option (required: API_TOKEN)
$options = new ClickUp\Options('API_TOKEN');

// create Client (required: ClickUp\Options)
$client = new ClickUp\Client($options);

Get

// me
$client->user();
// -> \ClickUp\Objects\User


// all affiliated teams
$client->teams()->objects();
// -> \ClickUp\Objects\Team[]

// team by team id
$team = $client->team($teamId);
// team by name
$team = $client->teams()->getByName('team_name');
// -> \ClickUp\Objects\Team


// spaces in team
$team->spaces()->objects();
// -> \ClickUp\Objects\Space[]

// space by space id
$space = $team->space(888);
// space by name
$space = $team->spaces()->getByName('spaaaaace');
// -> \ClickUp\Objects\Space


// folders in space
$space->folders()->objects();
// -> \ClickUp\Objects\Folder[]

// folder by folder id
$folder = $space->folder(11111);
// folder by name
$folder = $space->folders()->getByName('super cool folder');
// -> \ClickUp\Objects\Folder

// lists in folder
$folder->taskLists()->objects();
// -> \ClickUp\Objects\TaskList[]

// list by list id
$taskList = $folder->taskList(9999);
// list by name
$taskList = $folder->taskLists()->getByName('T A S K L I S T');
// -> \ClickUp\Objects\TaskList

// tasks by list
// @see https://jsapi.apiary.io/apis/clickup20/reference/0/lists/update-list.html
$tasks = $taskList->tasks()->objects();
// -> \ClickUp\Objects\Task[]

// task by task id
$task = $taskList->task(3333);
// -> \ClickUp\Objects\Task

// all tasks with chunks
// tasksChunk get all tasks from the API and execute callback function (arg: $tasks->objects())
$allTasks = [];
$team->tasksChunk(false, false, function($tasks) use (&$allTasks) {
    $allTasks = array_merge($tasks, $allTasks);
    // return false; // break loop 
});
// -> true \ false

You can use tasks and task methods on the any level ($team->tasks(); $space->tasks(); $folder->tasks(); etc). But remember, 100 is the maximum number of items in the response (not actual for chunk method), I recommend refining the research area.

Create

/**
 * create task list in folder
 * @see https://jsapi.apiary.io/apis/clickup20/reference/0/lists/create-list.html
 * @see https://jsapi.apiary.io/apis/clickup20/reference/0/lists/create-folderless-list.html
 */
$folder->createTaskList(['name' => 'newTaskList']);

/**
 * create task in list
 * @see https://jsapi.apiary.io/apis/clickup20/reference/0/tasks/create-task.html
 */
$taskList->createTask(['name' => 'my second task']);

Update

/**
 * update task list
 * @see https://jsapi.apiary.io/apis/clickup20/reference/0/lists/update-list.html
 */
$taskList->edit(['name' => 'renamed task list']);

/**
 * update task
 * @see https://jsapi.apiary.io/apis/clickup20/reference/0/lists/update-list.html
 */
$task->edit(['name' => 'renamed task']);

Storage

By default retries when rate limit is reached execute via Memory::Class. You can use other storage (Implement the StateStorage interface) and use custom time deferrer (Implement the TimeDeferrer interface).

// create Option (required: API_TOKEN)
$options = new ClickUp\Options('API_TOKEN');

// create StoreOptions (optional: StateStorage, StateStorage, TimeDeferrer)
$storeOptions = new ClickUp\StoreOptions($redisTStorage, $redisLStorage, $timeDeferrer);

// create Client (required: ClickUp\Options, optional: ClickUp\StoreOptions)
$client = new ClickUp\Client($options, $storeOptions);

LICENSE

This project is released under the MIT license.

clickup-php's People

Contributors

eduard9969 avatar stylecibot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.