-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andela Macbook
authored and
Andela Macbook
committed
Jan 16, 2016
1 parent
57e4c0b
commit a23c7fc
Showing
1 changed file
with
385 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,385 @@ | ||
## Questions Resources | ||
|
||
Endpoints |Params| Usage | | ||
--------- | ----- |-------- | ||
GET /questions | offset, limit ( both could be optional ), auth_token in header | Returns all questions with up-vote and down-vote data, or error message if any. | ||
POST /questions |title, description, user_id, auth_token in header | Returns success message if question creation is successful or error message if any. | ||
GET /questions/:id |question's id, auth_token in header| Returns the question with that id and all other information concerning the the question or error message if any. | ||
GET questions/latest | offset, limit ( both could be optional ), auth_token in header | Returns the latest questions or error message if any. | ||
GET questions/top_questions | offset, limit ( both could be optional ), auth_token in header | Returns the questions matching the criteria for top questions or error message if any. | ||
GET questions/:user_id| offset, limit ( both could be optional ), user_id, auth_token in header | Returns the questions with the user_id and all the information concerning it or error message if any. | ||
This comment has been minimized.
Sorry, something went wrong. |
||
PUT questions/:id| question's id, update information(title, description), auth_token in header | Returns the updated question and all the information concerning it or error message if any. | ||
PATCH questions/:id| question's id, update information(title, description), auth_token in header | Returns the updated question and all the information concerning it or error message if any. | ||
DELETE questions/:id| question's id, auth_token in header | Returns a confirmation that the question has been deleted or error message if any. | ||
|
||
## GET /questions/ | ||
Request | ||
```ruby | ||
GET /questions?limit=5,offset=1 | ||
``` | ||
Response | ||
```ruby | ||
Status: 200 | ||
{ | ||
question:[{ | ||
id: 1, | ||
title: "what is Andela?", | ||
user_id: 1, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 2 | ||
title: "where is Amity?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 3 | ||
title: "what is M55?" | ||
user_id: 4 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 4 | ||
title: "What is DevOps?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 5 | ||
title: "What is month one all about?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
] | ||
} | ||
``` | ||
|
||
#### OR | ||
```ruby | ||
Status: 404 | ||
{ | ||
message: "No questions found" | ||
} | ||
``` | ||
|
||
## POST /questions | ||
Request | ||
```ruby | ||
POST /questions | ||
params: { | ||
title: "Question Title", | ||
description: "Question Description", | ||
user_id: "current user id", | ||
tags: "tag 1", "tag 2", | ||
} | ||
``` | ||
|
||
Response | ||
```ruby | ||
Status: 200 | ||
{ | ||
question: { | ||
id: 1, | ||
title: "Question tittle", | ||
description: "Question Description", | ||
user_id: 1, | ||
up_votes: 0 | ||
down_votes: 0 | ||
comment: [{ }], | ||
answers: [{ | ||
"No answers yet" | ||
}], | ||
tags: [{ | ||
matches: [ "tag 1", "Tag 2"] | ||
}], | ||
created_at: "2015-12-14T16:51:06.437Z", | ||
updated_at: "2015-12-14T16:51:06.437Z", | ||
} | ||
}} | ||
``` | ||
|
||
#### OR | ||
|
||
```ruby | ||
Status: 403 | ||
{ | ||
message: Error Message | ||
} | ||
``` | ||
|
||
## GET /questions/:id | ||
|
||
Request | ||
```ruby | ||
GET /questions/1 | ||
``` | ||
|
||
Response | ||
```ruby | ||
Status: 200 | ||
{ | ||
question: { | ||
id: 1, | ||
title: "What is Andela", | ||
description: "I want to know what Andela is all about", | ||
user_id: 24, | ||
up_votes: 10 | ||
down_votes: 0 | ||
comment: [ | ||
{ | ||
id: 1, | ||
id: 13, | ||
body: "This is a comment on a question", | ||
type: "comment", | ||
created_at: "2015-12-14T22:23:17.646Z", | ||
updated_at: "2015-12-14T22:23:17.646Z" | ||
} | ||
{ | ||
id: 2, | ||
user_id: 2, | ||
body: "This is another comment on a question", | ||
type: "comment", | ||
created_at: "2015-12-14T22:23:17.646Z", | ||
updated_at: "2015-12-14T22:23:17.646Z" | ||
} | ||
], | ||
|
||
answers: [{ | ||
id: 1, | ||
user_id: 21, | ||
body: "A description of Andela", | ||
type: "Answer", | ||
comment:[ | ||
{ | ||
id: 3, | ||
user_id: 3, | ||
body: "This is a comment on an answer", | ||
type: "comment", | ||
created_at: "2015-12-14T22:23:17.646Z", | ||
updated_at: "2015-12-14T22:23:17.646Z" | ||
} | ||
{ | ||
id: 7, | ||
user_id: 5, | ||
body: "This is another comment on an answer", | ||
type: "comment", | ||
created_at: "2015-12-14T22:23:17.646Z", | ||
updated_at: "2015-12-14T22:23:17.646Z" | ||
} | ||
], | ||
created_at: "2015-12-14T22:23:17.646Z", | ||
updated_at: "2015-12-14T22:23:17.646Z" | ||
|
||
}], | ||
tags: [{ | ||
matches: [ "operations", "Andela"] | ||
}], | ||
created_at: "2015-12-14T16:51:06.437Z", | ||
updated_at: "2015-12-14T16:51:06.437Z", | ||
} | ||
} | ||
``` | ||
#### OR | ||
|
||
```ruby | ||
Status: 404 | ||
{ | ||
message: "Question with id 1 was not found" | ||
} | ||
``` | ||
## GET /questions/latest | ||
Request | ||
```ruby | ||
GET /questions/latest?limit=5,offset=1 | ||
``` | ||
Response | ||
```ruby | ||
Status: 200 | ||
{ | ||
question:[{ | ||
id: 5, | ||
title: "what is Andela?", | ||
user_id: 1, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 4 | ||
title: "where is Amity?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 3 | ||
title: "what is M55?" | ||
user_id: 4 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 2 | ||
title: "What is DevOps?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 1 | ||
title: "What is month one all about?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
] | ||
} | ||
``` | ||
|
||
#### OR | ||
```ruby | ||
Status: 404 | ||
{ | ||
message: "No questions found" | ||
} | ||
``` | ||
|
||
## GET /questions/top_questions | ||
Request | ||
```ruby | ||
GET /questions/top_questions?limit=5,offset=1 | ||
``` | ||
Response | ||
```ruby | ||
Status: 200 | ||
{ | ||
question:[{ | ||
id: 12, | ||
title: "what is Andela?", | ||
user_id: 1, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 24 | ||
title: "where is Amity?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 300 | ||
title: "what is M55?" | ||
user_id: 4 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 41 | ||
title: "What is DevOps?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 5 | ||
title: "What is month one all about?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
] | ||
} | ||
``` | ||
|
||
#### OR | ||
```ruby | ||
Status: 404 | ||
{ | ||
message: "No questions found" | ||
} | ||
``` | ||
|
||
## GET /questions?:user_id | ||
Request | ||
```ruby | ||
GET /questions | ||
params:{ | ||
user_id=3 | ||
} | ||
``` | ||
Response | ||
```ruby | ||
Status: 200 | ||
{ | ||
question:[{ | ||
id: 121, | ||
title: "what is Andela?", | ||
user_id: 3, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 2 | ||
title: "where is Amity?" | ||
user_id: 3, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 3 | ||
title: "what is M55?" | ||
user_id: 3, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 43 | ||
title: "What is DevOps?" | ||
user_id: 3, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 51 | ||
title: "What is month one all about?" | ||
user_id: 3, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
] | ||
} | ||
``` | ||
|
||
#### OR | ||
```ruby | ||
Status: 404 | ||
{ | ||
message: "No questions found" | ||
} | ||
``` |
This will conflict with the
route
on line 7 above; in fact this route will never be triggered. I suggest that the route to retrieve all questions belonging to a particular user be created on the user resources i.e