rubytypeformio 0.1.0 → 0.1.1

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: 84ee277300c3b9600e243a4bcc07f8a217ed57f1
4
- data.tar.gz: 1f8038f3b6f8036c5feb8fd976adad1928171dfa
3
+ metadata.gz: bbe41659dcaa2877b00b11944f59b9b712095ab8
4
+ data.tar.gz: 31419b54d09ae959eb91b1cf9695378159c8817d
5
5
  SHA512:
6
- metadata.gz: cbe6ec49f5fd090752b330a9f23463052cb6204347448be5c3d9faeee7e275a3bbf28ecd61811facdbc76f09a3d188077d9f8390192260a6fe793b31ad826795
7
- data.tar.gz: c2fe809dba18509fe863ef90de41b89e0c0ab7822e564a81f073aadcdaf2875dd521be5363040c080ec4d81954c8092bf9b65a8f7d1a9a09e13919247111a5b2
6
+ metadata.gz: dd69c5a8bb5c25db7be6ca4f6e9465c84ca67956a2a764a1523c9bef42ee351e862019a11357ee23b1505f403a61ba7d26c6911fdfb4fb54b6571620e78a6953
7
+ data.tar.gz: 6f41b4825d5bdeab4b9f1ad5b2ab39bac4b8d6a31ef2d0c9bb1c6670efd728373871bb855b3e380af062aee1ea4c760264821acff3c4277c96e2b5a01e939e31
data/Gemfile CHANGED
@@ -2,3 +2,11 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rubytypeformio.gemspec
4
4
  gemspec
5
+
6
+ gem 'vcr', '2.9.3'
7
+ gem 'webmock', '1.21.0'
8
+ gem 'faraday', '0.9.1'
9
+ gem 'json', '1.8.3'
10
+ gem 'rspec', '3.3.0'
11
+ gem 'factory_girl', '4.5.0'
12
+ gem 'pry', '0.10.1'
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Rubytypeformio
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubytypeformio`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ A ruby client library for the typeform i/o api
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,25 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ See [examples/examples.rb](https://github.com/zachgoldstein/rubytypeformio/blob/master/examples/examples.rb) for full examples
24
+
25
+ 2 second example:
26
+ ```ruby
27
+
28
+ # First create the fields...
29
+ short_field = Rubytypeformio::ShortTextField.new('will it work?', 'test short text field', true)
30
+ long_field = Rubytypeformio::LongTextField.new('will it work?', 'test long text field', true)
31
+
32
+ # Then create your form...
33
+ form = Rubytypeformio::Form.new('A simple form', 'http://311008e2.ngrok.io', 123, [short_field, long_field]])
34
+
35
+ # Then post it to issue the request against the typeform API. This returns a new form object with the response data
36
+ created_form = form.post
37
+
38
+ # And now you can do what you will with it!
39
+ puts "Form url: " + created_form.links[1].rel
40
+
41
+ ```
26
42
 
27
43
  ## Development
28
44
 
@@ -32,8 +48,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
48
 
33
49
  ## Contributing
34
50
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubytypeformio. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
-
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zachgolstein/rubytypeformio. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
37
52
 
38
53
  ## License
39
54
 
@@ -0,0 +1,82 @@
1
+ require_relative '../lib/rubytypeformio'
2
+ require 'json'
3
+
4
+ puts 'We are running'
5
+
6
+ field = Rubytypeformio::Field.new('test field', 'will it work?', true, 'short_text')
7
+ # Testing json<->ruby obj conversions
8
+ # puts "manually created new field"
9
+ # puts field.pretty
10
+ # puts "question: " + field.question
11
+ #
12
+ # puts "new field json:" + field.to_json.to_s
13
+ # json_obj = field.to_json
14
+ #
15
+ # new_field = Rubytypeformio::Field.from_json(json_obj)
16
+ # puts "unmarshalled new field"
17
+ # puts new_field.pretty
18
+ # puts "question: " + new_field.question
19
+
20
+ short_field = Rubytypeformio::ShortTextField.new('will it work?', 'test short text field', true)
21
+ long_field = Rubytypeformio::LongTextField.new('will it work?', 'test long text field', true)
22
+ statement_field = Rubytypeformio::StatementField.new('will it work?', 'test statement field', true)
23
+
24
+ good_choice = Rubytypeformio::Choice.new('good')
25
+ bad_choice = Rubytypeformio::Choice.new('bad')
26
+ choices = [good_choice, bad_choice]
27
+ mc_field = Rubytypeformio::MultipleChoiceField.new('which option would you pick?', 'test multiple choice field', true, choices)
28
+
29
+ left_choice = Rubytypeformio::Choice.new('good')
30
+ right_choice = Rubytypeformio::Choice.new('bad')
31
+ left_choice.image_id = 123
32
+ right_choice.image_id = 245
33
+ choices = [left_choice, right_choice]
34
+ pc_field = Rubytypeformio::PictureChoiceField.new('which option would you pick?', 'test picture choice field', true, choices)
35
+
36
+ top_choice = Rubytypeformio::Choice.new('top')
37
+ bottom_choice = Rubytypeformio::Choice.new('bottom')
38
+ choices = [top_choice, bottom_choice]
39
+ dropdown_field = Rubytypeformio::DropdownField.new('which option would you pick?', 'test picture choice field', true, choices)
40
+
41
+
42
+ opinion_field = Rubytypeformio::OpinionField.new('will it work?', 'test statement field', true)
43
+ rating_field = Rubytypeformio::RatingField.new('will it work?', 'test rating field', true)
44
+ number_field = Rubytypeformio::NumberField.new('will it work?', 'test number field', true)
45
+ website_field = Rubytypeformio::WebsiteField.new('will it work?', 'test website field', true)
46
+ email_field = Rubytypeformio::EmailField.new('will it work?', 'test email field', true)
47
+ legal_field = Rubytypeformio::LegalField.new('will it work?', 'test legal field', true)
48
+ yesno_field = Rubytypeformio::YesNoField.new('will it work?', 'test yes no field', true)
49
+
50
+ fields = [
51
+ field,
52
+ short_field,
53
+ long_field,
54
+ statement_field,
55
+ mc_field,
56
+ pc_field,
57
+ dropdown_field,
58
+ opinion_field,
59
+ rating_field,
60
+ number_field,
61
+ website_field,
62
+ email_field,
63
+ legal_field,
64
+ yesno_field
65
+ ]
66
+
67
+ form = Rubytypeformio::Form.new('A simple form', 'http://311008e2.ngrok.io', 123, fields)
68
+ puts "manually created new form"
69
+ puts form.pretty
70
+
71
+ json_obj = form.to_json
72
+ new_form = Rubytypeformio::Form.from_json(json_obj)
73
+ # Test json<->ruby obj
74
+ # puts "unmarshalled new form"
75
+ # puts new_form.pretty
76
+
77
+ created_form = new_form.post
78
+ puts "created form remotely"
79
+ puts created_form.pretty
80
+
81
+ puts "Form url: " + created_form.links[1].rel
82
+
@@ -1,9 +1,36 @@
1
- require "rubytypeformio/version"
1
+ require_relative 'rubytypeformio/version'
2
2
 
3
- module Rubytypeformio
3
+ require_relative 'rubytypeformio/base'
4
+
5
+ require_relative 'rubytypeformio/field'
6
+ require_relative 'rubytypeformio/short_text_field'
7
+ require_relative 'rubytypeformio/long_text_field'
8
+ require_relative 'rubytypeformio/statement_field'
9
+ require_relative 'rubytypeformio/choice_field'
10
+ require_relative 'rubytypeformio/multiple_choice_field'
11
+ require_relative 'rubytypeformio/picture_choice_field'
12
+ require_relative 'rubytypeformio/dropdown_field'
13
+ require_relative 'rubytypeformio/opinion_field'
14
+ require_relative 'rubytypeformio/rating_field'
15
+ require_relative 'rubytypeformio/email_field'
16
+ require_relative 'rubytypeformio/website_field'
17
+ require_relative 'rubytypeformio/legal_field'
18
+ require_relative 'rubytypeformio/yes_no_field'
19
+
20
+ require_relative 'rubytypeformio/link'
21
+ require_relative 'rubytypeformio/choice'
4
22
 
23
+ require_relative 'rubytypeformio/client'
24
+ require_relative 'rubytypeformio/form'
25
+
26
+ module Rubytypeformio
5
27
  def hi
6
28
  puts 'O HAI'
7
- end
8
29
 
30
+ # Make request to typeform api with faraday
31
+
32
+
33
+
34
+ end
9
35
  end
36
+
@@ -0,0 +1,31 @@
1
+ require 'json'
2
+
3
+ module Rubytypeformio
4
+
5
+ class Base
6
+
7
+ def pretty
8
+ # pry
9
+ puts JSON.pretty_generate(self.to_h)
10
+ end
11
+
12
+ def compact(hash)
13
+ # hash.delete_if { |k, v| v.nil? }
14
+ hash.delete_if { |key, value| value.to_s.strip == '' }
15
+ end
16
+
17
+ private
18
+
19
+ def to_snake_case(string)
20
+ string.gsub(/::/, '/').
21
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
22
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
23
+ tr("-", "_").
24
+ downcase
25
+ end
26
+
27
+ end
28
+ end
29
+
30
+
31
+
@@ -0,0 +1,33 @@
1
+ require 'json'
2
+ require_relative 'base'
3
+
4
+ module Rubytypeformio
5
+
6
+ class Choice < Base
7
+ attr_accessor :image_id, :label
8
+
9
+ def initialize (label)
10
+ @label = label
11
+ end
12
+
13
+ def to_json
14
+ JSON.dump(self.to_h)
15
+ end
16
+
17
+ def to_h
18
+ return {
19
+ :image_id => @image_id,
20
+ :label => @label
21
+ }
22
+ end
23
+
24
+ def self.from_json(string)
25
+ data = JSON.load(string)
26
+ obj = self.new( data["label"])
27
+ if (data["image_id"])
28
+ obj.image_id = data["image_id"]
29
+ end
30
+ return obj
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'field'
2
+ require_relative 'choice'
3
+
4
+ module Rubytypeformio
5
+ class ChoiceField < Field
6
+
7
+ attr_accessor :choices
8
+
9
+ def initialize (question, description, required, type, choices)
10
+ super(question, description, required, type)
11
+ @choices = choices
12
+ end
13
+
14
+ def to_h
15
+ hash = super.to_h
16
+
17
+ hash[:choices] = []
18
+ @choices.each { |c|
19
+ hash[:choices].push(c.to_h)
20
+ }
21
+ return hash
22
+ end
23
+
24
+ end
25
+ end
26
+
@@ -0,0 +1,13 @@
1
+ module Rubytypeformio
2
+
3
+ class Client
4
+
5
+ attr_accessor :auth_token
6
+
7
+ def initialize (auth_token)
8
+
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,31 @@
1
+ require_relative 'choice_field'
2
+
3
+ module Rubytypeformio
4
+ class DropdownField < ChoiceField
5
+
6
+ def initialize (question, description, required, choices)
7
+ return super(question, description, required, 'dropdown', choices)
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+
13
+ choices = []
14
+ if (!data["choices"].nil?)
15
+ data["choices"].each { |f|
16
+ choices.push(Rubytypeformio::Choice.from_json(f.to_json))
17
+ }
18
+ end
19
+
20
+ obj = self.new( data["question"],
21
+ data["description"],
22
+ data["required"],
23
+ choices)
24
+ obj.id = data["id"]
25
+
26
+ return obj
27
+ end
28
+
29
+
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+ class EmailField < Field
5
+
6
+ def initialize (question, description, required)
7
+ return super(question, description, required, 'email')
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+ obj = self.new( data["question"],
13
+ data["description"],
14
+ data["required"])
15
+ obj.id = data["id"]
16
+ return obj
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,40 @@
1
+ require 'json'
2
+ require_relative 'base'
3
+
4
+ module Rubytypeformio
5
+
6
+ class Field < Base
7
+ attr_accessor :id, :description, :question, :required, :type
8
+
9
+ def initialize (question, description, required, type)
10
+ @description = description
11
+ @question = question
12
+ @required = required
13
+ @type = type
14
+ end
15
+
16
+ def to_json
17
+ JSON.dump(self.to_h)
18
+ end
19
+
20
+ def to_h
21
+ hash = {
22
+ :description => @description,
23
+ :question => @question,
24
+ :required => @required,
25
+ :type => @type,
26
+ :id => @id,
27
+ }
28
+ end
29
+
30
+ def self.from_json(string)
31
+ data = JSON.load(string)
32
+ obj = self.new( data["description"],
33
+ data["question"],
34
+ data["required"],
35
+ data["type"] )
36
+ obj.id = data["id"]
37
+ return obj
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,150 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ require_relative 'base'
5
+ require_relative 'field'
6
+ require_relative 'link'
7
+
8
+ require_relative 'short_text_field'
9
+ require_relative 'long_text_field'
10
+ require_relative 'statement_field'
11
+ require_relative 'multiple_choice_field'
12
+ require_relative 'picture_choice_field'
13
+ require_relative 'dropdown_field'
14
+ require_relative 'opinion_field'
15
+ require_relative 'rating_field'
16
+ require_relative 'number_field'
17
+ require_relative 'website_field'
18
+ require_relative 'email_field'
19
+ require_relative 'legal_field'
20
+ require_relative 'yes_no_field'
21
+
22
+ module Rubytypeformio
23
+
24
+ class Form < Base
25
+
26
+ attr_accessor :id, :links, :title, :design_id, :webhook_submit_url, :fields
27
+
28
+ def initialize (title, webhook, design_id, fields)
29
+ @title = title
30
+ @webhook_submit_url = webhook
31
+ @design_id = design_id
32
+ @fields = fields
33
+ end
34
+
35
+ def to_h
36
+ hash = {
37
+ :id => @id,
38
+ :title => @title,
39
+ :design_id => @design_id,
40
+ :webhook_submit_url => @webhook_submit_url
41
+ }
42
+
43
+ hash[:fields] = []
44
+ @fields.each { |f|
45
+ hash[:fields].push(f.to_h)
46
+ }
47
+ hash[:links] = []
48
+ if (!@links.nil?)
49
+ @links.each { |l|
50
+ hash[:links].push(l.to_h)
51
+ }
52
+ end
53
+
54
+ return hash
55
+
56
+ end
57
+
58
+ def to_json
59
+ JSON.dump(self.to_h)
60
+ end
61
+
62
+ def self.from_json(string)
63
+ data = JSON.load(string)
64
+ fields = []
65
+ data["fields"].each { |f|
66
+
67
+ # @TODO: figure out a cleaner way to do this case statement
68
+ case f["type"]
69
+ when 'short_text'
70
+ fields.push(Rubytypeformio::ShortTextField.from_json(f.to_json))
71
+ when 'long_text_field'
72
+ fields.push(Rubytypeformio::LongTextField.from_json(f.to_json))
73
+ when 'statement'
74
+ fields.push(Rubytypeformio::StatementField.from_json(f.to_json))
75
+ when 'multiple_choice'
76
+ fields.push(Rubytypeformio::MultipleChoiceField.from_json(f.to_json))
77
+ when 'picture_choice'
78
+ fields.push(Rubytypeformio::PictureChoiceField.from_json(f.to_json))
79
+ when 'dropdown'
80
+ fields.push(Rubytypeformio::DropdownField.from_json(f.to_json))
81
+ when 'yes_no'
82
+ fields.push(Rubytypeformio::YesNoField.from_json(f.to_json))
83
+ when 'number'
84
+ fields.push(Rubytypeformio::NumberField.from_json(f.to_json))
85
+ when 'rating'
86
+ fields.push(Rubytypeformio::RatingField.from_json(f.to_json))
87
+ when 'opinion_scale'
88
+ fields.push(Rubytypeformio::OpinionField.from_json(f.to_json))
89
+ when 'email'
90
+ fields.push(Rubytypeformio::EmailField.from_json(f.to_json))
91
+ when 'website'
92
+ fields.push(Rubytypeformio::WebsiteField.from_json(f.to_json))
93
+ when 'legal'
94
+ fields.push(Rubytypeformio::LegalField.from_json(f.to_json))
95
+ else
96
+ fields.push(Rubytypeformio::Field.from_json(f.to_json))
97
+ end
98
+
99
+ }
100
+
101
+ obj = self.new(data["title"],
102
+ data["webhook_submit_url"],
103
+ data["design_id"],
104
+ fields)
105
+
106
+ if (data["links"])
107
+ links = []
108
+ data["links"].each { |l|
109
+ links.push(Rubytypeformio::Link.from_json(l.to_json))
110
+ }
111
+ obj.links = links
112
+ end
113
+
114
+ if (data["id"])
115
+ obj.id = data["id"]
116
+ end
117
+
118
+ return obj
119
+ end
120
+
121
+ # @return [Form]
122
+ def post
123
+
124
+ if (ENV["TYPEFORM_KEY"].nil?)
125
+ puts "no typeform key set"
126
+ return nil
127
+ end
128
+
129
+ puts 'creating new form with API'
130
+
131
+ conn = Faraday.new(:url => 'https://api.typeform.io') do |faraday|
132
+ faraday.request :url_encoded
133
+ faraday.response :logger
134
+ faraday.adapter Faraday.default_adapter
135
+ end
136
+
137
+ resp = conn.post do |req|
138
+ req.url 'https://api.typeform.io/v0.3/forms'
139
+ req.headers['x-api-token'] = ENV["TYPEFORM_KEY"]
140
+ req.body = self.compact(self.to_h).to_json.to_s
141
+
142
+ puts "REQUEST: " + req.to_s
143
+ end
144
+
145
+ return Rubytypeformio::Form.from_json(resp.body)
146
+ end
147
+
148
+ end
149
+
150
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+ class LegalField < Field
5
+
6
+ def initialize (question, description, required)
7
+ return super(question, description, required, 'legal')
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+ obj = self.new( data["question"],
13
+ data["description"],
14
+ data["required"])
15
+ obj.id = data["id"]
16
+ return obj
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,32 @@
1
+ require 'json'
2
+ require_relative 'base'
3
+
4
+ module Rubytypeformio
5
+
6
+ class Link < Base
7
+ attr_accessor :href, :rel
8
+
9
+ def initialize (rel, href)
10
+ @rel = rel
11
+ @href = href
12
+ end
13
+
14
+ def to_json
15
+ JSON.dump(self.to_h)
16
+ end
17
+
18
+ def to_h
19
+ return {
20
+ :href => @href,
21
+ :rel => @rel
22
+ }
23
+ end
24
+
25
+ def self.from_json(string)
26
+ data = JSON.load(string)
27
+ obj = self.new( data["href"],
28
+ data["rel"])
29
+ return obj
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+
5
+ class LongTextField < Field
6
+
7
+ def initialize (question, description, required)
8
+ super(question, description, required, 'long_text')
9
+ end
10
+
11
+ def self.from_json(string)
12
+ data = JSON.load(string)
13
+ obj = self.new( data["question"],
14
+ data["description"],
15
+ data["required"])
16
+ obj.id = data["id"]
17
+ return obj
18
+ end
19
+
20
+ end
21
+ end
22
+
@@ -0,0 +1,31 @@
1
+ require_relative 'choice_field'
2
+
3
+ module Rubytypeformio
4
+ class MultipleChoiceField < ChoiceField
5
+
6
+ def initialize (question, description, required, choices)
7
+ return super(question, description, required, 'multiple_choice', choices)
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+
13
+ choices = []
14
+ if (!data["choices"].nil?)
15
+ data["choices"].each { |f|
16
+ choices.push(Rubytypeformio::Choice.from_json(f.to_json))
17
+ }
18
+ end
19
+
20
+ obj = self.new( data["question"],
21
+ data["description"],
22
+ data["required"],
23
+ choices)
24
+ obj.id = data["id"]
25
+
26
+ return obj
27
+ end
28
+
29
+
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+ class NumberField < Field
5
+
6
+ def initialize (question, description, required)
7
+ return super(question, description, required, 'number')
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+ obj = self.new( data["question"],
13
+ data["description"],
14
+ data["required"])
15
+ obj.id = data["id"]
16
+ return obj
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,21 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+ class OpinionField < Field
5
+
6
+ def initialize (question, description, required)
7
+ return super(question, description, required, 'opinion_scale')
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+ obj = self.new( data["question"],
13
+ data["description"],
14
+ data["required"])
15
+ obj.id = data["id"]
16
+ return obj
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,30 @@
1
+ require_relative 'multiple_choice_field'
2
+
3
+ module Rubytypeformio
4
+ class PictureChoiceField < ChoiceField
5
+
6
+ def initialize (question, description, required, choices)
7
+ return super(question, description, required, 'picture_choice', choices)
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+
13
+ choices = []
14
+ if (!data["choices"].nil?)
15
+ data["choices"].each { |f|
16
+ choices.push(Rubytypeformio::Choice.from_json(f.to_json))
17
+ }
18
+ end
19
+
20
+ obj = self.new( data["question"],
21
+ data["description"],
22
+ data["required"],
23
+ choices)
24
+ obj.id = data["id"]
25
+
26
+ return obj
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+ class RatingField < Field
5
+
6
+ def initialize (question, description, required)
7
+ return super(question, description, required, 'rating')
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+ obj = self.new( data["question"],
13
+ data["description"],
14
+ data["required"])
15
+ obj.id = data["id"]
16
+ return obj
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,22 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+
5
+ class ShortTextField < Field
6
+
7
+ def initialize (question, description, required)
8
+ super(question, description, required, 'short_text')
9
+ end
10
+
11
+ def self.from_json(string)
12
+ data = JSON.load(string)
13
+ obj = self.new( data["question"],
14
+ data["description"],
15
+ data["required"])
16
+ obj.id = data["id"]
17
+ return obj
18
+ end
19
+
20
+ end
21
+ end
22
+
@@ -0,0 +1,21 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+ class StatementField < Field
5
+
6
+ def initialize (question, description, required)
7
+ return super(question, description, required, 'statement')
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+ obj = self.new( data["question"],
13
+ data["description"],
14
+ data["required"])
15
+ obj.id = data["id"]
16
+ return obj
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -1,3 +1,3 @@
1
1
  module Rubytypeformio
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,21 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+ class WebsiteField < Field
5
+
6
+ def initialize (question, description, required)
7
+ return super(question, description, required, 'website')
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+ obj = self.new( data["question"],
13
+ data["description"],
14
+ data["required"])
15
+ obj.id = data["id"]
16
+ return obj
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,21 @@
1
+ require_relative 'field'
2
+
3
+ module Rubytypeformio
4
+ class YesNoField < Field
5
+
6
+ def initialize (question, description, required)
7
+ return super(question, description, required, 'yes_no')
8
+ end
9
+
10
+ def self.from_json(string)
11
+ data = JSON.load(string)
12
+ obj = self.new( data["question"],
13
+ data["description"],
14
+ data["required"])
15
+ obj.id = data["id"]
16
+ return obj
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["zachgold@gmail.com"]
11
11
 
12
12
  spec.summary = %q{A simple API wrapper for typeformio.}
13
- spec.description = %q{A simple API wrapper for typeformio.}
13
+ spec.description = %q{Wraps the api to provide convenience methods for interacting with the api.}
14
14
  spec.homepage = "https://github.com/zachgoldstein/rubytypeformio"
15
15
  spec.license = "MIT"
16
16
 
@@ -20,6 +20,14 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.10"
24
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "bundler", "1.10.5"
24
+ spec.add_development_dependency "rake", "10.4.2"
25
+ spec.add_development_dependency "rspec", "3.3.0"
26
+ spec.add_development_dependency "vcr", "2.9.3"
27
+ spec.add_development_dependency "webmock", "1.21.0"
28
+ spec.add_development_dependency "pry", "0.10.1"
29
+
30
+ spec.add_dependency "faraday", "0.9.1"
31
+ spec.add_dependency "json", "1.8.3"
32
+
25
33
  end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Rubytypeformio::Form do
4
+
5
+ it 'queries typeform io to check auth' do
6
+ puts "TESTING???"
7
+ end
8
+
9
+ end
10
+
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'factory_girl'
3
+ require 'rspec'
4
+ require 'rubytypeformio'
5
+
6
+ RSpec.configure do |config|
7
+ config.include FactoryGirl::Syntax::Methods
8
+ end
metadata CHANGED
@@ -1,44 +1,129 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubytypeformio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Goldstein
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: 1.10.5
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: 1.10.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 10.4.2
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
41
- description: A simple API wrapper for typeformio.
40
+ version: 10.4.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.3.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.9.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.9.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.21.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.21.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.10.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: json
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.8.3
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.8.3
125
+ description: Wraps the api to provide convenience methods for interacting with the
126
+ api.
42
127
  email:
43
128
  - zachgold@gmail.com
44
129
  executables: []
@@ -52,9 +137,32 @@ files:
52
137
  - LICENSE.txt
53
138
  - README.md
54
139
  - Rakefile
140
+ - examples/examples.rb
55
141
  - lib/rubytypeformio.rb
142
+ - lib/rubytypeformio/base.rb
143
+ - lib/rubytypeformio/choice.rb
144
+ - lib/rubytypeformio/choice_field.rb
145
+ - lib/rubytypeformio/client.rb
146
+ - lib/rubytypeformio/dropdown_field.rb
147
+ - lib/rubytypeformio/email_field.rb
148
+ - lib/rubytypeformio/field.rb
149
+ - lib/rubytypeformio/form.rb
150
+ - lib/rubytypeformio/legal_field.rb
151
+ - lib/rubytypeformio/link.rb
152
+ - lib/rubytypeformio/long_text_field.rb
153
+ - lib/rubytypeformio/multiple_choice_field.rb
154
+ - lib/rubytypeformio/number_field.rb
155
+ - lib/rubytypeformio/opinion_field.rb
156
+ - lib/rubytypeformio/picture_choice_field.rb
157
+ - lib/rubytypeformio/rating_field.rb
158
+ - lib/rubytypeformio/short_text_field.rb
159
+ - lib/rubytypeformio/statement_field.rb
56
160
  - lib/rubytypeformio/version.rb
161
+ - lib/rubytypeformio/website_field.rb
162
+ - lib/rubytypeformio/yes_no_field.rb
57
163
  - rubytypeformio.gemspec
164
+ - spec/client_spec.rb
165
+ - spec/spec_helper.rb
58
166
  homepage: https://github.com/zachgoldstein/rubytypeformio
59
167
  licenses:
60
168
  - MIT
@@ -79,4 +187,6 @@ rubygems_version: 2.4.6
79
187
  signing_key:
80
188
  specification_version: 4
81
189
  summary: A simple API wrapper for typeformio.
82
- test_files: []
190
+ test_files:
191
+ - spec/client_spec.rb
192
+ - spec/spec_helper.rb