Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functions to Card api #16

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4b9d1c4
Update composer.json
rtvisser Aug 25, 2015
b385cc2
Update Card.php
rtvisser Aug 25, 2015
2ee6349
Update composer.json
rtvisser Aug 25, 2015
000e6b4
Update Card.php
rtvisser Aug 25, 2015
62a9437
Update Card.php
rtvisser Aug 25, 2015
88a9c79
Update Card.php
rtvisser Aug 25, 2015
9679ab1
Update Card.php
rtvisser Aug 25, 2015
4b8eb5e
Update Card.php
rtvisser Aug 25, 2015
c1ef49d
Update Card.php
rtvisser Aug 25, 2015
d2f88e1
Update composer.json
rtvisser Aug 25, 2015
0febe7d
Update Card.php
rtvisser Aug 26, 2015
e93fdfa
Update Card.php
rtvisser Aug 27, 2015
b8a595f
Update Card.php
rtvisser Aug 27, 2015
90bb736
Update Checklist.php
rtvisser Aug 27, 2015
9046ba0
Update Checklist.php
rtvisser Aug 27, 2015
1d80e97
Update Card.php
rtvisser Aug 29, 2015
71b9e9c
Update Actions.php
rtvisser Sep 11, 2015
5628081
Update Actions.php
rtvisser Sep 11, 2015
95c58fc
Update Actions.php
rtvisser Sep 11, 2015
f6c5325
Update Actions.php
rtvisser Sep 11, 2015
b8e0ebd
Update Actions.php
rtvisser Sep 14, 2015
30ecdda
Update Actions.php
rtvisser Sep 14, 2015
513bd40
Update Labels.php
rtvisser Nov 3, 2015
faeaa9f
add a member to the board by memberId - add()
rtvisser Apr 28, 2017
7567d17
add label by color and name to board
rtvisser Apr 28, 2017
d32e4fa
fixed endpoint in add label to board function
rtvisser Apr 28, 2017
31cbf96
increased timeout counter for httpclient
rtvisser Apr 29, 2017
b67607d
Added actions to add/remove/update checklist items
rtvisser Aug 2, 2017
b3acbb8
Fixed type in function name
rtvisser Aug 2, 2017
d9ec2fb
reverted changes
rtvisser Aug 2, 2017
bd8747f
Get/Update/Delete checklist items from card
rtvisser Aug 2, 2017
c651f94
Fixed issue with adding cardid for checklist items
rtvisser Aug 2, 2017
405dfaf
fixed updateCheckItem endpoint
rtvisser Aug 2, 2017
1ced191
Added getChecklists call from card
rtvisser Aug 2, 2017
9ca700d
Get checklist items directly from checklist
rtvisser Aug 2, 2017
06a954d
typo in function declaration
rtvisser Aug 2, 2017
897c9cf
Split getChecklistItems and getChecklistItem
rtvisser Aug 2, 2017
f53f479
Update timeout to 50 sec
rtvisser Sep 8, 2017
d2b829f
Updated dependency to guzzle
rtvisser Mar 20, 2018
9120328
Upgrade to GuzzleHttp
rtvisser Mar 20, 2018
0b10096
Update to guzzleHttp
rtvisser Mar 20, 2018
9fb8756
Update to guzzleHttp
rtvisser Mar 20, 2018
8c7c595
Update to GuzzleHttp
rtvisser Mar 20, 2018
eb0af16
Update to GuzzleHttp
rtvisser Mar 20, 2018
064ef0e
Revert changes
rtvisser Mar 20, 2018
2a9fc1c
Revert changes
rtvisser Mar 20, 2018
a7bb6a5
Revert changes guzzleHttp
rtvisser Mar 20, 2018
18ed846
Revert changes guzzleHttp
rtvisser Mar 20, 2018
2ef7598
Revert changes guzzelHttp
rtvisser Mar 20, 2018
e29933f
Revert changes guzzleHttp
rtvisser Mar 20, 2018
6adf3e8
Custom fields basic API support
daryush Oct 3, 2019
60a1e65
Merge pull request #1 from daryush/feature/custom-fields
rtvisser Oct 3, 2019
38827df
Update custom field item on card
daryush Dec 9, 2019
4079089
Merge pull request #2 from daryush/feature/send-custom-field-item
rtvisser Dec 10, 2019
fea57ec
Update PowerUps.php
rtvisser May 25, 2021
13f7b10
Update PowerUps.php
rtvisser May 25, 2021
d90db84
Update PowerUps.php
rtvisser May 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/Trello/Api/Board.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,14 @@ public function powerUps()
{
return new Board\PowerUps($this->client);
}

/**
* Board CustomFields API
*
* @return Board\CustomFields
*/
public function customFields()
{
return new Board\CustomFields($this->client);
}
}
33 changes: 33 additions & 0 deletions lib/Trello/Api/Board/CustomFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Trello\Api\Board;

use Trello\Api\AbstractApi;

/**
* Trello Board custom fields API
* @link https://developers.trello.com/docs/getting-started-custom-fields
*
*/
class CustomFields extends AbstractApi
{
/**
* Base path of board custom fields api
* @var string
*/
protected $path = 'boards/#id#/customFields';

/**
* Get custom fields related to a given board
* @link https://developers.trello.com/docs/getting-started-custom-fields#section-get-custom-fields-on-a-board
*
* @param string $id the board's
* @param array $params optional parameters
*
* @return array
*/
public function all($id, array $params = array())
{
return $this->get($this->getPath($id), $params);
}
}
21 changes: 21 additions & 0 deletions lib/Trello/Api/Board/Labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ public function show($id, $color)
return $this->get($this->getPath($id).'/'.rawurlencode($color));
}

/**
* Add a label related to a given board
* @link https://developers.trello.com/advanced-reference/board#post-1-boards-board-id-labels
*
* @param string $id the board's id
* @param string $color the label's color
* @param string $name the label's name
*
* @return array
*/
public function add($id, $color, $name)
{

$params = array(
'color' => $color,
'name' => $name
);

return $this->post($this->getPath($id), $params);
}

/**
* Set a label's name on a given board and for a given color
* @link https://trello.com/docs/api/board/#put-1-boards-board-id-labelnames-blue
Expand Down
19 changes: 19 additions & 0 deletions lib/Trello/Api/Board/Members.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ public function remove($id, $memberId)
{
return $this->delete($this->getPath($id).'/'.$memberId);
}

/**
* Add a given member from a given board
* @link https://trello.com/docs/api/board/#get-1-boards-board-id-members
*
* @param string $id the board's id
* @param string $memberId the member's id
*
* @return array
*/
public function add($id, $memberId, $role = 'normal')
{
$params = array(
'idMember' => $memberId,
'type' => $role,
);

return $this->put($this->getPath($id).'/'.$memberId, $params);
}

/**
* Filter members related to a given board
Expand Down
30 changes: 29 additions & 1 deletion lib/Trello/Api/Board/PowerUps.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,33 @@ class PowerUps extends AbstractApi
* Base path of board power ups api
* @var string
*/
protected $path = 'boards/#id#/powerUps';
protected $path = 'boards/#id#/boardPlugins';


/**
* Get all power ups that are enabled on the board
* @link https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-plugins-get
*
* @param string $id the board's id
*
* @return array
*/
public function all($boardId, array $params = array())
{
return $this->get($this->getPath($boardId), $params);
}

/**
* Enable a powerup on the board
* @link https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-boardplugins-post
*
* @param string $boardId the board's id
* @param string $powerUpId the id of the powerUp that should be enabled
*
* @return array
*/
public function enable($boardId, $powerUpId)
{
return $this->post($this->getPath($boardId), array('idPlugin' => $powerUpId));
}
}
193 changes: 189 additions & 4 deletions lib/Trello/Api/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
* @link https://trello.com/docs/api/card
*
* Unimplemented:
* - https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-name
* - https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-pos
* - https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-state
* - https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklistcurrent-checkitem-idcheckitem
* - https://trello.com/docs/api/card/#post-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem
* - https://trello.com/docs/api/card/#post-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-converttocard
* - https://trello.com/docs/api/card/#post-1-cards-card-id-or-shortlink-markassociatednotificationsread
*/
Expand Down Expand Up @@ -91,6 +87,24 @@ public function create(array $params = array())

return $this->post($this->getPath(), $params);
}

/**
* Create a checklist Item
* @link https://trello.com/docs/api/card/#post-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem
*
* @param string $cardId id of the card the item is added to
* @param string $checkListId id of the checklist the item is added to
* @param array $params optional attributes
*
* @return array card info
*/

public function createCheckListItem($cardId, $checkListId, $params = Array()){

$this->validateRequiredParameters(array('idChecklist', 'name'), $params);

return $this->post($this->getPath().'/'.rawurlencode($cardId).'/checklist/'.rawurlencode($checkListId).'/checkItem', $params);
}

/**
* Update a card
Expand Down Expand Up @@ -152,6 +166,45 @@ public function getBoardField($id, $field)
return $this->get($this->getPath().'/'.rawurlencode($id).'/board/'.rawurlencode($field));
}

/**
* Get the checkitemstates, for now will return the full list of checkitem states;
* @link https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-checkitemstates
*
* @param string $id the card's id or short link
*
* @return array list info
*/
public function getCheckItemStates($id){

return $this->get($this->getPath().'/'.rawurlencode($id).'/checkItemStates', array('value' => 'all'));
}

/**
* Get the checklists, for now will return the full list of checkitem states;
* @link https://trello.readme.io/v1.0/reference#cardsidchecklists
*
* @param string $id the card's id or short link
* @param array $fields (optional) an array with the requested fields, all by default
*
* @return array checklist info
*/
public function getCheckLists($id, array $fields = array('fields'=>'all')){

return $this->get($this->getPath().'/'.rawurlencode($id).'/checklists', $fields);

}

/**
* Get the members;
* @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-members
*
* @param string $id the card's id or short link
*
* @return array list info
*/
public function getMembers($id){
return $this->get($this->getPath().'/'.rawurlencode($id).'/members', array('value' => 'all'));
}
/**
* Set a given card's list
* @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-idlist
Expand Down Expand Up @@ -283,6 +336,128 @@ public function setSubscribed($id, $subscribed)
return $this->put($this->getPath().'/'.rawurlencode($id).'/subscribed', array('value' => $subscribed));
}


/**
* Set a given card's memberId
* @link tbd
*
* @param string $id the list's id
* @param string $idMembers comma seperated list of responsible members
*
* @return array list info
*/
public function setIdMembers($id, $idMembers)
{
return $this->put($this->getPath().'/'.rawurlencode($id).'/idMembers', array('value' => $idMembers));
}

/**
* Set a given checklist item name
* @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-name
*
* @param string $cardId the cards's id
* @param string $checkListId the checklist's id
* @param string $itemId the item's id
* @param string $name new name value
*
* @return array list info
*/
public function setCheckListItemName($cardId,$checkListId,$itemId, $name)
{
return $this->put($this->getPath().'/'.rawurlencode($cardId).'/checklist/'.rawurlencode($checkListId).'/checkItem/'.rawurlencode($itemId).'/name', array('value' => $name));
}

/**
* Set a given checklist item position
* @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-pos
*
* @param string $cardId the cards's id
* @param string $checkListId the checklist's id
* @param string $itemId the item's id
* @param string $position new position value
*
* @return array list info
*/
public function setCheckListItemPosition($cardId,$checkListId,$itemId, $position)
{
return $this->put($this->getPath().'/'.rawurlencode($cardId).'/checklist/'.rawurlencode($checkListId).'/checkItem/'.rawurlencode($itemId).'/pos', array('value' => $position));
}

/**
* Set a given checklist item closed state
* @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-state
*
* @param string $cardId the cards's id
* @param string $checkListId the checklist's id
* @param string $itemId the item's id
* @param bool $complete new complete value, defaults to true
*
* @return array list info
*/
public function setCheckListItemClosed($cardId,$checkListId,$itemId, $complete = true)
{
return $this->put($this->getPath().'/'.rawurlencode($cardId).'/checklist/'.rawurlencode($checkListId).'/checkItem/'.rawurlencode($itemId).'/state', array('value' => $complete));
}

/**
* Update checklist item by parameter array
* @link https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-checklist-idchecklistcurrent-checkitem-idcheckitem
*
* @param string $cardId the cards's id
* @param string $checkListId the checklist's id
* @param string $itemId the item's id
* @param array $params item attributes to update
*
* @return array list info
*/
public function updateCheckListItem($cardId,$checkListId,$itemId, $params = array())
{
return $this->put($this->getPath().'/'.rawurlencode($cardId).'/checklist/'.rawurlencode($checkListId).'/checkItem/'.rawurlencode($itemId), $params);
}

/**
* Get checkitem from a given card
* @link https://trello.readme.io/v1.0/reference#cardsidcheckitemidcheckitem-2
*
* @param string $id the card's id or short link
* @param string $checkItemId the check item id
* @param array $params the parameter array to retrieve, default is to retrieve all fields
*
* @return array
*/
public function getCheckItem($id, $checkItemId, array $params = array('fields'=> 'all'))
{
return $this->get($this->getPath().'/'.rawurlencode($id).'/checkItem/'.rawurlencode($checkItemId), $params);
}

/**
* Update checkItem for a given card
* @link https://trello.readme.io/v1.0/reference#cardsidcheckitemidcheckitem-1
*
* @param string $id the card's id or short link
* @param string $checkItemId the check item id
* @param array $updateFields the fields that should be updated
* @return array
*/
public function updateCheckItem($id, $checkItemId, array $updateFields = array())
{
return $this->put($this->getPath().'/'.rawurlencode($id).'/checkItem/'.rawurlencode($checkItemId), $updateFields);
}

/**
* Remove checkitem from a given card
* @link https://trello.readme.io/v1.0/reference#cardsidcheckitemidcheckitem-2
*
* @param string $id the card's id or short link
* @param string $checkItemId the checklist item id
*
* @return array
*/
public function removeCheckItem($id, $checkItemId)
{
return $this->delete($this->getPath().'/'.rawurlencode($id).'/checkItem/'.rawurlencode($checkItemId));
}

/**
* Actions API
*
Expand Down Expand Up @@ -342,4 +517,14 @@ public function stickers()
{
return new Card\Stickers($this->client);
}

/**
* CustomFieldItems API
*
* @return Card\CustomFieldItems
*/
public function customFieldItems()
{
return new Card\CustomFieldItems($this->client);
}
}
18 changes: 16 additions & 2 deletions lib/Trello/Api/Card/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function all($id, array $params = array())
{
return $this->get($this->getPath($id), $params);
}

/**
* Add comment to a given card
* @link https://trello.com/docs/api/card/#post-1-cards-card-id-or-shortlink-actions-comments
Expand All @@ -53,6 +53,20 @@ public function addComment($id, $text)
*/
public function removeComment($id, $commentId)
{
return $this->delete($this->getPath($id).'/comments/'.rawurlencode($commentId));
return $this->delete($this->getPath($id).'/'.rawurlencode($commentId).'/comments');
}

/**
* Update comment to a given card
* @link https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-actions-idaction-comments
*
* @param string $id the card's id or short link
* @param string $commentId the comment's id
* @param string $text the new comment text
* @return array
*/
public function updateComment($id, $commentId, $text)
{
return $this->put($this->getPath($id).'/'.rawurlencode($commentId).'/comments', array('text' => $text));
}
}