create account

Tasks API implementation into the PHP Client for Makerlog by dehenne

View this thread on: hive.blogpeakd.comecency.com
· @dehenne · (edited)
$46.25
Tasks API implementation into the PHP Client for Makerlog
Tasks API implementation into the PHP Client for Makerlog
------

<center>
![PHP Client for Makerlog](https://github.com/pcsg/pcsg-makerlog-php-client/raw/master/makerlog-php-client.png)
</center>

In my spare time I build a PHP client for Makerlog. Makerlog is the dead-simple task log that helps you stay productive and ship faster. There you can meet other makers and share your progress.

At the moment there is no PHP client, so I decided to change this a few weeks ago.
Today I integrated the basic Task API into the client.

#### Repository

- https://github.com/pcsg/pcsg-makerlog-php-client
- Licence: GPL-3.0+

### New Features
- What feature(s) did you add?

Almost the complete Task API

- How did you implement it/them?

The implementation is done with the following commits

- [feat: new sync method; feat: started new Task Object; feat: /issues/4](https://github.com/pcsg/pcsg-makerlog-php-client/commit/4b8447f043478549482432e3d8a7b1794dcf5856)
- [feat: create tasks](https://github.com/pcsg/pcsg-makerlog-php-client/commit/4d53aeca0b9aa80f18ce86f1444bc8aeae026463)
- [feat: delete a task](https://github.com/pcsg/pcsg-makerlog-php-client/commit/d5c630bcff2c6b0e44bf58f98a559bcbcb68976f)
- [feat: getter and task data integrated](https://github.com/pcsg/pcsg-makerlog-php-client/commit/c1936dd9fc0cbaea65e3b5be38474d6720ef9b24)

In addition, I have written a basic documentation so that you can use it.

- [docs: task doku](https://github.com/pcsg/pcsg-makerlog-php-client/commit/4e48bb8f7dfadc936a652136202d3c2e805ba5bc)
- [docs: create a new task](https://github.com/pcsg/pcsg-makerlog-php-client/commit/0a6ce184dacf91a2f0eddab73e230b34f46bdfb0)

Since documentation is more important to most people than the implementation of the client. Let me give you an overview how to use the client.

- Basically there is a central `Tasks` object which can be used to get Tasks and which can be used to create Tasks.
- Additionally there is the single `Task`.

###### How to get the main Tasks Object

The main Tasks object is directly available via the makerlog client

```
<?php

use PCSG\Makerlog\Makerlog;

$Makerlog = new Makerlog([
    'client_id'     => 'YOUR_CLIENT_ID',
    'client_secret' => 'YOUR_CLIENT_SECRET',
    'access_token'  => 'ACCESS_TOKEN_FROM_THE_USER'
]);

$Tasks = $Makerlog->getTasks();
```

###### Create a Task

To create a new task, you must use the tasks object.

*For the sake of simplicity I assume that the makerlog object is already instantiated and in my examples I won't do that again.*

```
<?php
$Makerlog->getTasks()->createTask('COUR CONTENT', $options);
```

The options of a task are optional but can have the following values:

```
<?php

$options = [
    "done"        => false, // bool
    "in_progress" => false  // bool
];
```

###### Get tasks

Returns a list of all tasks in Makerlog.

```
<?php

$list = $Makerlog->getTasks()->getList();
```

###### Get a task

A single task can be received via its id

```
<?php

$task = $Makerlog->getTasks()->get(892); // get task via ID
```

With a normal task which has been received via get(), no operations can be executed. If you want to change the task, you should get a task object. This can be done via getTaskAsObject().

```
<?php

$Task = $Makerlog->getTasks()->getTaskAsObject(892); // get task via ID

// delete the task
$Task->delete();

// praise the task
$Task->praise(100);
```

A task object has several getter methods, so it is quite easy to access the data of the task.

```
<?php

$Task = $Makerlog->getTasks()->getTaskAsObject(892); // get task via ID

// main data
$Task->getId();
$Task->getContent();

// dates
$Task->getCreationDate();
$Task->getDoneDate();
$Task->getLastUpdateDate();

$Task->getCommentCount();

// is methods
$Task->isDone();         // returns true if the task is done
$Task->isInProgress();   // returns true if the task is in progress
```

#### GitHub Account

- https://github.com/dehenne


Makerlog and the client itself is still at the beginning. Many functions are still missing. But if you want to use the client, you can have a look at the [examples](https://github.com/pcsg/pcsg-makerlog-php-client/tree/master/examples).

With the changes and features of today it is now possible to create, delete tasks, praise other tasks and read tasks. :-)
Have fun in Makerlog and thanks for reading,
Hen
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 81 others
properties (23)
authordehenne
permlinktasks-api-implementation-into-the-php-client-for-makerlog
categoryutopian-io
json_metadata{"tags":["utopian-io","development"],"image":["https://github.com/pcsg/pcsg-makerlog-php-client/raw/master/makerlog-php-client.png"],"links":["https://github.com/pcsg/pcsg-makerlog-php-client","https://github.com/pcsg/pcsg-makerlog-php-client/commit/4b8447f043478549482432e3d8a7b1794dcf5856","https://github.com/pcsg/pcsg-makerlog-php-client/commit/4d53aeca0b9aa80f18ce86f1444bc8aeae026463","https://github.com/pcsg/pcsg-makerlog-php-client/commit/d5c630bcff2c6b0e44bf58f98a559bcbcb68976f","https://github.com/pcsg/pcsg-makerlog-php-client/commit/c1936dd9fc0cbaea65e3b5be38474d6720ef9b24","https://github.com/pcsg/pcsg-makerlog-php-client/commit/4e48bb8f7dfadc936a652136202d3c2e805ba5bc","https://github.com/pcsg/pcsg-makerlog-php-client/commit/0a6ce184dacf91a2f0eddab73e230b34f46bdfb0","https://github.com/dehenne","https://github.com/pcsg/pcsg-makerlog-php-client/tree/master/examples"],"app":"steemit/0.1","format":"markdown"}
created2019-03-09 15:30:21
last_update2019-03-09 15:36:03
depth0
children6
last_payout2019-03-16 15:30:21
cashout_time1969-12-31 23:59:59
total_payout_value35.044 HBD
curator_payout_value11.208 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,342
author_reputation8,032,043,781,732
root_title"Tasks API implementation into the PHP Client for Makerlog"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id80,970,285
net_rshares64,929,736,942,612
author_curate_reward""
vote details (145)
@justyy ·
$12.66
Thank you for your contribution.

1. The build is failing on the github page.
2. It would be nice to have some unit tests to cover the new classes you added.
3. The `refresh()` is actually clearing the caching (doesn't do what exactly it says), it would be better to move (or re-organise) the correct logics e.g the code in `getTaskdata` into this function.
4. Often, the chainning such as `$this->Makerlog->getRequest()->get('/tasks/sync/');` is a code smell, because something may be null in the middle, try to have `if null` check, then throw exception accordingly.

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/2-2-2-2-2-2-1-).

---- 
Need help? Chat with us on [Discord](https://discord.gg/uTyJkNm).

[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorjustyy
permlinkre-dehenne-tasks-api-implementation-into-the-php-client-for-makerlog-20190309t210027955z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/3/2-2-2-2-2-2-1-","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2019-03-09 21:00:30
last_update2019-03-09 21:00:30
depth1
children2
last_payout2019-03-16 21:00:30
cashout_time1969-12-31 23:59:59
total_payout_value9.620 HBD
curator_payout_value3.043 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,018
author_reputation280,616,224,641,976
root_title"Tasks API implementation into the PHP Client for Makerlog"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id80,981,223
net_rshares17,927,792,910,688
author_curate_reward""
vote details (22)
@dehenne · (edited)
> The build is failing on the github page.

yes, there is an issue for that. it's an issue with travis-ci and i have no solution at the moment :(

> The refresh() is actually clearing the caching (doesn't do what exactly it says), it would be better to move (or re-organise) the correct logics e.g the code in getTaskdata into this function.

good argument. I will take to heart
oh, and thanks for the improvement suggestions
properties (22)
authordehenne
permlinkre-justyy-re-dehenne-tasks-api-implementation-into-the-php-client-for-makerlog-20190310t160303178z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2019-03-10 16:03:03
last_update2019-03-10 16:03:42
depth2
children0
last_payout2019-03-17 16:03:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length425
author_reputation8,032,043,781,732
root_title"Tasks API implementation into the PHP Client for Makerlog"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id81,021,031
net_rshares0
@utopian-io ·
Thank you for your review, @justyy! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-dehenne-tasks-api-implementation-into-the-php-client-for-makerlog-20190309t210027955z-20190312t035706z
categoryutopian-io
json_metadata"{"app": "beem/0.20.17"}"
created2019-03-12 03:57:09
last_update2019-03-12 03:57:09
depth2
children0
last_payout2019-03-19 03:57:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length58
author_reputation152,955,367,999,756
root_title"Tasks API implementation into the PHP Client for Makerlog"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id81,111,569
net_rshares0
@steem-ua ·
#### Hi @dehenne!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-tasks-api-implementation-into-the-php-client-for-makerlog-20190309t212834z
categoryutopian-io
json_metadata"{"app": "beem/0.20.18"}"
created2019-03-09 21:28:36
last_update2019-03-09 21:28:36
depth1
children0
last_payout2019-03-16 21:28:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length286
author_reputation23,214,230,978,060
root_title"Tasks API implementation into the PHP Client for Makerlog"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id80,982,057
net_rshares0
@steem-ua ·
#### Hi @dehenne!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-tasks-api-implementation-into-the-php-client-for-makerlog-20190309t213404z
categoryutopian-io
json_metadata"{"app": "beem/0.20.18"}"
created2019-03-09 21:34:06
last_update2019-03-09 21:34:06
depth1
children0
last_payout2019-03-16 21:34:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length286
author_reputation23,214,230,978,060
root_title"Tasks API implementation into the PHP Client for Makerlog"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id80,982,243
net_rshares0
@utopian-io ·
Hey, @dehenne!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-tasks-api-implementation-into-the-php-client-for-makerlog-20190311t015959z
categoryutopian-io
json_metadata"{"app": "beem/0.20.17"}"
created2019-03-11 02:00:00
last_update2019-03-11 02:00:00
depth1
children0
last_payout2019-03-18 02:00:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length589
author_reputation152,955,367,999,756
root_title"Tasks API implementation into the PHP Client for Makerlog"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id81,043,277
net_rshares0