Repository navigation
Backend API Friend
HumphreyLu6 edited this page Mar 29, 2020
·
10 revisions
Response status code and body format:
200 OK
{
"query": "friend requests",
"authors": [
"https://spongebook.herokuapp.com/author/ab187a84-7eb2-4970-9535-815311b3c874"
]
}
Response status code and body format:
200 OK
{
"query":"friends",
"author":"<authorid>",
# Array of Author ids
"authors": [
"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
]
}
Request format:
{
"query":"friends",
"author":"<authorid>",
# Array of Author ids
"authors": [
"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
"...",
"...",
"..."
]
}
Response status code and body format:
200 OK
{
"query":"friends",
"author":"<authorid>", # where <authorid> is the full URL of the author in question
# Array of Author ids who are friends
"authors": [
"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
"..."
]
}
Request format:
{
"query":"friendrequest",
"author": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg Johnson",
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
},
"friend": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e637281",
"host":"http://127.0.0.1:5454/",
"displayName":"Lara Croft",
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
}
}
Response status code and body format:
201 Created
{
}
Request format:
{
"query":"friendrequest",
"author": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg Johnson"
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
},
"friend": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e637281",
"host":"http://127.0.0.1:5454/",
"displayName":"Lara Croft",
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
},
"status":"A"
}
Response status code and body format:
200 OK
{
}
Request format:
{
"query":"friendrequest",
"author": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg Johnson"
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
},
"friend": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e637281",
"host":"http://127.0.0.1:5454/",
"displayName":"Lara Croft",
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
},
"status":"R"
}
Response status code and body format:
204 No Content
{
}
Request format:
{
"query":"friendrequest",
"author": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg Johnson"
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
},
"friend": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e637281",
"host":"http://127.0.0.1:5454/",
"displayName":"Lara Croft",
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
},
"status":"R"
}
Response status code and body format:
204 No Content
{
}
8. As an author, I want to know if I am friend with another author: /author/<AUTHOR1_ID>/friends/<AUTHOR2_ID> GET
<AUTHOR1_ID> is a uuid, <AUTHOR2_ID> is an url: servive/author/, this is required in the example-article.json.
Response status code and body format:
{ "query":"friends",
# Array of Author UUIDs
"authors":[
"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891"
],
# boolean true or false
"friends": true
}
Social Distribution: Make post, Add friend, Enjoy life!
Copyright (C) 2020 Qiaoyan Zhang, Devin Dai, Zhonghao Lu, Yuan Wang, Isaac Zhang