Tasks API implementation into the PHP Client for Makerlog

in #utopian-io6 years ago (edited)

Tasks API implementation into the PHP Client for Makerlog


PHP Client for Makerlog

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

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

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

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

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.

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

Sort:  

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, 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.


Need help? Chat with us on Discord.

[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!

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

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

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 or Steeditor).

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

Vote for Utopian Witness!