Tasks API implementation into the PHP Client for Makerlog

in #utopian-io6 years ago (edited)

Tasks API implementation into the PHP Client for Makerlog

<p dir="auto"><center><br /> <img src="https://images.hive.blog/768x0/https://github.com/pcsg/pcsg-makerlog-php-client/raw/master/makerlog-php-client.png" alt="PHP Client for Makerlog" srcset="https://images.hive.blog/768x0/https://github.com/pcsg/pcsg-makerlog-php-client/raw/master/makerlog-php-client.png 1x, https://images.hive.blog/1536x0/https://github.com/pcsg/pcsg-makerlog-php-client/raw/master/makerlog-php-client.png 2x" /><br /> <p dir="auto">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. <p dir="auto">At the moment there is no PHP client, so I decided to change this a few weeks ago.<br /> Today I integrated the basic Task API into the client. <h4>Repository <ul> <li><span><a href="https://github.com/pcsg/pcsg-makerlog-php-client" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/pcsg/pcsg-makerlog-php-client <li>Licence: GPL-3.0+ <h3>New Features <ul> <li>What feature(s) did you add? <p dir="auto">Almost the complete Task API <ul> <li>How did you implement it/them? <p dir="auto">The implementation is done with the following commits <ul> <li><a href="https://github.com/pcsg/pcsg-makerlog-php-client/commit/4b8447f043478549482432e3d8a7b1794dcf5856" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">feat: new sync method; feat: started new Task Object; feat: /issues/4 <li><a href="https://github.com/pcsg/pcsg-makerlog-php-client/commit/4d53aeca0b9aa80f18ce86f1444bc8aeae026463" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">feat: create tasks <li><a href="https://github.com/pcsg/pcsg-makerlog-php-client/commit/d5c630bcff2c6b0e44bf58f98a559bcbcb68976f" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">feat: delete a task <li><a href="https://github.com/pcsg/pcsg-makerlog-php-client/commit/c1936dd9fc0cbaea65e3b5be38474d6720ef9b24" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">feat: getter and task data integrated <p dir="auto">In addition, I have written a basic documentation so that you can use it. <ul> <li><a href="https://github.com/pcsg/pcsg-makerlog-php-client/commit/4e48bb8f7dfadc936a652136202d3c2e805ba5bc" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">docs: task doku <li><a href="https://github.com/pcsg/pcsg-makerlog-php-client/commit/0a6ce184dacf91a2f0eddab73e230b34f46bdfb0" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">docs: create a new task <p dir="auto">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. <ul> <li>Basically there is a central <code>Tasks object which can be used to get Tasks and which can be used to create Tasks. <li>Additionally there is the single <code>Task. <h6>How to get the main Tasks Object <p dir="auto">The main Tasks object is directly available via the makerlog client <pre><code><?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(); <h6>Create a Task <p dir="auto">To create a new task, you must use the tasks object. <p dir="auto"><em>For the sake of simplicity I assume that the makerlog object is already instantiated and in my examples I won't do that again. <pre><code><?php $Makerlog->getTasks()->createTask('COUR CONTENT', $options); <p dir="auto">The options of a task are optional but can have the following values: <pre><code><?php $options = [ "done" => false, // bool "in_progress" => false // bool ]; <h6>Get tasks <p dir="auto">Returns a list of all tasks in Makerlog. <pre><code><?php $list = $Makerlog->getTasks()->getList(); <h6>Get a task <p dir="auto">A single task can be received via its id <pre><code><?php $task = $Makerlog->getTasks()->get(892); // get task via ID <p dir="auto">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(). <pre><code><?php $Task = $Makerlog->getTasks()->getTaskAsObject(892); // get task via ID // delete the task $Task->delete(); // praise the task $Task->praise(100); <p dir="auto">A task object has several getter methods, so it is quite easy to access the data of the task. <pre><code><?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 <h4>GitHub Account <ul> <li><span><a href="https://github.com/dehenne" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/dehenne <p dir="auto">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 <a href="https://github.com/pcsg/pcsg-makerlog-php-client/tree/master/examples" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">examples. <p dir="auto">With the changes and features of today it is now possible to create, delete tasks, praise other tasks and read tasks. :-)<br /> Have fun in Makerlog and thanks for reading,<br /> Hen
Sort:  

Thank you for your contribution.

<ol> <li>The build is failing on the github page. <li>It would be nice to have some unit tests to cover the new classes you added. <li>The <code>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 <code>getTaskdata into this function. <li>Often, the chainning such as <code>$this->Makerlog->getRequest()->get('/tasks/sync/'); is a code smell, because something may be null in the middle, try to have <code>if null check, then throw exception accordingly. <p dir="auto">Your contribution has been evaluated according to <a href="https://join.utopian.io/guidelines" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category. <p dir="auto">To view those questions and the relevant answers related to your post, <a href="https://review.utopian.io/result/3/2-2-2-2-2-2-1-" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">click here. <hr /> <p dir="auto">Need help? Chat with us on <a href="https://discord.gg/uTyJkNm" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Discord. <p dir="auto"><a href="https://join.utopian.io/" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">[utopian-moderator]

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

Thank you for your review, @justyy! Keep up the good work!

Hi @dehenne!



Feel free to join our @steem-ua Discord serverYour 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!

Hi @dehenne!



Feel free to join our @steem-ua Discord serverYour 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!

Hey, @dehenne!

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

Get higher incentives and support Utopian.io!
SteemPlus or Steeditor). Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via

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

Vote for Utopian Witness!