typeform

package module
v0.0.0-...-4b13e88 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 8 Imported by: 0

README

typeform-processor

The typeform-processor takes care of parsing the response from the notification end-point and provides functionality to enable and persist the notification endpoint at Typeform

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

Init wraps the reading from env and setting up the webhook functionality

Types

type Answer

type Answer struct {
	Type    string      `json:"type,required"`
	Text    string      `json:"text,omitempty"`
	Field   AnswerField `json:"field"`
	Email   string      `json:"email,omitempty"`
	Date    string      `json:"date,omitempty"`
	Choices Choices     `json:"choices"`
	Number  int64       `json:"number,omitempty"`
	Boolean bool        `json:"boolean,omitempty"`
	Choice  Choice      `json:"choice,omitempty"`
}

Answer ...

type AnswerField

type AnswerField struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

AnswerField ...

type Calculated

type Calculated struct {
	Score int64 `json:"score"`
}

Calculated ...

type Choice

type Choice struct {
	Label string `json:"label"`
}

Choice ...

type Choices

type Choices struct {
	Labels []string `json:"labels"`
}

Choices ...

type Configuration

type Configuration struct {
	ID      []string `env:"TYPEFORM_ID,required"`
	Tag     string   `env:"TYPEFORM_TAG,required"`
	Token   string   `env:"TYPEFORM_TOKEN,required"`
	FormURL string   `env:"TYPEFORM_URL,required"`
	BaseURL string   `env:"TYPEFORM_BASEURL,default=https://api.typeform.com"`
}

Configuration allows multiple endpoints to be defined from the envs

type Definition

type Definition struct {
	ID     string         `json:"id"`
	Title  string         `json:"title"`
	Fields []FieldElement `json:"fields"`
}

Definition ...

type Endpoint

type Endpoint struct {
	ID      string `env:"TYPEFORM_ID,required"`
	Tag     string `env:"TYPEFORM_TAG,required"`
	Token   string `env:"TYPEFORM_TOKEN,required"`
	FormURL string `env:"TYPEFORM_URL,required"`
	BaseURL string `env:"TYPEFORM_BASEURL,default=https://api.typeform.com"`
}

Endpoint is the specific configuration per endpoint to be used

type FieldElement

type FieldElement struct {
	ID                      string `json:"id"`
	Title                   string `json:"title"`
	Type                    string `json:"type"`
	Ref                     string `json:"ref"`
	AllowMultipleSelections bool   `json:"allow_multiple_selections"`
	AllowOtherChoice        bool   `json:"allow_other_choice"`
}

FieldElement ...

type FormResponse

type FormResponse struct {
	FormID      string     `json:"form_id,required"`
	Token       string     `json:"token,required"`
	SubmittedAt string     `json:"submitted_at,required"`
	LandedAt    string     `json:"landed_at,required"`
	Calculated  Calculated `json:"calculated,required"`
	Definition  Definition `json:"definition,required"`
	Answers     []Answer   `json:"answers,required"`
	Hidden      Hidden     `json:"hidden,required"`
}

FormResponse ...

type Hidden

type Hidden struct {
	User     string `json:"user"`
	T        string `json:"t"`
	Language string `json:"language"`
}

Hidden ...

type WebhookCreateRequest

type WebhookCreateRequest struct {
	URL     string `json:"url,required"`
	Enabled bool   `json:"enabled,required"`
}

WebhookCreateRequest ...

type WebhookCreateResponse

type WebhookCreateResponse struct {
	ID        string `json:"id,required"`
	FormID    string `json:"form_id,required"`
	Tag       string `json:"tag,required"`
	URL       string `json:"url,required"`
	Enabled   bool   `json:"enabled,required"`
	CreatedAt string `json:"created_at,required"`
	UpdatedAt string `json:"updated_at,required"`
}

WebhookCreateResponse ...

type WebhookDataResponse

type WebhookDataResponse struct {
	ID        string `json:"id,required"`
	FormID    string `json:"form_id,required"`
	Tag       string `json:"tag,required"`
	URL       string `json:"url,required"`
	Enabled   bool   `json:"enabled,required"`
	CreatedAt string `json:"created_at,required"`
	UpdatedAt string `json:"updated_at,required"`
}

WebhookDataResponse ...

type WebhookTypeform

type WebhookTypeform struct {
	EventID      string       `json:"event_id,required"`
	EventType    string       `json:"event_type,required"`
	FormResponse FormResponse `json:"form_response,required"`
}

WebhookTypeform ...

func ParseTypeformData

func ParseTypeformData(data []byte) (WebhookTypeform, error)

ParseTypeformData accepts a json and returns a WebhookTypeform struct

Jump to

Keyboard shortcuts

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