This documentation intends to give an overview of the Apis endpoints and the appropriate way to consume them using any client.
You are going to need:
- Linux or OSX
- Ruby version-2.4.0
- Rails version-5.0
- Bundler - If Ruby is installed but the
budnle
command does not work, just rungem install bundler
in a terminal.
- Fork this repository on Github.
- Clone the forked repository to your hard drive using
git clone git@github.com:YOUR USERNAME/linkdot_api.git
cd linkdot_api
bundle install
rake db:create
rake db:migrate
rails s
You can now see the apis up and running locally at http://localhost:3000. Whoa! Thats fast ;)
We target to develop Api's for the following features in our project. Of course, we will be adding more as we move along with the scope of the project.
-
Sign Up:
This end point creates new user.
POST http://localhost:3000/users/sign_up
Parameter Presence Description user[emai] required User email address. user[password] required User password. picture[avatar] required Picture of the user. tag_ids[0] required Array of tag ids, that represent user interest. curl -X POST -F "user[email]='random@mail.com" -F "user[password]=12345678" -F "tag_ids[0][]=1" -F" picture[avatar]=@Path of local image" http://localhost:3000/users/sign_up
The above command returns a json response like this:
{
"user": {
"id": 51,
"email": "josh@mail.com",
"picture": {
"id": 47,
"image": "http://localhost:3000/system/pictures/avatars/000/000/047/original/pin.jpg?1503499504"
},
"tags": [
{
"name": "Digital Programming"
},
{
"name": "Digital Programming"
},
{
"name": "Meta Programming"
}
]
}
}
-
Sign In:
This end point signs in new user.
POST http://localhost:3000/users/sign_in
Parameter Presence Description user[email] required User email address. user[password] required User Password curl -X POST -F "user[email]='jackie@mail.com" -F "user[password]=12345678" http://localhost:3000/users/sign_in
The above command returns a response like this:
{ "user": { "id": 55, "email": "jackie@mail.com", "authentication_token": "xBysg6BptdYxZi2WPWsk", "picture": { "id": 51, "image": "http://localhost:3000/system/pictures/avatars/000/000/051/original/ns.jpg?1503684916" }, "tags": [ { "name": "Digital Programming" } ] } }
-
Sign Out:
This endpoint sign out login user.
DELETE http://localhost:3000/users/sign_out
Parameter Presence Description token required Sing in user's token. user[email] required User email address. user[password] optional User password. user[first_name] optional User first name. user[last_name] optional User last name. picture[avatar] optional Picture of the user. tag_ids[0] optional Array of tag ids, that represent user interest. curl -X DELETE -H "Authorization: Token token=TOKEN OF SIGN IN USER" http://localhost:3000/users/update
The above command returns a response like this.
{"detail":"Sign Out Successfully."}
-
Update User:
This endpoint updates user's attributes.
PUT http://localhost:3000/users/update
Parameter Presence Description token required Sign in user's token. user[email] required Sign in user's email user[password] optional Sign in user's password user[password_confirmation] optional Sign in user's password confirmation picture[avatar] optional Sign in user's picture. user[first_name] optional Sign in user's first name. user[last_name] optional Sign in user's last name. tag_ids[] optional Array of tag ids, that represent user interest. Tags that are passed to this api will be removed from user's interest. curl -X PUT -H "Authorization: Token token=TOKEN OF SIGN IN USER" -F "user[email]=email" -F "user[first_name]=f_name" http://localhost:3000/users/update
The above command returns a response like this.
{ "user": { "id": 1, "email": "gori@mail.com", "first_name": "Jesse", "last_name": "Wright", "authentication_token": "z971Maay1KdibLRStBBB", "picture": { "id": 75, "image": "http://localhost:3000/system/pictures/avatars/000/000/051/original/ns.jpg?1503684916" }, "tags": [] } }
-
Events:
This endpoint returns all events in the system.
GET http://localhost:3000/events
Parameter Presence Description token required Auth token of sign in user curl -H "Authorization: Token token=TOKEN OF SIGN IN USER" http://localhost:3000/events
The above command returns a json response like this:
{ "events": [ { "id": 7, "title": "Smart City Innovation", "address": "Alto University Finland", "city": "Helsenki", "state": "HL", "zip": "38100", "event_start_time": "02:00 AM", "event_end_time": "12:00 PM", "event_start_date": "09-12-2017", "event_end_date": "12-12-2017", "picture": { "id": 45, "image": "http://localhost:3000/system/pictures/avatars/000/000/045/original/19467565_717135315143212_2254025401790960972_o.jpg?1503409105" }, "tags": [ { "name": "Digital Programming" }, { "name": "Digital Programming" }, { "name": "Meta Programming" } ] }, { "id": 8, "title": "Trip to Ericson Lab", "address": "Ericson Labs.Inc", "city": "Helsenki", "state": "HL", "zip": "38100", "event_start_time": "02:00 AM", "event_end_time": "12:00 PM", "event_start_date": "09-12-2017", "event_end_date": "12-12-2017", "picture": { "id": 46, "image": "http://localhost:3000/system/pictures/avatars/000/000/046/original/calculatoe1955.jpg?1503410065" }, "tags": [ { "name": "Digital Programming" }, { "name": "Digital Programming" }, { "name": "Meta Programming" } ] } ] }