Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

APIv1.Objects

alexandrepiveteau edited this page May 28, 2020 · 1 revision

Table of Contents

General

When a list of objects needs to be sent, it will be done so using JSON arrays.

Moderator

Client

When a moderator needs to be sent by a client, it should be represented as so:

{
  "username" : "guy-laurent",
  "password" : "1234"
}

Server

When a moderator needs to be sent by the server, it should be represented as so:

{
  "idModerator" : "123",
  "token"       : "abcdefghi"
}

Token

Client

When a token needs to be sent by a client, it should be via the URL:

/ex/ample?token=abcdefghi

Server

When the server needs to send a token, it should be represented as so:

{
  "token" : "abcdefghi"
}

Poll

Client

When a client needs to send a poll, it should be represented as so:

{
  "title" : "My title"
}

Server

When the server needs to send a poll, it should be represented as so:

{
  "idModerator" : {idModerator},
  "idPoll"      : {idPoll},
  "title"       : "My title"
}

Session

Note: The status can be either:

  • open meaning the session is active and people can connect to it
  • quarantined meaning the session is active but people cannot connect to it anymore
  • closed meaning the session is not active anymore

Client

When the client needs to send a session, it should be represented as so:

{
  "status"      : `open`
}

Server

When the server needs to send a session, it should be represented as so:

{
  "idModerator" : {idModerator},
  "idPoll"      : {idPoll},
  "idSession"   : {idSession},
  "code"        : "0xABCD",
  "status"      : `open`
}

Question

Note: indexInPoll can be a double. In which case, the natural number ordering is to be followed.

Client

When a client needs to send a question, it should be represented as so:

{
  "title"       : "This is a Question title",
  "details"     : "Comment",
  "visibility"  : "hidden",
  "indexInPoll" : 1,
  "answersMin"  : 1,
  "answersMax"  : 42
}

Server

When the server needs to send a question, it should be represented as so:

{
  "idModerator" : {idModerator},
  "idPoll"      : {idPoll},
  "idQuestion"  : {idQuestion},
  "title"       : "This is a Question title",
  "details"     : "Comment",
  "visibility"  : "hidden",
  "indexInPoll" : 1,
  "answersMin"  : 1,
  "answersMax"  : 42
}

General

visibility can have one of three values: visible, hidden or archived.

Attributes answersMin and answersMax are optionnal.

Answers

Client

When a client needs to send an answer, it should be represented as so:

{
  "title"       : "First answer",
  "description" : "This is a description"
}

Server

When the server needs to send an answer, it should be represented as so:

{
  "idModerator" : {idModerator},
  "idPoll"      : {idPoll},
  "idQuestion"  : {idQuestion},
  "idAnswer"    : {idAnswer},
  "title"       : "First answer",
  "description" : "This is a description",
  "checked"     : {boolean, optional}
}

Answers that have been requested with a participant token will get the checked field, but moderators will not see any field set.

Votes

Client

When a client needs to send a vote for an answer, it should be represented as so:

{
  "checked" : true
}

The value of checked is a boolean and should represent if the answer is selected in the user's UI.

Poll Statistics

Server

When a moderator needs some basic statistics, he might retrieve some general poll statistics that are represented as so :

[
  {
    "title": "Question title 1",
    "answers" :
      [
        { "title": "answer 1", "positive":  123, "negative": 123 },
        { "title": "answer 2", "positive":  123, "negative": 123 },
        { "title": "answer 3", "positive":  123, "negative": 123 }
      ]
  },
  {
    "title": "Question title 2",
    "answers" : []
  }
]

Question statistics

Client

An array of question statistics is requested for certain UNIX timestamps. The timestamps consider the current time in seconds.

[
  1589128713,
  1589128722
]

Server

An array of question statistics is returned for a certain question at a set of different timestamps.

{
  "answers":
    [
      {
        "idAnswer" : 1,
        "title": "Answer 1"
      },
      {
        "idAnswer" : 2,
        "title": "Answer 2"
      }
    ],
  "timestamps": 
    [
      {
        "seconds": 1589128713,
        "votes":
          [
            {
              "idAnswer" : 1,
              "count": 123
            },
            {
              "idAnswer" : 2,
              "count": 456
            }
          ]
      },
      {
        "seconds": 1589128715,
        "votes":
          [
            {
              "idAnswer" : 1,
              "count": 123
            },
            {
              "idAnswer" : 2,
              "count": 456
            }
          ]
      }
    ]
}