Skip to content

Commit f570b53

Browse files
committed
massive code cleanup and attachments working
1 parent 5856873 commit f570b53

File tree

9 files changed

+432
-581
lines changed

9 files changed

+432
-581
lines changed

README.md

Lines changed: 18 additions & 279 deletions
Original file line numberDiff line numberDiff line change
@@ -1,294 +1,33 @@
1-
# Asana for Laravel 5
1+
# Asana for Laravel
22

3-
[![Latest Stable Version](https://poser.pugx.org/torann/laravel-asana/v/stable.png)](https://packagist.org/packages/torann/laravel-asana) [![Total Downloads](https://poser.pugx.org/torann/laravel-asana/downloads.png)](https://packagist.org/packages/torann/laravel-asana)
3+
[![Latest Stable Version](https://poser.pugx.org/torann/laravel-asana/v/stable.png)](https://packagist.org/packages/torann/laravel-asana)
4+
[![Total Downloads](https://poser.pugx.org/torann/laravel-asana/downloads.png)](https://packagist.org/packages/torann/laravel-asana)
5+
[![Patreon donate button](https://img.shields.io/badge/patreon-donate-yellow.svg)](https://www.patreon.com/torann)
6+
[![Donate weekly to this project using Gratipay](https://img.shields.io/badge/gratipay-donate-yellow.svg)](https://gratipay.com/~torann)
7+
[![Donate to this project using Flattr](https://img.shields.io/badge/flattr-donate-yellow.svg)](https://flattr.com/profile/torann)
8+
[![Donate to this project using Paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4CJA2A97NPYVU)
49

5-
----------
6-
7-
## Installation
10+
Asana API wrapper for Laravel, supporting workspaces, projects, tasks, tags, users and stories.
811

912
- [Laravel Asana on Packagist](https://packagist.org/packages/torann/laravel-asana)
1013
- [Laravel Asana on GitHub](https://github.com/torann/laravel-asana)
11-
- [Laravel 4 Installation](https://github.com/Torann/laravel-asana/tree/0.1.2)
12-
13-
### Composer
14-
15-
From the command line run:
16-
17-
```
18-
$ composer require torann/laravel-asana
19-
```
20-
21-
### Laravel
22-
23-
Once installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key.
24-
25-
``` php
26-
'providers' => [
27-
28-
\Torann\LaravelAsana\ServiceProvider::class,
29-
30-
]
31-
```
32-
33-
### Lumen
34-
35-
For Lumen register the service provider in `bootstrap/app.php`.
36-
37-
``` php
38-
$app->register(\Torann\LaravelAsana\ServiceProvider::class);
39-
```
40-
41-
### Facade
42-
43-
This package also ships with a facade which provides the static syntax for creating collections. You can register the facade in the aliases key of your `config/app.php` file.
44-
45-
```php
46-
'aliases' => [
47-
'Asana' => 'Torann\LaravelAsana\Facade',
48-
]
49-
```
50-
51-
### Publish the configurations
52-
53-
Run this on the command line from the root of your project:
54-
55-
```
56-
$ php artisan vendor:publish --provider="Torann\LaravelAsana\ServiceProvider"
57-
```
58-
59-
A configuration file will be publish to `config/asana.php`.
60-
61-
## Quick Examples
62-
63-
#### Get a specific user
64-
65-
```php
66-
Asana::getUserInfo($user_id);
67-
```
68-
69-
#### Get current user
70-
71-
Will return the user's info of the owner of the Personal Access Token.
72-
73-
```php
74-
Asana::getCurrentUser();
75-
```
76-
77-
#### Get all users in all workspaces
78-
79-
Will return the user's info of the owner of the Personal Access Token.
80-
81-
```php
82-
Asana::getUsers();
83-
```
84-
85-
#### Get task
86-
87-
```php
88-
Asana::getTask($task_id);
89-
```
90-
91-
#### Get a task's sub-tasks
92-
93-
```php
94-
Asana::getSubTasks($task_id);
95-
```
96-
97-
#### Creating a task
98-
99-
```php
100-
Asana::createTask([
101-
'workspace' => '176825', // Workspace ID
102-
'name' => 'Hello World!', // Name of task
103-
'assignee' => '[email protected]', // Assign task to...
104-
'followers' => ['3714136', '5900783'] // We add some followers to the task... (this time by ID)
105-
]);
106-
```
107-
108-
#### Delete a task
109-
110-
```php
111-
Asana::deleteTask($task_id);
112-
```
113-
114-
#### Adding task to project
115-
116-
```php
117-
Asana::addProjectToTask($task_id, $project_id);
118-
```
119-
120-
#### Remove task from a project
121-
122-
```php
123-
Asana::removeProjectToTask($task_id, $project_id);
124-
```
125-
126-
#### Get task stories
127-
128-
```php
129-
Asana::getTaskStories($task_id);
130-
```
131-
132-
#### Commenting on a task
133-
134-
```php
135-
Asana::commentOnTask($task_id, "Please please! Don't assign me this task!");
136-
```
137-
138-
#### Add a tag to a task
139-
140-
```php
141-
Asana::addTagToTask($task_id, $tag_id);
142-
```
14314

144-
#### Remove a tag from a task
15+
## Official Documentation
14516

146-
```php
147-
Asana::removeTagFromTask($task_id, $tag_id);
148-
```
17+
Documentation for the package can be found on [Lyften.com](http://lyften.com/projects/laravel-asana/).
14918

150-
#### Create a project
151-
152-
```php
153-
Asana::createProject([
154-
"workspace" => "1768",
155-
"name" => "Foo Project!",
156-
"notes" => "This is a test project"
157-
]);
158-
```
159-
160-
#### Getting projects in all workspaces
161-
162-
```php
163-
Asana::getProjects();
164-
```
165-
166-
#### Get projects in a workspace
167-
168-
```php
169-
$archived = false;
170-
171-
Asana::getProjectsInWorkspace($workspace_id, $archived);
172-
```
173-
174-
#### Updating project info
175-
176-
```php
177-
Asana::updateProject($project_id, [
178-
'name' => 'This is a new cool project!',
179-
'notes' => 'At first, it wasn't cool, but after this name change, it is!'
180-
]);
181-
```
182-
183-
#### Get project tasks
184-
185-
```php
186-
Asana::getProjectTasks($project_id);
187-
```
188-
189-
#### Get project stories
190-
191-
```php
192-
Asana::getProjectStories($project_id);
193-
```
194-
195-
#### Get a specific story
196-
197-
```php
198-
Asana::getSingleStory($story_id);
199-
```
200-
201-
#### Comment on a project
202-
203-
```php
204-
$text = "Such fun!";
205-
206-
Asana::commentOnProject($project_id, $text)
207-
```
208-
209-
#### Get a specific tag
210-
211-
```php
212-
Asana::getTag($tag_id);
213-
```
214-
215-
#### Get tags
216-
217-
```php
218-
Asana::getTags();
219-
```
220-
221-
#### Update tag
222-
223-
```php
224-
// $data - array - An array containing fields to update, see Asana API if needed.
225-
226-
Asana::updateTag($tag_id, $data);
227-
```
228-
229-
#### Get tasks with tag
230-
231-
```php
232-
Asana::getTasksWithTag($tag_id);
233-
```
234-
235-
#### Get workspaces
236-
237-
```php
238-
Asana::getWorkspaces();
239-
```
240-
241-
#### Update workspace
242-
243-
```php
244-
$data = ['name' => ''];
245-
246-
Asana::updateWorkspace($workspace_i, $data);
247-
```
248-
249-
#### Get workspace tasks
250-
251-
```php
252-
// Assignee can either be 'me' or a user's ID
253-
254-
Asana::getWorkspaceTasks($workspace_id, $assignee);
255-
```
256-
257-
#### Get workspace tags
258-
259-
```php
260-
Asana::getWorkspaceTags($workspace_id);
261-
```
262-
263-
#### Get workspace users
264-
265-
```php
266-
Asana::getWorkspaceUsers($workspace_id);
267-
```
268-
269-
#### Filtering
270-
271-
If you specify an assignee, you must also specify a workspace to filter on.
272-
273-
```php
274-
Asana::getTasksByFilter([
275-
'assignee' => 1121,
276-
'project' => 37373729,
277-
'workspace' => 111221
278-
]);
279-
```
280-
281-
## Upgrading
19+
## Change Log
28220

283-
### Upgrade from v0.2 to v0.3
21+
#### v0.4.0
28422

285-
Asana stopped supporting API keys, so now we must use a Personal Access Token. See Asana's directions for generating a [personal access tokens](https://asana.com/guide/help/api/api#gl-access-tokens). Then update the `config/asana.php` config file with the new token:
23+
- Added attachment
24+
- Code cleanup
25+
- Add helper function
28626

287-
```php
288-
'accessToken' => env('ASANA_TOKEN'),
289-
```
27+
#### v0.3.1
29028

291-
## Change Log
29+
- Fix big integers parsing
30+
- Fix `getTasksByFilter` ignoring filters beside the predefined ones
29231

29332
#### v0.3.0
29433

composer.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
{
22
"name": "torann/laravel-asana",
3-
"description": "Asna API wrapper for Laravel",
4-
"keywords": ["laravel", "asana", "laravel 5", "laravel 4"],
3+
"description": "Asana API wrapper for Laravel",
4+
"keywords": ["laravel", "asana", "laravel 5"],
55
"license": "BSD 2-Clause",
66
"authors": [
77
{
88
"name": "Daniel Stainback",
9-
"email": "daniel@lyften.com"
9+
"email": "torann@gmail.com"
1010
}
1111
],
1212
"require": {
1313
"php": ">=5.5.9",
14-
"illuminate/support": "~5.0",
15-
"illuminate/database": "~5.0"
14+
"illuminate/support": "~5.0"
1615
},
1716
"autoload": {
17+
"files": [
18+
"src/helpers.php"
19+
],
1820
"psr-4": {
19-
"Torann\\LaravelAsana\\": "src/Torann/LaravelAsana"
21+
"Torann\\LaravelAsana\\": "src/"
2022
}
2123
},
2224
"extra": {
2325
"branch-alias": {
24-
"dev-master": "0.3-dev"
26+
"dev-master": "0.4-dev"
2527
}
2628
}
2729
}
File renamed without changes.

src/Torann/LaravelAsana/Asana.php renamed to src/Asana.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function getUsers()
9696
* )
9797
* )
9898
*
99-
* @return string|null
99+
* @return object|null
100100
*/
101101
public function createTask($data)
102102
{
@@ -167,11 +167,9 @@ public function deleteTask($taskId)
167167
*/
168168
public function addTaskAttachment($taskId, $file)
169169
{
170-
$data = [
171-
'file' => $this->addPostFile($file)
172-
];
173-
174-
return $this->curl->post("tasks/{$taskId}/attachments", $data);
170+
return $this->curl->post("tasks/{$taskId}/attachments", [
171+
'file' => $file,
172+
]);
175173
}
176174

177175
/**
@@ -243,10 +241,10 @@ public function removeProjectToTask($taskId, $projectId = null)
243241
public function getTasksByFilter($filter = ["assignee" => "", "project" => "", "workspace" => ""])
244242
{
245243
$filter = array_filter(array_merge(["assignee" => "", "project" => "", "workspace" => ""], $filter));
246-
$url = '?' . join('&', array_map(function($k, $v){
247-
return "{$k}={$v}";
248-
}, array_keys($filter), $filter));
249-
244+
$url = '?' . join('&', array_map(function ($k, $v) {
245+
return "{$k}={$v}";
246+
}, array_keys($filter), $filter));
247+
250248
return $this->curl->get("tasks{$url}");
251249
}
252250

0 commit comments

Comments
 (0)