typeform_data 0.2.0 → 1.0.0
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 +4 -4
- data/.rubocop.yml +6 -0
- data/README.md +1 -1
- data/lib/typeform_data/typeform/answer.rb +18 -0
- data/lib/typeform_data/typeform.rb +6 -4
- data/lib/typeform_data/value_class.rb +1 -1
- data/lib/typeform_data/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edd3d6b08e718fd4c2429253873d9c5b269774d6
|
4
|
+
data.tar.gz: 8939f372f3a5fba107d4879b56ee04c02c2a885b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d54650fab170d77b860f49d9839d88039f2280ccf24401272f089ba303ce51cc1839628f8980bb2e5bb35256d481318c5cccd4ceb6672c42b821980c4d534111
|
7
|
+
data.tar.gz: dd0308219f6e615bb0ac9e2218b450246c116212ac54fc1876261f4432aee99e53c9621ad9cb7fd4127b02ffc15e90631f65189e2a9ed45a85dce8bb17156b95
|
data/.rubocop.yml
CHANGED
@@ -146,3 +146,9 @@ Style/CaseIndentation:
|
|
146
146
|
# !something.nil? isn't a good solution. I wish Ruby had a to_b ("to boolean") method.
|
147
147
|
Style/DoubleNegation:
|
148
148
|
Enabled: false
|
149
|
+
|
150
|
+
# Marshal#load is a security concern, but we rely on it for serialization. The end-user is
|
151
|
+
# responsible for ensuring any data they deserialize with TypeformData::Client#load comes from a
|
152
|
+
# trusted source.
|
153
|
+
Security/MarshalLoad:
|
154
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TypeformData
|
2
2
|
|
3
|
-
A Ruby client for Typeform's [Data API](https://www.typeform.com/help/data-api/). Our documentation is available [here](http://www.rubydoc.info/gems/typeform_data/TypeformData/Typeform).
|
3
|
+
A Ruby gem and client for Typeform's [Data API](https://www.typeform.com/help/data-api/). Our documentation is available [here](http://www.rubydoc.info/gems/typeform_data/TypeformData/Typeform).
|
4
4
|
|
5
5
|
## Usage:
|
6
6
|
|
@@ -40,6 +40,23 @@ module TypeformData
|
|
40
40
|
# same specificity as Fields.
|
41
41
|
#
|
42
42
|
# Use this method to create Answers when initializing a Response.
|
43
|
+
#
|
44
|
+
# @param config [TypeformData::Config]
|
45
|
+
# @param attrs [Hash] Looks like:
|
46
|
+
# {
|
47
|
+
# "completed"=>"1",
|
48
|
+
# "token"=>"581eec6b27c23dc70e047e4354944bfb",
|
49
|
+
# "metadata"=>{ ... },
|
50
|
+
# "hidden"=>{ ... },
|
51
|
+
# "answers"=>
|
52
|
+
# {
|
53
|
+
# "answer_id"=>"answer_value",
|
54
|
+
# ...
|
55
|
+
# },
|
56
|
+
# :typeform_id=>"OTFzVb"
|
57
|
+
# }
|
58
|
+
#
|
59
|
+
# @param fields [Array<TypeformData::Typeform::Field>]
|
43
60
|
# @return [Array<Answer>]
|
44
61
|
def self.from_response_attrs(config, attrs, fields)
|
45
62
|
(attrs[:answers] || attrs['answers']).group_by { |id, _value|
|
@@ -53,6 +70,7 @@ module TypeformData
|
|
53
70
|
raise UnexpectedError, 'Expected to find a matching field' unless matched
|
54
71
|
}
|
55
72
|
}.map { |field, ids_and_values|
|
73
|
+
# ids_and_values looks like [[id, value], [id, value], ...]
|
56
74
|
values = ids_and_values.map(&:last)
|
57
75
|
|
58
76
|
Answer.new(
|
@@ -74,7 +74,7 @@ module TypeformData
|
|
74
74
|
|
75
75
|
def fetch_questions
|
76
76
|
questions = responses_request(limit: 1)['questions'] || []
|
77
|
-
questions.map { |hash| Question.new(config, hash) }
|
77
|
+
questions.map { |hash| Question.new(config, hash.merge!(typeform_id: id)) }
|
78
78
|
end
|
79
79
|
|
80
80
|
def fetch_stats
|
@@ -118,7 +118,9 @@ module TypeformData
|
|
118
118
|
|
119
119
|
# rubocop:disable Style/AccessorMethodName
|
120
120
|
def set_questions(questions_hashes = [])
|
121
|
-
@_questions = questions_hashes.map { |hash|
|
121
|
+
@_questions = questions_hashes.map { |hash|
|
122
|
+
Question.new(config, hash.merge(typeform_id: id))
|
123
|
+
}
|
122
124
|
end
|
123
125
|
|
124
126
|
# @param [Hash] stats_hash of the form {"responses"=>{"showing"=>2, "total"=>2, "completed"=>0}}
|
@@ -131,8 +133,8 @@ module TypeformData
|
|
131
133
|
'completed' => Object,
|
132
134
|
'since' => Object,
|
133
135
|
'until' => Object,
|
134
|
-
'offset' =>
|
135
|
-
'limit' =>
|
136
|
+
'offset' => Integer,
|
137
|
+
'limit' => Integer,
|
136
138
|
'token' => String,
|
137
139
|
}.freeze
|
138
140
|
|
@@ -51,7 +51,7 @@ module TypeformData
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
#
|
54
|
+
# Compound classes (e.g. a Response which has many Answers) should use this method to re-set
|
55
55
|
# 'config' on each child object. ValueClass#reconfig is called in TypeformData#load.
|
56
56
|
def reconfig(config)
|
57
57
|
self.config = config
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typeform_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Wallace
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|