Skip to content

Survey API v1

Jinglei Ren edited this page Oct 14, 2017 · 17 revisions

Authorization

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

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

Question Object

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

Review Object

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

Label Object

{
  "label": {
    "id": STR,
    "name": 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
}

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

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

Response

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

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

获取所有 Labels

Response

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

标准 Response

{
  "status": 0, // 可能的错误号或者 0
  "message": '可能的错误信息',
  "data": 返回的数据
}
Clone this wiki locally