Skip to content

Questions endpoints

jimmymlu edited this page Oct 17, 2014 · 2 revisions

GET /v1/questions/?date=XXXX-XX-XX

  • scopes: OAuthScope.QUESTIONS_READ

Returns a list of questions for the user authenticated by the access token

public class Question {

    public enum Type {
        CHOICE("choice"),
        YES_NO("yes_no");
    }

    @JsonProperty("id")
    final public Long id;

    @JsonProperty("text")
    final public String text;

    @JsonProperty("type")
    final public Type type;

    @JsonProperty("choices")
    final List<Choice> choiceList;
}

and Choice is defined by the following class:

public class Choice {

    @JsonProperty("id")
    final public Long id;

    @JsonProperty("text")
    final public String text;

    @JsonProperty("question_id")
    final public Optional<Long> questionId;
}

Example JSON response:

[
  {
    "id": 123,
    "text": "tim bart, do you sleep better when it is hot or cold?",
    "type": "CHOICE",
    "choices": [
      {
        "id": 123456789,
        "text": "HOT",
        "question_id": 123
      },
      {
        "id": 987654321,
        "text": "COLD",
        "question_id": 123
      }
    ]
  }
]

Note: the date attribute in format (YYYY-MM-DD) is not required

POST /v1/questions/

  • scopes: OAuthScope.QUESTIONS_WRITE

Body is a JSON serialized choice object as defined above.

Raw request:

curl https://dev-api.hello.is/v1/questions -X POST -d '{"id":123456798, "text": "HOT"}' -H'Authorization : Bearer 1.c331d0a37fe341ea830918f535430149' -H 'Content-Type: application/json'

Response HTTP 204

HTTP/1.1 204 No Content
Date: Wed, 10 Sep 2014 16:51:13 GMT

PUT /v1/questions/{question_id}/skip

  • scopes: OAuthScope.QUESTIONS_WRITE

Raw request:

curl https://dev-api.hello.is/v1/questions/123/skip -X PUT -H'Authorization : Bearer 1.c331d0a37fe341ea830918f535430149' -H 'Content-Type: application/json'

Response HTTP 204

HTTP/1.1 204 No Content
Date: Wed, 10 Sep 2014 16:51:13 GMT