Skip to content

Survey API v1

Jinglei Ren edited this page Dec 11, 2017 · 17 revisions

Authorization

All requests must contain HTTP header X-USR-TOKEN to identify a specified user.

API responds HTTP code 403 if the token doesn't exist or token is invalid.

Question Object

{
  "question": {
    "id": STR,
    "type": "single",
    "commits": [
      {
        "id": STR,
        "title": STR,
        "url": STR,
        "description": STR,
      }
      ...
    ],
    "answered": INT
  }
}

Review Object

{
  "review": {
    "id": STR,
    "type": "single",
    "commits": [
      {
        "id": STR,
        "title": STR,
        "url": STR
      }
      ...
    ],
    "selected": STR,
    "commitLabels": [
      {
        "commitId": STR,
        "labelId": STR
      }
      ...
    ],
    "reason": STR,
    "reviewed": INT
  }
}

Label Object

{
  "label": {
    "id": STR,
    "name": STR
  }
}

Project Object

{
  "project": {
    "id": STR,
    "name": STR,
    "githubUrl": STR
  }
}

GET /survey/v1/projects/:projectId/questions/next

返回下一个没有作答过的 Question,包含 Question Object

Response

{
  "status": INT,
  "message": STR,
  "data": QUESTION_OBJECT,
}

POST /survey/v1/projects/:projectId/questions/:questionId

Payload

{
  "selected": COMMIT_ID,
  "reason": STR
}

The reason string should be in the format '\[.*\] is more valuable than \[.*\]'.

GET /survey/v1/projects/:projectId/reviews/next

返回下一个没有加过标签的 Review,包含 Review Object

Response

{
  "status": INT,
  "message": STR,
  "data": REVIEW_OBJECT,
}

POST /survey/v1/projects/:projectId/reviews/:id

Payload

{
  "comment": STR,
  "commitLabels": [
    {
      "commitId": STR,
      "labelId": STR
    }
    ...
    {
      "commitId": STR,
      "labelName": STR
    }
    ...
  ]
}

Response

{
  "status": INT,
  "message": STR,
  "data": [LABEL_OBJECT, ...]
}

GET /survey/v1/projects/:projectId/labels

Collect all labels.

Response

{
  "status": INT,
  "message": STR,
  "data": {
    "builtin": [LABEL_OBJECT, ...], 
    "customized": [LABEL_OBJECT, ...]
  }
}

GET /survey/v1/projects/:projectId/project-info

Retrieve basic project information.

Response

{
  "status": INT,
  "message": STR,
  "data": PROJECT_OBJECT
}

GET /survey/v1/projects/:projectId/developer-stats

Get basic statistics of the current developer, including the total number of questions in this project ("total"), and the number of answered questions ("answered").

Response

{
  "status": INT,
  "message": STR,
  "data": {
    "total": INT, 
    "answered": INT
  }
}

Standard Response

{
  "status": 0, // Error number or 0
  "message": 'Error message if any',
  "data": Object
}