Skip to content
This repository was archived by the owner on Apr 10, 2021. It is now read-only.

Endpoints Documentation

Xuechun Hou edited this page Mar 12, 2020 · 18 revisions

http://service/str:author_id/ retrieve author's profile

  • request method: GET
  • url parameter: author_id: UUID
  • example response:
{
  "id":"http://service/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
  "host":"http://127.0.0.1:5454/",
  "displayName":"Lara",
  "url":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
  "friends": [
    {
      "id":"http://127.0.0.1:5454/author/8d919f29c12e8f97bcbbd34cc908f19ab9496989",
      "host":"http://127.0.0.1:5454/",
      "displayName":"Greg",
      "url": "http://127.0.0.1:5454/author/8d919f29c12e8f97bcbbd34cc908f19ab9496989"
    }
  ],

  # Optional attributes
  "github": "http://github.com/lara",
  "firstName": "Lara",
  "lastName": "Smith",
  "email": "lara@lara.com",
  "bio": "Hi, I'm Lara"
} 
  • response status code:
  • 404: author not found
  • 405: request methods not allowed
  • 200: success retrieval of author information

http://service/author/str:author1_id/friends/path:author2_id/ Ask if 2 authors are friends

  • request method: GET
  • url parameter: author1_id: UUID author2_id: full url of author (w/o protocol)
  • example response:
{	"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
}
  • response status code:
  • 405: request methods not allowed
  • 200: succesfully retrieval of friendship information

http://service/str:author_id/addfriend/ view a list of available authors to befriend

  • request method: GET
  • url parameter: author1_id: UUID
  • example response:
{
    "available_authors_to_befriend": [
        "localhost:8000/author/198238a04a1a409cbb4b52ef373fbd27",
        "127.0.0.1:8000/author/b5154eb3b16740eda96857233b165678",
        "localhost:8000/author/d747a675e1054e5b9fe32c5d1a5d277c",
        "localhost:8000/author/99baa477e25b406696f0f61655716197"
    ]
}
  • response status code: 405: request methods not allowed 404: author record not found 200: succesfully retrieval of available friends information

http://service/author/unfriend unfriend two authors given in request body

  • request method: POST
  • example request body:
{
	"author_id" : "127.0.0.1:8000/author/9d411951f13246728c2a1d00c081e680",
	"friend_id" : "localhost:8000/author/99baa477e25b406696f0f61655716197"
}
  • response status code:
  • 422: request body missing field
  • 405: request methods not allowed
  • 404: trying to remove friendship that does not exist
  • 200: successfully removal of friendship

http://service/author/path:author_id/friends/

  • url parameter: author_id: full url of author
  • request method: POST ask a service if anyone in the list is a friend
  • example request body:
{
	"query":"friends",
	"author":"<full url of author>",
	# 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",
		"...",
		"...",
		"..."
  	]
}
  • example response:
{
	"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 method: GET retrieve a list of friends of current user
  • example response:
{
	"query":"friends",
	# Array of Author UUIDs
	"authors":[
		"http://host3/author/de305d54-75b4-431b-adb2-eb6b9e546013",
		"http://host2/author/ae345d54-75b4-431b-adb2-fb6b9e547891"
	]
}
  • response status code:
  • 200: successful retrieval of information
  • 405: request methods not allowed
  • 422: post body missing entries

http://service/friendrequest to make a friend request

  • request method: POST
  • example request body:
{
	"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:
  • 422: post body missing entires
  • 200: firendrequest successfully sent
  • 405: request methods not allowed
  • 409: send friend request when two users already friended or already in a follow relationship
  • request method: POST to accept a friend request
  • example request body:
{
	"query":"friendrequest",
	"author": {
		"id":"localhost:8000/author/c730cf54a83d4d0982ec13a578692793",
		"host":"http://localhost:8000/",
		"displayName":"Greg Johnson",
        "url":"http://localhost:8000/author/de305d54-75b4-431b-adb2-eb6b9e546013"
	},
	"friend": {
		"id":"localhost:8000/author/ba6cf5db6a164c00a85bd717ec6ada60",
		"host":"http://localhost:8000/",
		"displayName":"Lara Croft",
        "url":"http://localhost:8000/author/de305d54-75b4-431b-adb2-eb6b9e546013"

	}
}

  • request method: DELETE to reject a friend request
  • example request body:
{
	"query":"friendrequest",
	"author": {
		"id":"localhost:8000/author/c730cf54a83d4d0982ec13a578692793",
		"host":"http://localhost:8000/",
		"displayName":"Greg Johnson",
        "url":"http://localhost:8000/author/de305d54-75b4-431b-adb2-eb6b9e546013"
	},
	"friend": {
		"id":"localhost:8000/author/ba6cf5db6a164c00a85bd717ec6ada60",
		"host":"http://localhost:8000/",
		"displayName":"Lara Croft",
        "url":"http://localhost:8000/author/de305d54-75b4-431b-adb2-eb6b9e546013"

	}
}

  • response status code:
  • 405: request methods not allowed
  • 422: request body missing entries
  • 404: handle a friend request that doesn't exist
  • 200: friend request successfully handled

http://service/friendrequest/str:author_id to retrieve pending requests of author

  • request method: GET
  • example response:
{
    "query": "retrieve_friend_requests",
    "author": "127.0.0.1:8000/author/c730cf54a83d4d0982ec13a578692793",
    "request": [
       "http://host3/author/de305d54-75b4-431b-adb2-eb6b9e546013",
       "http://host2/author/ae345d54-75b4-431b-adb2-fb6b9e547891"
      ]
}
  • response status code:
  • 405: request method not allowed
  • 200: successful retrieval of information

http://service/user/login display user login page

  • request method: GET

http://service/user/signup display user signup page

  • request method: POST

http://service/user/logout display user logout page

  • request method: GET

Clone this wiki locally