Giter Club home page Giter Club logo

api's Introduction

Simple Task Management Application

A simple Lumen based lightweight task management application with simple UI and API endpoint. Each task can have subtasks and tasks without subtasks have points. That means parent task has a sum of points from subtasks. What is more, if all subtasks of a task are done, then task also is done. If at least one subtask of a task marked as not done then it also becomes not done.

About this application

  1. The application is using PHP Lumen framework;
  2. The application have a simple UI and required API endpoints;
  3. It is follow PSR-2 style guide;
  4. The Application is written in OOP;
  5. The code in simple and clean;
  6. The code is tested in PHPUnit test.

Environment setup

First clone this repository by using git clone https://github.com/devawal/api.git And run composer install

Third party dependencies

  1. PHP Unit is used for unit testing.
  2. PHP Coding Standards Fixer is usse for maintain PSR-2 coding standerd

Database

The application is using MySQL database and use default connection settings. To connect and create table at first create a database with a name and configure it in .env file. In this application I used tasks_management. Run the migration command by typing console command php artisan migrate:install it will create migration table then run php artisan migrate to install the migration in the database.

User data source

The application is using users from the following link https://gitlab.iterato.lt/snippets/3/raw

The URL can be updated from App\Http\Controllers\TasksController in

/**
 * The user data source URL.
 *
 * @var string
 */
protected $userSource = 'https://gitlab.iterato.lt/snippets/3/raw';

Create task

End point for create task is: http://your_host/api/task which accept HTTP POST request whth the following input parameters

Input data

{
	"parent_id":null,
	"user_id":1,
	"title":"Task 1",
	"points":5,
	"is_done":1,
	"email":"[email protected]"
}

Output

The application API will return 201 status code if it passed all validations otherwise it will throw 400 status code with validation message

{
    "parent_id": null,
    "user_id": 2,
    "title": "Task 1",
    "points": 5,
    "is_done": 1,
    "created_at": "2019-10-12 14:34:15",
    "updated_at": "2019-10-12 14:34:15",
    "id": 1
}

Update task

End point for update task is: http://your_host/api/task/{task_id} which accept HTTP PUT request with the following input parameters

Input data

{
	"parent_id":null,
	"user_id":2,
	"title":"Task 1",
	"points":10,
	"is_done":1,
	"email":"[email protected]"
}

Output

The application API will return 201 status code if it passed all validations otherwise it will throw 400 status code with validation message

All other internal errors will return 500 with error message

View task list

End point for all task: http://your_host/tasks

Testing

The application is tested with random data set using faker. For Unit test following is the command ./vendor/bin/phpunit

Test class tests\TasksTest Test configuration file phpunit.xml

Test output from windows

$ ./vendor/bin/phpunit
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

..                                                                  2 / 2 (100%)

Time: 1.83 seconds, Memory: 10.00MB

OK (2 tests, 2 assertions)

api's People

Contributors

devawal avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.