Skip to content

Commit

Permalink
Merge 4079089 into 579530b
Browse files Browse the repository at this point in the history
  • Loading branch information
rtvisser committed Dec 10, 2019
2 parents 579530b + 4079089 commit 4303b71
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 9 deletions.
10 changes: 10 additions & 0 deletions lib/Trello/Api/Board.php
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
@@ -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
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
193 changes: 189 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 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
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));
}
}

0 comments on commit 4303b71

Please sign in to comment.