Skip to content

wilmkr/naija_emojis

Repository files navigation

#naija_emojis

Build Status

This is a simple RESTFul API rendering emoji service to users. It was built with PHP and implements the Slim framework and JSON web token (JWT) for user authentication.

Install

Via Composer

$ composer require Wilson/naija-emoji

Usage

  • Create a new users
Send a POST request to https://w-naija-emoji.herokuapp.com/register
request body:
{
    'username'  : 'wil',
    'password'  : '******'
    'name'      : 'Wilson Omokoro'
}

response
{
    'Status'    : '200'
    'Message'   : 'User registration successful.'
}
  • User login
Send a POST request to https://w-naija-emoji.herokuapp.com/auth/login
request body:
{
    'username'  : 'wil',
    'password'  : '******'
}

A JSON Web Token should be returned on successful login

response
{
    'Status'    : '200'
    'Message'   : 'Login successful'
    'Token'     : 'eyJ0eXAiOiJKV1QiLCJh.bGciOiJIUzI1NiJ9.eyJpYXQiOjE0NT'
}
  • User logout
Send a GET request to https://w-naija-emoji.herokuapp.com/auth/logout

request header
{
    'Authorization' : 'eyJ0eXAiOiJKV1QiLCJh.bGciOiJIUzI1NiJ9.eyJpYXQiOjE0NT';
}
  • Create an Emoji
Send a POST request to https://w-naija-emoji.herokuapp.com/emojis
request body:
{
    'name'  : 'Happy'
    'emoji_char'  : 😀
    'category'  : 'Facial'
    'key_words'  : ['happy, glad, delighted']
    'created_by'  : 'Wilson Omokoro'
}
request header
{
    'Authorization' : 'eyJ0eXAiOiJKV1QiLCJh.bGciOiJIUzI1NiJ9.eyJpYXQiOjE0NT';
}

response
{
    'Status'    : '201'
    'Message'   : 'Emoji creation successful.'
}
  • Show all Emojis in the database
Send a GET request to https://w-naija-emoji.herokuapp.com/emojis

Response should contain all emojis in JSON format.
  • Get a particular Emoji
Send a GET request containing the Emoji's ID in the emojis table to https://w-naija-emoji.herokuapp.com/emojis

E.g. to get the third emoji:

https://w-naija-emojis.herokuapp.com/emojis/3

Response should contain the emoji in JSON format.
  • Partialy update an Emoji
Send a PATCH request containing the Emoji's ID in the emojis table to https://w-naija-emoji.herokuapp.com/emojis

E.g. to update just the name of the first emoji:

https://w-naija-emojis.herokuapp.com/emojis/1

request body
{
    'name'  : 'some other name',
}
request header
{
    'Authorization' : 'eyJ0eXAiOiJKV1QiLCJh.bGciOiJIUzI1NiJ9.eyJpYXQiOjE0NT';
}

response
{
    'Status'    : '200'
    'Message'   : 'Emoji successfully updated.'
}
  • Fully update an Emoji
Send a PUT request containing the Emoji's ID in the emojis table to https://w-naija-emoji.herokuapp.com/emojis

E.g. to fully update the first emoji:

https://w-naija-emojis.herokuapp.com/emojis/1

request body
{
    'name'  : 'Happy'
    'emoji_char'  : 😀
    'category'  : 'Facial'
    'key_words'  : 'happy, glad, delighted'
    'created_by'  : 'Wilson Omokoro'
}
request header
{
    'Authorization' : 'eyJ0eXAiOiJKV1QiLCJh.bGciOiJIUzI1NiJ9.eyJpYXQiOjE0NT';
}

response
{
    'Status'    : '200'
    'Message'   : 'Emoji successfully updated.'
}
  • Delete a particular Emoji
Send a DELETE request containing the Emoji's ID in the emojis table to https://w-naija-emoji.herokuapp.com/emojis

E.g. to DELETE the third emoji:

https://w-naija-emojis.herokuapp.com/emojis/3

request header
{
    'Authorization' : 'eyJ0eXAiOiJKV1QiLCJh.bGciOiJIUzI1NiJ9.eyJpYXQiOjE0NT';
}

response
{
    'Status'    : '200'
    'Message'   : 'Emoji 3 deletion successful.'
}

Testing

If the folder containing your test classes is "tests"

$ phpunit tests

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email wilson.omokoro@andela.com instead of using the issue tracker.

Credits

Naija-emoji is maintained by Wilson Omokoro.

License

The MIT License (MIT). Please see License File for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published