Appearance
Poll
Create and vote on polls.
Endpoints
| Endpoint | Arguments | Returns |
|---|---|---|
poll.create | options: PollCreateOptions | object |
poll.edit | pollId: string, pollOptions: PollEditOptions | object |
poll.remove | pollId: string | boolean |
poll.retract | retractOptions: { pollId: string, optionId: string } | boolean |
poll.vote | voteOptions: { pollId: string, optionId: string } | boolean |
poll.create
Description
Creates a poll with given answer visibility and options
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
options | object[] | yes | |
answerVisibility | creator | none | public | yes | One of: creator, none, public. |
name | string | yes | |
multipleAnswers | boolean | no | |
draft | boolean | no | |
scheduled | boolean | no | |
scheduleTime | number | no | |
lockedVotes | boolean | no |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('poll.create', [
{
options: [{
name: 'string',
}],
answerVisibility: 'creator',
name: 'string',
},
]);
console.log(result);Returns
| Field | Type | Required | Description |
|---|---|---|---|
_id | ObjectId | yes | pollId |
name | string | yes | |
created | number | yes | |
creatorId | userId | yes | userId |
options | Record<ObjectId, object> | yes | |
answerVisibility | creator | none | public | yes | One of: creator, none, public. |
answers | Record<userId, Record<ObjectId, object>> | no | |
answerCounts | Record<ObjectId, number> | no | |
usersAnsweredCount | number | no | |
multipleAnswers | boolean | no | |
draft | boolean | no | |
scheduled | boolean | no | |
lockedVotes | boolean | no |
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
poll.edit
Description
Edits given poll, that is scheduled, to have different visiblity or options
Parameters
Argument 1 (ObjectId, optional): pollId
Argument 2 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
options | object[] | no | |
answerVisibility | creator | none | public | no | One of: creator, none, public. |
name | string | no | |
multipleAnswers | boolean | no | |
draft | boolean | no | |
scheduled | boolean | no | |
scheduleTime | number | no | |
lockedVotes | boolean | no |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('poll.edit', [
'507f1f77bcf86cd799439011', // ObjectId
{
options: [{
name: 'string',
}],
answerVisibility: 'creator',
},
]);
console.log(result);Returns
| Field | Type | Required | Description |
|---|---|---|---|
_id | ObjectId | yes | pollId |
name | string | yes | |
created | number | yes | |
creatorId | userId | yes | userId |
options | Record<ObjectId, object> | yes | |
answerVisibility | creator | none | public | yes | One of: creator, none, public. |
answers | Record<userId, Record<ObjectId, object>> | no | |
answerCounts | Record<ObjectId, number> | no | |
usersAnsweredCount | number | no | |
multipleAnswers | boolean | no | |
draft | boolean | no | |
scheduled | boolean | no | |
lockedVotes | boolean | no |
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
poll.remove
Description
Removes given poll
Parameters
Argument 1 (ObjectId, required): pollId
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('poll.remove', [
'507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);Returns
boolean
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
poll.retract
Description
Retracts a vote from the given polls option
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
pollId | string | yes | |
optionId | string | yes |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('poll.retract', [
{
pollId: 'string',
optionId: 'string',
},
]);
console.log(result);Returns
boolean
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.
poll.vote
Description
Adds a vote to the given polls option
Parameters
Argument 1 (object, optional):
| Field | Type | Required | Description |
|---|---|---|---|
pollId | string | yes | |
optionId | string | yes |
Example
javascript
const { Client } = require('@hailer/cli');
const client = await Client.create({
host: 'https://api.hailer.com',
username: 'you@example.com',
password: '••••••',
});
const result = await client.request('poll.vote', [
{
pollId: 'string',
optionId: 'string',
},
]);
console.log(result);Returns
boolean
Auth: requires an authenticated session.
Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.