Click here for directives on how to contribute
What does your API do? This is a comment microservice that allows user to create comments, edit comments and also flags comment. Users can also reply comments , flags reply and also upvote and downvote comments and replies.
Developers should note that all the parameters in the uris are not optional. All body contents should be sent in json.
What is the preferred way of using the API? This API can be accessed with any programing language
404, 400, 401
https://fgn-comments-service.herokuapp.com/
This route creates comments received on twitter report. The body will carry the owner username and email also the report id
BODY
{"report_id":"integer","comment_body": "string", "comment_origin": "string", "comment_owner_username": "string", "comment_owner_email": "string"}
Example Request Default
Example Request ` Default
var bodyJson = {"report_id": 63,"comment_body": "This is the comment body", "comment_origin": "Twitter", "comment_owner_username": "name of comment twitter user", "comment_owner_email": "[email protected]"};
var requestOptions = {
method: 'POST',
body: bodyJson,
redirect: 'follow'
};
fetch("tweet/comment/create", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
201
Body Headers (0)
{"data" : [],
"message" : "Comment saved successfully",
"response" : "Created"}
This route creates comments received on report. The body will carry the owner username and email also the report id if the user is not anonymous. If it is anonymous use anonymous as name and [email protected] as email
BODY
{"report_id":"integer","comment_body": "string", "comment_origin": "string", "comment_owner_username": "string", "comment_owner_email": "string"}
Example Request Default
Example Request ` Default
var bodyJson = {
"report_id": 63,"comment_body": "This is the comment body", "comment_origin": "comment origin", "comment_owner_username": "name of comment owner use anonymous if user is anonymous", "comment_owner_email": "[email protected]"};
var requestOptions = {
method: 'POST',
body: bodyJson,
redirect: 'follow'
};
fetch("report/comment/create", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
201
Body Headers (0)
{"data" : [],
"message" : "Comment saved successfully",
"response" : "Created"}
This route returns all the comments in under a report in the database without the flagged comments.
Example Request
- Default
var raw = "";
var requestOptions = {
method: 'GET',
body: raw,
redirect: 'follow'
};
fetch("report/comments/{report_id}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
200
Body Headers (0)
{"data" : [{
"report_id": "integer",
"comment_origin" : "string",
"comment_body" : "string",
"comment_owner" : "string",
"votes" : "integer",
"replies_count" : "integer",
"upvotes" : "integer",
"downvotes" : "integer",
},],
"message" : "Comment returned successfully",
"response" : "Ok"
}
This route deletes a particular user comment
{"email": "string"}
Example Request
- Default
var bodyJson = {"email": "[email protected]"};
var requestOptions = {
method: 'DELETE',
body: bodyJson,
redirect: 'follow'
};
fetch("report/comment/{comment_id}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
200
** Body Headers (0)**
{
"data" : {
"comment" : "id"
},
"message" : "Comment deleted successfully",
"response" : "Ok"
}
This route modifies the comments vote. User should send vote types between *upvote and *downvote. The body of the call must include the comment id
{"vote_type": enum["upvote", "downvote"]}
Example Request
- Default
var bodyJson = {"vote_type": "downvote"}; //for downvote
var bodyJson = {"vote_type": "upvote"}; //for upvote
var requestOptions = {
method: 'PATCH',
body: bodyJson,
redirect: 'follow'
};
fetch("reports/comment/vote/{comment_id}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response 202 Body Headers (0)
{"data" : [{
"comment_votes": "integer",
"upvotes": "integer",
"downvotes": "integer",
"'message" : "Comment voted successfully",
"response" : "Accepted"
},]
}
This route flags comment
BODY
{"is_flagged": true}
{"is_flagged": true}
Example Request
- Default
var bodyJson = {"is_flagged": true};
var requestOptions = {
method: 'PATCH',
body: bodyJson,
redirect: 'follow'
};
fetch("reports/comment/flag/{comment_id}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
202
Body Headers (0)
{"data": [],
"comment": 36,
"message": "Comments Flagged Successfully",
"response": "Accepted"}
This routes edits comment
BODY
{
"comment_body": "string",
"email": "string"
}
Example Request
- Default
var bodyJson = {"comment_body": "Edited comment", "email": "[email protected]"};
var requestOptions = {
method: 'PATCH',
body: bodyJson,
redirect: 'follow'
};
fetch("reports/comment/edit/{comment_id}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
202
Body Headers (0)
"data": [],
"message": "Comment editted successfully",
"response": "Accepted"
Votes reply
BODY
{"vote_type": "enum['upvote', 'downvote']"}
Example Request
- Default
var bodyJson = {"vote_type": "upvote"};
var requestOptions = {
method: 'PATCH',
body: bodyJson,
redirect: 'follow'
};
fetch("reports/comment/reply/vote/{reply_id}\n", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
202
Body Headers (0)
"data" : {
"message" : "Reply voted successfully",
"response" : "Ok"
},
This route allows user to edit reply
BODY
{"reply_body": "string", "email": "[email protected]"}
Example Request
- Default
var bodyJson = {"reply_body": "edited reply", "email": "[email protected]"};
var requestOptions = {
method: 'PATCH',
body: bodyJson,
redirect: 'follow'
};
fetch("reports/comment/edit/reply/{report_id}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
202
Body Headers (0)
{
"data": [],
"message": "Reply editted successfully",
"response": "Accepted",
}
Flags reply
BODY
"is_flagged": true
Example Request
- Default
var bodyJson = {"is_flagged": true};
var requestOptions = {
method: 'PATCH',
body: bodyJson,
redirect: 'follow'
};
fetch("reports/comment/reply/flag/{reply_id}\n", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
202
Body Headers (0)
"data": [],
"message" : "Reply flagged successfully",
"response": "Accepted"
Gets all the replies for a comment
Example Request
- Default
var raw = "";
var requestOptions = {
method: 'GET',
body: raw,
redirect: 'follow'
};
fetch("report/comment/{comment_id}/reply/{reply_id}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
200
Body Headers (0)
{"data" : [{
"report_id": "integer",
"comment_id": "integer",
"reply_body": "string",
"votes": "integer",
"reply_id": "integer",
"upvotes": "integer",
"downvotes": "integer"
},],
"message" : "Replies returned successfully",
"response" : "Ok"
}