Skip to content

Commit

Permalink
Merge pull request #28 from stevenmaguire/sm-add-custom-fields
Browse files Browse the repository at this point in the history
Add custom fields support
  • Loading branch information
stevenmaguire authored Mar 23, 2018
2 parents 18e4a44 + 233b953 commit 984e43f
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 0 deletions.
39 changes: 39 additions & 0 deletions API-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ $result = $client->updateBoardLabelNameRed($boardId, $attributes);
```php
$result = $client->updateBoardLabelNameYellow($boardId, $attributes);
```

#### Get board custom fields

```php
$result = $client->getBoardCustomFields($boardId);
```

#### Get board labels

```php
Expand Down Expand Up @@ -600,6 +607,13 @@ $result = $client->addCardChecklist($cardId, $attributes);
```php
$result = $client->deleteCardChecklist($cardId, $checklistId);
```

#### Update card custom field

```php
$result = $client->updateCardCustomField($cardId, $customFieldId, $attributes);
```

#### Update card closed

```php
Expand Down Expand Up @@ -828,6 +842,31 @@ $result = $client->updateChecklistName($checklistId, $attributes);
```php
$result = $client->updateChecklistPos($checklistId, $attributes);
```
### CustomFields

#### Create custom field

```php
$result = $client->addCustomField($attributes);
```

#### Add option to a custom field

```php
$result = $client->addCustomFieldOption($customFieldId, $attributes);
```

#### Update custom field option

```php
$result = $client->updateCustomFieldOption($customFieldId, $optionId, $attributes);
```

#### Delete custom field

```php
$result = $client->deleteCustomField($customFieldId);
```

### Labels

Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#Changelog

All Notable changes to `trello-php` will be documented in this file

## 0.5.0 - 2018-03-23

### Added
- Added support for custom fields - https://developers.trello.com/docs/getting-started-custom-fields

### Deprecated
- Nothing

### Fixed
- Nothing

### Removed
- Nothing

### Security
- Nothing

## 0.4.1 - 2017-03-22

### Added
Expand Down
6 changes: 6 additions & 0 deletions src/Traits/ApiMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ trait ApiMethodsTrait
'updateBoardLabelNamePurple' => ['put', 'boards/%s/labelNames/purple'],
'updateBoardLabelNameRed' => ['put', 'boards/%s/labelNames/red'],
'updateBoardLabelNameYellow' => ['put', 'boards/%s/labelNames/yellow'],
'getBoardCustomFields' => ['get', 'boards/%s/customFields'],
'getBoardLabels' => ['get', 'boards/%s/labels'],
'addBoardLabel' => ['post', 'boards/%s/labels'],
'getBoardLabel' => ['get', 'boards/%s/labels/%s'],
Expand Down Expand Up @@ -139,6 +140,7 @@ trait ApiMethodsTrait
'addCardLabel' => ['post', 'cards/%s/labels'],
'updateCardLabel' => ['put', 'cards/%s/labels'],
'deleteCardLabel' => ['delete', 'cards/%s/labels/%s'],
'updateCardCustomField' => ['put', 'cards/%s/customField/%s'],
'getCardList' => ['get', 'cards/%s/list'],
'getCardListField' => ['get', 'cards/%s/list/%s'],
'addCardMarkAssociatedNotificationsRead' => ['post', 'cards/%s/markAssociatedNotificationsRead'],
Expand Down Expand Up @@ -170,6 +172,10 @@ trait ApiMethodsTrait
'updateChecklistIdCard' => ['put', 'checklists/%s/idCard'],
'updateChecklistName' => ['put', 'checklists/%s/name'],
'updateChecklistPos' => ['put', 'checklists/%s/pos'],
'addCustomField' => ['post', 'customFields'],
'addCustomFieldOption' => ['post', 'customField/%s/options'],
'updateCustomFieldOption' => ['put', 'customField/%s/options/%s'],
'deleteCustomField' => ['delete', 'customField/%s'],
'addLabel' => ['post', 'labels'],
'deleteLabel' => ['delete', 'labels/%s'],
'getLabel' => ['get', 'labels/%s'],
Expand Down
72 changes: 72 additions & 0 deletions tests/ApiTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,17 @@ public function testUpdateBoardLabelNameYellow()
$this->assertExpectedEqualsResult($payload, $result);
}

public function testGetBoardCustomFields()
{
$boardId = $this->getTestString();
$payload = $this->getSuccessPayload();
$this->prepareFor("GET", sprintf("/boards/%s/customFields", $boardId), "", $payload);

$result = $this->client->getBoardCustomFields($boardId);

$this->assertExpectedEqualsResult($payload, $result);
}

public function testGetBoardLabels()
{
$boardId = $this->getTestString();
Expand Down Expand Up @@ -1308,6 +1319,19 @@ public function testDeleteCardChecklistCheckItem()
$this->assertExpectedEqualsResult($payload, $result);
}

public function testUpdateCardCustomField()
{
$cardId = $this->getTestString();
$customFieldId = $this->getTestString();
$attributes = $this->getTestAttributes();
$payload = $this->getSuccessPayload();
$this->prepareFor("PUT", sprintf("/cards/%s/customField/%s", $cardId, $customFieldId), "", $payload);

$result = $this->client->updateCardCustomField($cardId, $customFieldId, $attributes);

$this->assertExpectedEqualsResult($payload, $result);
}

public function testUpdateCardChecklistCheckItem()
{
$cardId = $this->getTestString();
Expand Down Expand Up @@ -1944,6 +1968,54 @@ public function testUpdateChecklistPos()
$this->assertExpectedEqualsResult($payload, $result);
}

public function testAddCustomField()
{
$attributes = $this->getTestAttributes();
$payload = $this->getSuccessPayload();
$this->prepareFor("POST", "/customFields", "", $payload);

$result = $this->client->addCustomField($attributes);

$this->assertExpectedEqualsResult($payload, $result);
}

public function testAddCustomFieldOption()
{
$customFieldId = $this->getTestString();
$attributes = $this->getTestAttributes();
$payload = $this->getSuccessPayload();
$this->prepareFor("POST", sprintf("/customField/%s/options", $customFieldId), "", $payload);

$result = $this->client->addCustomFieldOption($customFieldId, $attributes);

$this->assertExpectedEqualsResult($payload, $result);
}

public function testUpdateCustomFieldOption()
{
$customFieldId = $this->getTestString();
$optionId = $this->getTestString();
$attributes = $this->getTestAttributes();
$payload = $this->getSuccessPayload();
$this->prepareFor("PUT", sprintf("/customField/%s/options/%s", $customFieldId, $optionId), "", $payload);

$result = $this->client->updateCustomFieldOption($customFieldId, $optionId, $attributes);

$this->assertExpectedEqualsResult($payload, $result);
}

public function testDeleteCustomFieldOption()
{
$customFieldId = $this->getTestString();
$attributes = $this->getTestAttributes();
$payload = $this->getSuccessPayload();
$this->prepareFor("DELETE", sprintf("/customField/%s", $customFieldId), "", $payload);

$result = $this->client->deleteCustomField($customFieldId);

$this->assertExpectedEqualsResult($payload, $result);
}

public function testAddLabel()
{
$attributes = $this->getTestAttributes();
Expand Down

0 comments on commit 984e43f

Please sign in to comment.