Skip to content

Commit

Permalink
Merge e29933f into 579530b
Browse files Browse the repository at this point in the history
  • Loading branch information
rtvisser committed Mar 20, 2018
2 parents 579530b + e29933f commit 505d1c7
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 9 deletions.
21 changes: 21 additions & 0 deletions lib/Trello/Api/Board/Labels.php
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
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
183 changes: 179 additions & 4 deletions lib/Trello/Api/Card.php
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
18 changes: 16 additions & 2 deletions lib/Trello/Api/Card/Actions.php
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));
}
}
36 changes: 36 additions & 0 deletions lib/Trello/Api/Card/Labels.php
Expand Up @@ -38,6 +38,25 @@ public function set($id, array $labels)

return $this->put($this->getPath($id), array('value' => $labels));
}

/**
* Set a given card's label by labelId
* @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-labels
*
* @param string $id the card's id or short link
* @param string $labelId the label id
*
* @return array card info
*
* @throws InvalidArgumentException If a label does not exist
*/
public function setById($id, $labelId)
{
//first set the right path based on the documentation;
$this->path = 'cards/#id#/idLabels';

return $this->post($this->getPath($id), array('value' => $labelId));
}

/**
* Remove a given label from a given card
Expand All @@ -58,4 +77,21 @@ public function remove($id, $label)

return $this->delete($this->getPath($id).'/'.rawurlencode($label));
}

/**
* Remove a given label from a given card based on the label id
* @link https://developers.trello.com/advanced-reference/card#delete-1-cards-card-id-or-shortlink-idlabels-idlabel
*
* @param string $id the card's id or short link
* @param string $labelId the label id to remove
*
* @return array card info
*
* @throws InvalidArgumentException If a label does not exist
*/
public function removeById($id, $labelId)
{
$this->path = 'cards/#id#/idLabels';
return $this->delete($this->getPath($id).'/'.rawurlencode($labelId));
}
}
47 changes: 46 additions & 1 deletion lib/Trello/Api/Checklist.php
Expand Up @@ -85,7 +85,52 @@ public function remove($id)
{
return $this->delete($this->getPath().'/'.rawurlencode($id));
}


/**
* Remove a listitem from a checklist
* @link https://trello.com/docs/api/checklist/index.html#delete-1-checklists-idchecklist-checkitems-idcheckitem
*
* @param string $checkListId the checklist's id
* @param string $listItemId the listItem id
*
* @return array
*/
public function removeListItem($checkListId, $listItemId)
{
return $this->delete($this->getPath().'/'.rawurlencode($checkListId).'/checkItems/'.rawurlencode($listItemId));
}


/**
* get checklist items from a checklist
* @link https://trello.readme.io/v1.0/reference#checklistsidcardscheckitems
*
* @param string $checkListId the checklist's id
* @param string $listItemId (optional) the listItem id
* @param array $fields (options) the fields to retrieve
*
* @return array
*/
public function getListItems($checkListId, array $fields = array('fields' => 'all'))
{
return $this->get($this->getPath().'/'.rawurlencode($checkListId).'/checkItems', $fields);
}

/**
* get a specific checklist item from a checklist
* @link https://trello.readme.io/v1.0/reference#checklistsidcardscheckitems
*
* @param string $checkListId the checklist's id
* @param string $listItemId the listItem id
* @param array $fields (options) the fields to retrieve
*
* @return array
*/
public function getListItem($checkListId, $listItemId, array $fields = array('fields' => 'all'))
{
return $this->get($this->getPath().'/'.rawurlencode($checkListId).'/checkItem/'.rawurlencode($listItemId), $fields);
}

/**
* Get the board of a given checklist
* @link https://trello.com/docs/api/checklist/#get-1-checklists-idchecklist-board
Expand Down

0 comments on commit 505d1c7

Please sign in to comment.