Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Add Folder functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
johnRivs committed Aug 25, 2015
1 parent 3933d8e commit 4caad62
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the latest Wunderlist API version in your apps.
[![Latest Stable Version](https://poser.pugx.org/johnrivs/wunderlist/v/stable)](https://packagist.org/packages/johnrivs/wunderlist) [![Total Downloads](https://poser.pugx.org/johnrivs/wunderlist/downloads)](https://packagist.org/packages/johnrivs/wunderlist) [![License](https://poser.pugx.org/johnrivs/wunderlist/license)](https://packagist.org/packages/johnrivs/wunderlist) [![Endpoint coverage](http://progressed.io/bar/63?title=progress)](#progress )
[![Latest Stable Version](https://poser.pugx.org/johnrivs/wunderlist/v/stable)](https://packagist.org/packages/johnrivs/wunderlist) [![Total Downloads](https://poser.pugx.org/johnrivs/wunderlist/downloads)](https://packagist.org/packages/johnrivs/wunderlist) [![License](https://poser.pugx.org/johnrivs/wunderlist/license)](https://packagist.org/packages/johnrivs/wunderlist) [![Endpoint coverage](http://progressed.io/bar/72?title=progress)](#progress )

[http://johnrivs.github.io/wunderlist](http://johnrivs.github.io/wunderlist )

Expand Down Expand Up @@ -124,13 +124,6 @@ Make sure the auth callback URL you provide to `authUrl()` matches the one you h
Well.. at the time of this writing, the Wunderlist API isn't too helpful when it comes to error messages, so make sure you stick to the docs, use `getStatusCode()` and ask any questions in the docs comment section.

#### Progress
- Folder
- ~~Get all folders~~
- ~~Get a folder~~
- Create a folder
- Update a folder
- Delete a folder
- ~~Get folder revisions~~
- Reminder
- ~~Get all reminders~~
- Create a reminder
Expand All @@ -143,6 +136,7 @@ Well.. at the time of this writing, the Wunderlist API isn't too helpful when it
Finished:
- Authorization
- Avatar
- Folder
- Lists
- Note
- Subtask
Expand Down
54 changes: 50 additions & 4 deletions src/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ trait Folder {

/**
* Show all the folders a user has access to.
*
*
* @return array
*/
public function getFolders()
Expand All @@ -14,7 +14,7 @@ public function getFolders()

/**
* Show a folder.
*
*
* @param int $folderId The id of the list.
* @return array
*/
Expand All @@ -23,14 +23,60 @@ public function getFolder($folderId)
return $this->call('GET', "folders/{$folderId}");
}

/**
* Create a folder.
*
* @param array $attributes
* @return array
*/
public function createFolder(array $attributes = [])
{
$this->requires(['title', 'list_ids'], $attributes);

return $this->call('POST', 'folders', ['json' => $attributes]);
}

/**
* Update a folder.
*
* @param int $folderId The id of the folder.
* @param array $attributes
* @return array
*/
public function updateFolder($folderId, array $attributes = [])
{
$attributes['revision'] = $this->getFolder($folderId)['revision'];

$this->requires(['revision'], $attributes);

return $this->call('PATCH', "folders/{$folderId}", ['json' => $attributes]);
}

/**
* Delete a folder.
*
* @param int $folderId The id of the folder.
* @return array
*/
public function deleteFolder($folderId)
{
$attributes['revision'] = $this->getFolder($folderId)['revision'];

$this->requires(['revision'], $attributes);

$this->call('DELETE', "folders/{$folderId}", ['query' => $attributes]);

return $this->getStatusCode();
}

/**
* Show the revision for each folder.
*
*
* @return array
*/
public function getFolderRevisions()
{
return $this->call('GET', "folder_revisions");
}

}

0 comments on commit 4caad62

Please sign in to comment.