NaijaEmoji is a simple Restful API using Slim for NaijaEmoji Service. It is an implementation of the Checkpoint 3 requirement for PHP developers at Andela.
##Usage Clone this repository like so:
git clone https://github.com/andela-joyebanji/NaijaEmoji.git
Change your directory to NaijaEmoji
directory like so:
cd NaijaEmoji
Install package dependencies:
composer install
You need set your environment variables to define your database parameters or rename .env.example
file in project to .env
and change the below to your local configuration.
DRIVER = sqlite
HOSTNAME = 127.0.0.1
USERNAME = username
PASSWORD = password
DBNAME = YourDatabase
PORT = port
Finally, boot-up the API service with PHP's Built-in web server:
php -S localhost:8080 -t public/
All examples are shown in POSTMAN.
To manage emojis, you'd need to register as a user. The /auth/register
route handles user registration.
You can register a user using POSTMAN
like so:
Supply your preferred username
and password
.
To make use of routes that requires token authentication, you need to get a token. The /auth/login
route handles token generation for users.
You can get token like so:
Supply your registered username
and password
. You can now use the returned token to make other requests to restricted routes.
To get all emojis, you send a GET
request to /emojis
route like so:
To get an emoji, you send a GET
request to /emoji/{id of emoji}
route like so:
You can search for emojis by the emoji's name
, category
it belongs to and keyword
associated to it. You can also get all emojis created by
a particular user.
/emojis/name/{emoji name}
to search for emoji by itsname
/emojis/category/{category name}
to search for emojis that belongs to acategory
/emojis/keyword/{keyword name}
to search for emojis that belongs to akeyword
/emojis/createdBy/{creator name}
to search for emojis created by a user
To create an emoji, you send a POST
request, with your authentication token, to /emojis
route with emoji's information like so:
To delete an emoji, you send a DELETE
request, with your authentication token, to /emojis/{id of emoji}
route like so:
Note: You can only delete an Emoji you created personally.
To update an emoji, you send a PUT
or PATCH
request, with your authentication token, to /emojis/{id of emoji}
route with the information you what to update like so:
Note: You can only update an Emoji you created personally.
If you discover any security related issues, please email Oyebanji Jacob or create an issue.
Copyright (c) 2016 Oyebanji Jacob oyebanji.jacob@andela.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.