Skip to content

Commit 9e3906a

Browse files
committed
Removed ramsey/uuid and replaced it with a simple method.
1 parent 7aec56c commit 9e3906a

File tree

7 files changed

+32
-141
lines changed

7 files changed

+32
-141
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 0.3.1 - 2017-11-11
5+
### Changed
6+
- Removed ramsey/uuid.
7+
48
## 0.3.0 - 2017-11-11
59
### Added
610
- Implemented all the Labels endpoints.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Todoist SDK for PHP — An unofficial Todoist API library**This repository contains the open source PHP SDK which allows you to access the Todoist API from your PHP application.**[![GitHub tag](https://img.shields.io/github/tag/FabianBeiner/Todoist-PHP-SDK.svg)](https://github.com/FabianBeiner/Todoist-PHP-SDK/tags) * [![GitHub stars](https://img.shields.io/github/stars/FabianBeiner/Todoist-PHP-SDK.svg)](https://github.com/FabianBeiner/Todoist-PHP-SDK/stargazers) * [![GitHub issues](https://img.shields.io/github/issues/FabianBeiner/Todoist-PHP-SDK.svg)](https://github.com/FabianBeiner/Todoist-PHP-SDK/issues) * [![GitHub license](https://img.shields.io/github/license/FabianBeiner/Todoist-PHP-SDK.svg)](https://github.com/FabianBeiner/Todoist-PHP-SDK/blob/master/LICENSE) * [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a8cad853a2b041a896753b4dda5659ad)](https://www.codacy.com/app/FabianBeiner/Todoist-PHP-SDK?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=FabianBeiner/Todoist-PHP-SDK&amp;utm_campaign=Badge_Grade)## Requirements- PHP: 5.5+- guzzlehttp/guzzle: 6.3+- ramsey/uuid: 3.7+## InstallationThe Todoist SDK for PHP can be installed with [Composer](https://getcomposer.org/). Run this command:```bashcomposer require fabian-beiner/todoist-php-sdk```## Obtaining your personal API tokenOpen the [Todoist web app](https://todoist.com), click on the gear icon, select “Settings”, then “Integrations”. Your API token is visible on the bottom of this page.## Usage```php<?phprequire __DIR__ . '/vendor/autoload.php';$Todoist = new FabianBeiner\Todoist\Todoist('YOUR_API_TOKEN');```## Methods & Examples### Get all projects```php$allProjects = $Todoist->getAllProjects();``````print_r($allProjects);( [0] => stdClass Object ( [id] => 123456789 [name] => Inbox [order] => 0 [indent] => 1 [comment_count] => 0 ) [1] => stdClass Object ( [id] => 987654321 [name] => Project [order] => 1 [indent] => 1 [comment_count] => 0 ))```### Create a new project```php$createProject = $Todoist->createProject('Example Project');``````print_r($createProject);stdClass Object( [id] => 123454321 [name] => Example Project [order] => 2 [indent] => 1 [comment_count] => 0)```### Get a project```php$project = $Todoist->getProject('123454321');``````print_r($project);stdClass Object( [id] => 123454321 [name] => Example Project [order] => 2 [indent] => 1 [comment_count] => 0)```### Update (actually rename…) a project```php$Todoist->updateProject('123454321', 'New Project Name');``````print_r($Todoist->updateProject('123454321', 'New Project Name'));1```### Delete a project```php$Todoist->deleteProject('123454321');``````print_r($Todoist->deleteProject('123454321'));1```### Get all labels```php$allLabels = $Todoist->getAllLabels();``````print_r($allLabels);( [0] => stdClass Object ( [id] => 12121212 [name] => LabelName [order] => 1 ) [1] => stdClass Object ( [id] => 34343434 [name] => Another_Label [order] => 2 ))```### Create a new label```php$createLabel = $Todoist->createLabel('Example Label');``````print_r($createLabel);stdClass Object( [id] => 555888999 [name] => Example_Label [order] => 3)```### Get a label```php$label = $Todoist->getLabel('555888999');``````print_r($project);print_r($label);stdClass Object( [id] => 555888999 [name] => Example_Label [order] => 3)```### Update (actually rename…) a label```php$Todoist->updateProject('555888999', 'New Label Name');``````print_r($Todoist->renameLabel('555888999', 'New Label Name'));1```### Delete a label```php$Todoist->deleteLabel('555888999');``````print_r($Todoist->deleteLabel('555888999'));1```## ContributingI’d be happy if you contribute to this library. Please try to follow theexisting coding style and use proper comments in your commit message.
1+
# Todoist SDK for PHP — An unofficial Todoist API library**This repository contains the open source PHP SDK which allows you to access the Todoist API from your PHP application.**[![GitHub tag](https://img.shields.io/github/tag/FabianBeiner/Todoist-PHP-SDK.svg)](https://github.com/FabianBeiner/Todoist-PHP-SDK/tags) * [![GitHub stars](https://img.shields.io/github/stars/FabianBeiner/Todoist-PHP-SDK.svg)](https://github.com/FabianBeiner/Todoist-PHP-SDK/stargazers) * [![GitHub issues](https://img.shields.io/github/issues/FabianBeiner/Todoist-PHP-SDK.svg)](https://github.com/FabianBeiner/Todoist-PHP-SDK/issues) * [![GitHub license](https://img.shields.io/github/license/FabianBeiner/Todoist-PHP-SDK.svg)](https://github.com/FabianBeiner/Todoist-PHP-SDK/blob/master/LICENSE) * [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a8cad853a2b041a896753b4dda5659ad)](https://www.codacy.com/app/FabianBeiner/Todoist-PHP-SDK?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=FabianBeiner/Todoist-PHP-SDK&amp;utm_campaign=Badge_Grade)## Requirements- PHP: 5.5+- guzzlehttp/guzzle: 6.3+## InstallationThe Todoist SDK for PHP can be installed with [Composer](https://getcomposer.org/). Run this command:```bashcomposer require fabian-beiner/todoist-php-sdk```## Obtaining your personal API tokenOpen the [Todoist web app](https://todoist.com), click on the gear icon, select “Settings”, then “Integrations”. Your API token is visible on the bottom of this page.## Usage```php<?phprequire __DIR__ . '/vendor/autoload.php';$Todoist = new FabianBeiner\Todoist\Todoist('YOUR_API_TOKEN');```## Methods & Examples### Get all projects```php$allProjects = $Todoist->getAllProjects();``````print_r($allProjects);( [0] => stdClass Object ( [id] => 123456789 [name] => Inbox [order] => 0 [indent] => 1 [comment_count] => 0 ) [1] => stdClass Object ( [id] => 987654321 [name] => Project [order] => 1 [indent] => 1 [comment_count] => 0 ))```### Create a new project```php$createProject = $Todoist->createProject('Example Project');``````print_r($createProject);stdClass Object( [id] => 123454321 [name] => Example Project [order] => 2 [indent] => 1 [comment_count] => 0)```### Get a project```php$project = $Todoist->getProject('123454321');``````print_r($project);stdClass Object( [id] => 123454321 [name] => Example Project [order] => 2 [indent] => 1 [comment_count] => 0)```### Update (actually rename…) a project```php$Todoist->updateProject('123454321', 'New Project Name');``````print_r($Todoist->updateProject('123454321', 'New Project Name'));1```### Delete a project```php$Todoist->deleteProject('123454321');``````print_r($Todoist->deleteProject('123454321'));1```### Get all labels```php$allLabels = $Todoist->getAllLabels();``````print_r($allLabels);( [0] => stdClass Object ( [id] => 12121212 [name] => LabelName [order] => 1 ) [1] => stdClass Object ( [id] => 34343434 [name] => Another_Label [order] => 2 ))```### Create a new label```php$createLabel = $Todoist->createLabel('Example Label');``````print_r($createLabel);stdClass Object( [id] => 555888999 [name] => Example_Label [order] => 3)```### Get a label```php$label = $Todoist->getLabel('555888999');``````print_r($project);print_r($label);stdClass Object( [id] => 555888999 [name] => Example_Label [order] => 3)```### Update (actually rename…) a label```php$Todoist->updateProject('555888999', 'New Label Name');``````print_r($Todoist->renameLabel('555888999', 'New Label Name'));1```### Delete a label```php$Todoist->deleteLabel('555888999');``````print_r($Todoist->deleteLabel('555888999'));1```## ContributingI’d be happy if you contribute to this library. Please try to follow theexisting coding style and use proper comments in your commit message.

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"license": "MIT",
1414
"require": {
1515
"guzzlehttp/guzzle": "~6.3.0",
16-
"php": ">=5.5",
17-
"ramsey/uuid": "^3.7"
16+
"php": ">=5.5"
1817
},
1918
"authors": [
2019
{

composer.lock

Lines changed: 1 addition & 131 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/FabianBeiner/Todoist/Todoist.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
* @author Fabian Beiner (fb@fabianbeiner.de)
99
* @link https://fabianbeiner.de
1010
* @license MIT License
11-
* @version 0.3.0 (2017-11-11)
11+
* @version 0.3.1 (2017-11-11)
1212
*/
1313

1414
namespace FabianBeiner\Todoist;
1515

1616
use GuzzleHttp\Client;
17-
use GuzzleHttp\RequestOptions;
18-
use Ramsey\Uuid\Uuid;
1917

2018
class Todoist
2119
{
@@ -69,4 +67,24 @@ public function __construct($apiToken)
6967
'timeout' => 5
7068
]);
7169
}
70+
71+
/**
72+
* Generate a GUID v4 string.
73+
*
74+
* @author Pavel Volyntsev <pavel.volyntsev@gmail.com>
75+
* @see http://php.net/manual/en/function.com-create-guid.php#117893
76+
* @return string GUID v4 string.
77+
*/
78+
private function guidv4()
79+
{
80+
if (function_exists('com_create_guid') === true) {
81+
return trim(com_create_guid(), '{}');
82+
}
83+
84+
$data = openssl_random_pseudo_bytes(16);
85+
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
86+
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
87+
88+
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
89+
}
7290
}

src/FabianBeiner/Todoist/TodoistLabels.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function createLabel($name)
6868

6969
$result = $this->client->post('labels?' . $this->tokenQuery, [
7070
RequestOptions::JSON => ['name' => trim($name)],
71-
'X-Request-Id' => Uuid::uuid4()
71+
'X-Request-Id' => $this->guidv4()
7272
]);
7373
$status = $result->getStatusCode();
7474

@@ -129,7 +129,7 @@ public function updateLabel($labelId, $name)
129129

130130
$result = $this->client->post('labels/' . $labelId . '?' . $this->tokenQuery, [
131131
RequestOptions::JSON => ['name' => trim($name)],
132-
'X-Request-Id' => Uuid::uuid4()
132+
'X-Request-Id' => $this->guidv4()
133133
]);
134134
$status = $result->getStatusCode();
135135

src/FabianBeiner/Todoist/TodoistProjects.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function createProject($name)
6868

6969
$result = $this->client->post('projects?' . $this->tokenQuery, [
7070
RequestOptions::JSON => ['name' => trim($name)],
71-
'X-Request-Id' => Uuid::uuid4()
71+
'X-Request-Id' => $this->guidv4()
7272
]);
7373
$status = $result->getStatusCode();
7474

@@ -129,7 +129,7 @@ public function updateProject($projectId, $name)
129129

130130
$result = $this->client->post('projects/' . $projectId . '?' . $this->tokenQuery, [
131131
RequestOptions::JSON => ['name' => trim($name)],
132-
'X-Request-Id' => Uuid::uuid4()
132+
'X-Request-Id' => $this->guidv4()
133133
]);
134134
$status = $result->getStatusCode();
135135

0 commit comments

Comments
 (0)