tyapi

package
v0.0.0-...-b237f9b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIToken string

Functions

func ListenAndServe

func ListenAndServe(addr string, cb func(*Results, *http.Request) error) error

ListenAndServe starts an http server at the given addr and requires a handler that will be called for each webhook request and passed a Results pointer. If an error is returned from the handler, a 500 response is sent and TypeForm will retry the request.

Note: the handler might be called multiple times for the same results set. You should store the Token for each call and verify you haven't already processed it.

Types

type BooleanValue

type BooleanValue bool

type ChoiceValue

type ChoiceValue struct {
	Label      string `json:"label"                 bson:"l,omitempty"`
	Other      string `json:"other,omitempty"       bson:"o,omitempty"`
	EmptyOther bool   `json:"-"                     bson:"eo,omitempty"`
}

ChoiceValue represents a number answer

func (*ChoiceValue) UnmarshalJSON

func (v *ChoiceValue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type ChoicesValue

type ChoicesValue struct {
	Labels     []string `json:"labels"              bson:"l,omitempty"`
	Other      string   `json:"other,omitempty"     bson:"o,omitempty"`
	EmptyOther bool     `json:"-"                   bson:"eo,omitempty"`
}

func (*ChoicesValue) UnmarshalJSON

func (v *ChoicesValue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type CreateResult

type CreateResult struct {
	ID   string `json:"id"`
	URLs []URLs `json:"urls"`
}

func Create

func Create(f *tyform.Form) (*CreateResult, error)

Creates a survey on typeform. Returns an `Error` if we get one.

type Error

type Error struct {
	ErrorType   string `json:"error"`
	Field       string `json:"field"`
	Description string `json:"description"`
}

func (Error) Error

func (e Error) Error() string

type NumberValue

type NumberValue struct {
	Amount int64 `json:"amount"                     bson:"a"`
}

NumberValue represents a number answer

type Results

type Results struct {
	UID     string             `json:"uid"          bson:"i"`
	Token   string             `json:"token"        bson:"t"`
	Answers ResultsAnswerSlice `json:"answers"      bson:"a"`
}

Results represents a single set of answers received from typeform via the webhook in response to someone taking a form

type ResultsAnswer

type ResultsAnswer struct {
	ResultsAnswerMetadata `bson:",inline"`
	Value                 interface{} `json:"value" bson:"v"`
}

ResultsAnswer is a single answer in the Results The Value can be many different types. See http://docs.typeform.io/docs/results-introduction

func (*ResultsAnswer) SetBSON

func (a *ResultsAnswer) SetBSON(raw bson.Raw) error

SetBSON implements the bson.Setter interface

func (*ResultsAnswer) String

func (a *ResultsAnswer) String() string

String returns a string version of the answer

func (*ResultsAnswer) UnmarshalJSON

func (a *ResultsAnswer) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type ResultsAnswerMetadata

type ResultsAnswerMetadata struct {
	FieldID int64    `json:"field_id" bson:"i"`
	Type    string   `json:"type" bson:"t"`
	Tags    []string `json:"tags,omitempty"         bson:"g,omitempty"`
}

ResultsAnswerMetadata is shared between the different forms of the answer

type ResultsAnswerSlice

type ResultsAnswerSlice []ResultsAnswer

ResultsAnswerSlice implements the sort interface and sorts by FieldID ascending

func (ResultsAnswerSlice) Len

func (s ResultsAnswerSlice) Len() int

Len implements the sort interface

func (ResultsAnswerSlice) Less

func (s ResultsAnswerSlice) Less(i, j int) bool

Less implements the sort interface

func (ResultsAnswerSlice) Swap

func (s ResultsAnswerSlice) Swap(i, j int)

Swap implements the sort interface

type TextValue

type TextValue string

type URLs

type URLs struct {
	ID      string `json:"id"`
	FormID  string `json:"form_id"`
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL