Skip to content

Survey API v1

Jinglei Ren edited this page Oct 5, 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

{
  "id": $,
  "type": "single",
  "commits": [
    {
      "id": $,
      "title": STR,
      "url": STR
    }
    ...
  ]
}

Review Object

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

Label Object

{
  "id": $,
  "title": STR
}

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

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

Response

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

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

Payload

{
  "selected": COMMIT_ID,
}

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

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

Response

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

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

Payload

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

POST /survey/v1/projects/:projectId/labels/new

返回创建好的 label 信息

Payload

{
  labelTitle: STR
}

Response

{
  "status": $,
  "message": STR,
  "data": LABEL_OBJECT,
}

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

获取所有 Labels

Response

{
  "status": $,
  "message": STR,
  "data": {
    builtins: [LABEL_OBJECT, ...], 
    customised: [LABEL_OBJECT, ...],
  }
}

标准 Response

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