Skip to content

Commit

Permalink
Code cleaning and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoriohc committed Feb 5, 2016
1 parent 2da7cb6 commit 766e891
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/.idea/
/vendor/
composer.phar
composer.lock

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Laravel 5 Trello API wrapper

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/gregoriohc/laravel-trello/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/gregoriohc/laravel-trello/?branch=master)

A simple Laravel 5 package that wraps [Trello](https://trello.com) API.

## Requirements
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gregoriohc/laravel-trello",
"description": "A Laravel wrapper and facade package for the Trello API",
"keywords": [],
"keywords": ["laravel", "package", "facade", "trello", "api"],
"homepage": "https://github.com/gregoriohc/laravel-trello",
"license": "MIT",
"authors": [
Expand Down
Empty file removed config/.gitkeep
Empty file.
Empty file removed src/.gitkeep
Empty file.
28 changes: 22 additions & 6 deletions src/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,12 @@ class Wrapper
*/
public function __construct(Repository $config)
{
// Fetch the config data and set up the required url´s
// Get the config data
$this->config = $config;

// Retrieve the configuration variables
$apiKey = $this->config->get('trello.api_key');
$apiToken = $this->config->get('trello.api_token');

// Make the client instance
$this->client = new Client();
$this->client->authenticate($apiKey, $apiToken, Client::AUTH_URL_CLIENT_ID);
$this->client->authenticate($this->config->get('trello.api_key'), $this->config->get('trello.api_token'), Client::AUTH_URL_CLIENT_ID);
}

/**
Expand Down Expand Up @@ -135,6 +131,26 @@ public function getObjectId($type, $name, $options = [])
}
}

break;
case 'label':
if (!isset($options['organization'])) {
$options['organization'] = $this->config->get('trello.organization');
}
if (!isset($options['board'])) {
$options['board'] = $this->config->get('trello.board');
}

$boardId = $this->getObjectId('board', $options['board'], ['organization' => $options['organization']]);
if (!isset($this->cache['labels'][$boardId])) {
$this->cache['labels'][$boardId] = $this->api('board')->labels()->all($boardId);
}

foreach ($this->cache['labels'][$boardId] as $item) {
if ($name == $item['name']) {
return $item['id'];
}
}

break;
}

Expand Down

0 comments on commit 766e891

Please sign in to comment.