bounswe / bounswe2015group7

Sculture, The Software Project of Future
6 stars 4 forks source link

Updating the API docs #119

Open narinmahmuti opened 8 years ago

narinmahmuti commented 8 years ago

The API documentation should be updated since the story creation has been added recently.

fthdgn commented 8 years ago

I will write the API's which I have written. The assignee can write the documentation according to it.

POST /user/register

request body

{
"username":"fatih",
"email":"fatih@example.com",
"password":"123456789",
"facebook_id":123456789, //optional
"facebook_taken":"asda4as6f4a" //optional
"fullname":"fatih dogan" //optional
}

Successful response body

{
"id":1345,
"username":"fatih",
"email":"fatih@example.com",
"facebook_id":123456789,
"fullname":"fatih dogan",
"_promoted": false, // I don't know why the "is" part is not written, I will investigate it
"notification_rate": 1,
"access_token":"54564-fsfa-f87"
}

Possible error messages

POST /user/login

request body

{
"email":"fatih@example.com",
"password":"123456789"
}

Successful response body

{
"id":1345,
"username":"fatih",
"email":"fatih@example.com",
"facebook_id":123456789,
"fullname":"fatih dogan",
"_promoted": false, // I don't know why the "is" part is not written, I will investigate it
"notification_rate": 1,
"access_token":"54564-fsfa-f87"
}

Possible error messages

POST /story/get

request body

{
"id":1
}

Successful response body

{
  "id": 1,
  "title": "mytitle",
  "creation_date": 1448227926000,
  "update_date": 1448227926000,
  "last_editor": {
    "id": 1,
    "username": "fatih"
  },
  "owner": {
    "id": 1,
    "username": "fatih"
  },
  "tags": [
    "tag1",
    "tag2"
  ],
  "positive_vote": 0,
  "negative_vote": 0,
  "report_count": 0,
  "content": "content"
}

Possible error messages

POST /story/create

request body

{
   "title":"mytitle",
   "content":"my content",
   "tags" : ["tag1", "tag2"]
}

Request header

"access-token" : "50276as4-25de-526f-a4b9-3d04f00fee61"

Successful response body

{
  "id": 1,
  "title": "mytitle",
  "creation_date": 1448227926000,
  "update_date": 1448227926000,
  "last_editor": {
    "id": 1,
    "username": "fatih"
  },
  "owner": {
    "id": 1,
    "username": "fatih"
  },
  "tags": [
    "tag1",
    "tag2"
  ],
  "positive_vote": 0,
  "negative_vote": 0,
  "report_count": 0,
  "content": "my content"
}

Possible error messages

POST /search

request body

{
"query": "tag1",
"size": 5 ,  // default 10, min 1
"page" 1   // default 0, 1-based index
}

Successful response body

{
  "result": [
    {
      "id": 3,
      "title": "my title",
      "creation_date": 1448232843000,
      "update_date": 1448232843000,
      "last_editor": {
        "id": 10,
        "username": "ali"
      },
      "owner": {
        "id": 10,
        "username": "ali"
      },
      "tags": [
        "tag1",
        "fsdf"
      ],
      "positive_vote": 0,
      "negative_vote": 0,
      "report_count": 0
    },
    {
      "id": 4,
      "title": "my title",
      "creation_date": 1448232855000,
      "update_date": 1448232855000,
      "last_editor": {
        "id": 10,
        "username": "ali"
      },
      "owner": {
        "id": 10,
        "username": "ali"
      },
      "tags": [
        "tag1",
        "fsdf"
      ],
      "positive_vote": 0,
      "negative_vote": 0,
      "report_count": 0
    },
    {
      "id": 5,
      "title": "my title",
      "creation_date": 1448232856000,
      "update_date": 1448232856000,
      "last_editor": {
        "id": 10,
        "username": "ali"
      },
      "owner": {
        "id": 10,
        "username": "ali"
      },
      "tags": [
        "tag1",
        "fsdf"
      ],
      "positive_vote": 0,
      "negative_vote": 0,
      "report_count": 0
    }
 ]
}

Possible error messages