Code Monkey home page Code Monkey logo

typeform-go's Introduction

typeform-go

Non-official Go library for the Typeform API. https://developer.typeform.com/

Installation

go get github.com/marotpam/typeform-go

Basic usage

// create a typeform client with a personal access token (see https://developer.typeform.com/get-started/personal-access-token/)
tfClient := typeform.NewDefaultClient("personalAccessToken")
svc := typeform.NewFormService(tfClient)

// create a new form
f, err := svc.Create(typeform.Form{
  Title: "a form created with typeform-go",
  Fields: []*typeform.Field{
    {
      Title: "do you like go?",
      Type:  typeform.FieldTypeYesNo,
    },
  },
})
if err != nil {
  log.Fatal(err)
}
log.Printf("typeform with id %s created\n", f.ID)

// retrieve an existing form
f, err = svc.Retrieve(f.ID)
if err != nil {
  log.Fatal(err)
}
log.Printf("typeform with id '%s' retrieved successfully\n", f.ID)

// update an existing form
f.Title = "updated form title"
f, err = svc.Update(f)
if err != nil {
  log.Fatal(err)
}
log.Printf("typeform's title is now '%s'\n", f.Title)

// list available forms filtered by params
l, err := svc.List(typeform.FormListParams{
  Search:      "form title",
  Page:        1,
  PageSize:    1,
  WorkspaceID: "workspaceID",
})
if err != nil {
  log.Fatal(err)
}
log.Printf("total number of forms: %d\n", l.TotalItems)

// delete an existing form
err = svc.Delete(f.ID)
if err != nil {
  log.Fatal(err)
}
log.Printf("typeform with id %s successfully deleted\n", f.ID)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.