Skip to content

Commit 60a1e65

Browse files
authored
Merge pull request #1 from daryush/feature/custom-fields
Custom fields basic API support
2 parents e29933f + 6adf3e8 commit 60a1e65

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

lib/Trello/Api/Board.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,14 @@ public function powerUps()
336336
{
337337
return new Board\PowerUps($this->client);
338338
}
339+
340+
/**
341+
* Board CustomFields API
342+
*
343+
* @return Board\CustomFields
344+
*/
345+
public function customFields()
346+
{
347+
return new Board\CustomFields($this->client);
348+
}
339349
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Trello\Api\Board;
4+
5+
use Trello\Api\AbstractApi;
6+
7+
/**
8+
* Trello Board custom fields API
9+
* @link https://developers.trello.com/docs/getting-started-custom-fields
10+
*
11+
*/
12+
class CustomFields extends AbstractApi
13+
{
14+
/**
15+
* Base path of board custom fields api
16+
* @var string
17+
*/
18+
protected $path = 'boards/#id#/customFields';
19+
20+
/**
21+
* Get custom fields related to a given board
22+
* @link https://developers.trello.com/docs/getting-started-custom-fields#section-get-custom-fields-on-a-board
23+
*
24+
* @param string $id the board's
25+
* @param array $params optional parameters
26+
*
27+
* @return array
28+
*/
29+
public function all($id, array $params = array())
30+
{
31+
return $this->get($this->getPath($id), $params);
32+
}
33+
}

lib/Trello/Api/Card.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,4 +517,14 @@ public function stickers()
517517
{
518518
return new Card\Stickers($this->client);
519519
}
520+
521+
/**
522+
* CustomFieldItems API
523+
*
524+
* @return Card\CustomFieldItems
525+
*/
526+
public function customFieldItems()
527+
{
528+
return new Card\CustomFieldItems($this->client);
529+
}
520530
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Trello\Api\Card;
4+
5+
use Trello\Api\AbstractApi;
6+
7+
/**
8+
* Trello Card custom fields items API
9+
* @link https://developers.trello.com/docs/getting-started-custom-fields#section-custom-field-values-on-cards
10+
*
11+
*/
12+
class CustomFieldItems extends AbstractApi
13+
{
14+
/**
15+
* Base path of cards api
16+
* @var string
17+
*/
18+
protected $path = 'cards/#id#/';
19+
20+
/**
21+
* Get custom fiedls items related to a given card
22+
* @link https://developers.trello.com/docs/getting-started-custom-fields#section-getting-customfielditems-for-cards
23+
*
24+
* @param string $id the card's id or short link
25+
* @param array $params optional parameters
26+
*
27+
* @return array
28+
*/
29+
public function all($id, array $params = array())
30+
{
31+
$params = array_merge($params, array('customFieldItems' => 'true'));
32+
$data = $this->get($this->getPath($id), $params);
33+
34+
return array_key_exists('customFieldItems', $data) ? $data['customFieldItems'] : array();
35+
}
36+
}

0 commit comments

Comments
 (0)