typeform-ruby 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16124c8cc19ecf2ddf84303babef025c429126bc
4
- data.tar.gz: fb027dc8321502e6fc73023b97fdc0ec8e8c5df5
3
+ metadata.gz: df911a9835b60faafcd392086a96243b34cde88e
4
+ data.tar.gz: e20ae66e9fe1943511acee024e4a1336edf47db8
5
5
  SHA512:
6
- metadata.gz: 17e9b771231c876558a62167b4c6d85fdf23905b95bfe462d7f3f2aad4635a366cd3c8154d4b19930711ccaa1d2578ae69c49e5983ee5d36941f6271ace0310b
7
- data.tar.gz: 07378944905e980ad26c41c88b6d3b5b32621ef91d3d292c9dc3b32a9e89ca78fe14ef9215e56707ea7c146d7be6bd90549c02f4263b3fd64d2be53db128023f
6
+ metadata.gz: 2b1bf2db5c664c85c7fe25d7aa856dca488cd63254a5cc2f2c3bf79a6f1f44370d763f5de57f30aaa78544e4d3e6a095de3d2939d11e8456c14dea17d874d313
7
+ data.tar.gz: 02a4cac139638e66bc309c516934be46c8a8780ef9448b49796d2fa8c9409cc3679a1e459291b39b76050628fd95efebb2a1af7a2fc27a5796f1ee91d591d283
@@ -1,10 +1,17 @@
1
1
  {
2
- "title": "title",
2
+ "title": "Sandbox - Example #1",
3
3
  "fields": [
4
4
  {
5
- "type": "short_text",
6
- "question": "short_text"
5
+ "type": "multiple_choice",
6
+ "question": "How do you normally get to work?",
7
+ "choices": [
8
+ {
9
+ "label": "Metro"
10
+ },
11
+ {
12
+ "label": "Car"
13
+ }
14
+ ]
7
15
  }
8
- ],
9
- "webhook_submit_url": "https://webhook_submit_url.com"
16
+ ]
10
17
  }
@@ -6,25 +6,33 @@ typeform_api_key = ENV['TYPEFORM_API_KEY']
6
6
  client = Typeform::Client.new(typeform_api_key)
7
7
 
8
8
  # information
9
- pp client.information
9
+ # pp client.information.body
10
10
 
11
11
  # show form
12
- pp client.show_form("tPvxO8qyP6gIzg")
12
+ # pp client.show_form("tPvxO8qyP6gIzg")
13
13
 
14
14
  # create_form_from_json
15
- # field = Typeform::Field.new
16
- # field.type = "multiple_choice"
17
- # field.question = "What is your name?"
18
- # field.description = "description"
19
- # field.required = false
20
- # field.choices = [{label: "A"}]
21
- # form = Typeform::Form.new
22
- # form.title = "title"
23
- # form.fields = [field]
24
- # form.design_id = "design_id"
25
- # form.webhook_submit_url = "https://webhook_submit_url.com"
26
- # pp client.create_form_from_json(form.as_json).body
15
+ choice1 = Typeform::Choice.new
16
+ choice1.label = "Metro"
17
+ choice2 = Typeform::Choice.new
18
+ choice2.label = "Car"
19
+
20
+ field1 = Typeform::Field.new
21
+ field1.type = "multiple_choice"
22
+ field1.question = "How do you normally get to work?"
23
+ field1.description = "On most days..."
24
+ field1.required = false
25
+ field1.choices = [choice1, choice2]
26
+
27
+ form = Typeform::Form.new
28
+ form.title = "title"
29
+ form.fields = [field1]
30
+ form.webhook_submit_url = "http://webhook_submit_url.com"
31
+
32
+ pp form.as_json
33
+
34
+ pp client.create_form_from_json(form.as_json).body
27
35
 
28
36
  # create_form_from_file
29
- file = File.open("example/example.json")
30
- pp client.create_form_from_file(file)
37
+ # file = File.open("example/example.json")
38
+ # pp client.create_form_from_file(file)
@@ -0,0 +1,13 @@
1
+ module Typeform
2
+ class Choice
3
+ include JSON::Encodable
4
+
5
+ property :label, type: String
6
+
7
+ attr_accessor :label
8
+
9
+ def label
10
+ @label
11
+ end
12
+ end
13
+ end
@@ -2,6 +2,7 @@ require "typeform/version"
2
2
  require "typeform/connection"
3
3
  require "typeform/form"
4
4
  require "typeform/field"
5
+ require "typeform/choice"
5
6
  require "faraday"
6
7
  require "faraday_middleware"
7
8
  require "json"
@@ -20,7 +20,7 @@ module Typeform
20
20
  end
21
21
 
22
22
  def design_id
23
- @design_id
23
+ @design_id ||= ""
24
24
  end
25
25
 
26
26
  def webhook_submit_url
@@ -1,3 +1,3 @@
1
1
  module Typeform
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typeform-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Takiguchi
@@ -155,6 +155,7 @@ files:
155
155
  - example/example.rb
156
156
  - example/index.html
157
157
  - lib/typeform.rb
158
+ - lib/typeform/choice.rb
158
159
  - lib/typeform/client.rb
159
160
  - lib/typeform/connection.rb
160
161
  - lib/typeform/field.rb