Skip to content

Simplistic api wrapper for Typeform api without abusing macro/dsl

License

Notifications You must be signed in to change notification settings

msoedov/ex_form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExForm

MIT licensed Deps Status Inline docs Hex Version Code TriagersBadge

Simplistic api wrapper for Typeform api without abusing macro/dsl.

For more information about api check Typeform docs

Link for API key

Sign up for one here.

Installation

If available in Hex, the package can be installed as:

  1. Add ex_form to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:ex_form, "~> 0.1.0"}]
end
```
  1. Ensure ex_form is started before your application:
```elixir
def application do
  [applications: [:ex_form]]
end
```

Examples

{:ok, form} = ExForm.new
|> ExForm.short_text("A short text", max_characters = 14)
|> ExForm.long_text("Long text here")
|> ExForm.yes_no("Will Trump win?")
|> ExForm.number("Lucky number?")
|> ExForm.opinion_scale("Rate this test?", "Could be better", "Okay", "Awesome")
|> ExForm.rating("Whatever")
|> ExForm.publish("Awesome form tittle", "http://requestb.in/112mjyd1")

iex> form
%{"_links" => [%{"href" => "https://api.typeform.io/v0.4/forms/xd6ZCNMK3h", "rel" => "self"}, %{"href" => "https://forms.typeform.io/to/JHSAzF4qLb", "rel" => "form_render"}, %{"href" => "https://api.typeform.io/v0.4/urls/JHSAzF4qLb", "rel" => "url"}], "fields" => [%{"id" => 49056886, "max_characters" => 14, "question" => "A short text", "type" => "short_text"}, %{"id" => 49056887, "question" => "Long text here", "type" => "long_text"}, %{"id" => 49056888, "question" => "Will Trump win?", "type" => "yes_no"}, %{"id" => 49056889, "question" => "Lucky number?", "type" => "number"}, %{"id" => 49056890, "labels" => %{"center" => "Okay", "left" => "Could be better", "right" => "Awesome"}, "question" => "Rate this test?", "steps" => 11, "type" => "opinion_scale"}, %{"id" => 49056891, "question" => "Whatever", "shape" => "star", "steps" => 5, "type" => "rating"}], "id" => "xd6ZCNMK3h", "tags" => ["deafult"], "title" => "Awesome form tittle", "urls" => [%{"form_id" => "xd6ZCNMK3h", "id" => "JHSAzF4qLb", "version" => "v0.4"}], "version" => "v0.4", "webhook_submit_url" => "http://requestb.in/112mjyd1"}

Just build and prepare

form_payload = ExForm.new
|> ExForm.short_text("A short text", max_characters = 14)
|> ExForm.long_text("Long text here")
|> ExForm.yes_no("Will Trump win?")
|> ExForm.number("Lucky number?")
|> ExForm.opinion_scale("Rate this test?", "Could be better", "Okay", "Awesome")
|> ExForm.rating("Whatever")
|> ExForm.build("Awesome form tittle", "http://requestb.in/112mjyd1")

Configuration

In order to run TYPE_SECRET should be set in env

export TYPE_SECRET=key-goes-here

About

Simplistic api wrapper for Typeform api without abusing macro/dsl

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages