praekelt/vumi-go — pull request #335 by hodgestar (2013-08-01 16:29:20+00:00)
Title: New polls saving and loading functions to the Go API.

The new polls will directly support the JSON format below. Initially three kinds of questions will be supported -- choice states, free text states and end states.

Example JSON:
```javascript
var poll = {
conversation: "conversation-key",
start_state: {uuid: "state-1"},
poll_metadata: {
repeatable: true,
},
states: [
{
// these are common to all state types
uuid: "state-1", // name is unique
name: "Message 1", // a friendly name for the user to see
store_as: "message-1",
type: "choice", // menu of options
entry_endpoint: null, // null for the start state
store_on_contact: true,
// choice specific
text: "What is your favourite colour?",
choice_endpoints: [ // these are actually also the endpoints
{value: "value-1", label: "Red", uuid: "endpoint-1"},
{value: "value-2", label: "Blue", uuid: "endpoint-2"}
]
},
{
uuid: "state-2",
name: "Message 2",
store_as: "message-2",
type: "freetext",
store_on_contact: true,
entry_endpoint: "endpoint-3",
// freetext specific
exit_endpoint: "endpoint-4",
text: "What is your name?"
},
{
uuid: "state-3",
name: "Ending 1",
store_as: "ending-1",
type: "end",
store_on_contact: true,
entry_endpoint: "endpoint-5",
// end specific
text: "Thank you for taking our survey"
}
],
connections: [
{
source: {uuid: "endpoint-1"},
target: {uuid: "endpoint-2"}
}
]
};

```