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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c89b3a3f4d42c31eb7caca0e233587b91c373b1
4
- data.tar.gz: 6dbaf654728b826e8d71cb81b75d3ddd18763192
3
+ metadata.gz: edd3d6b08e718fd4c2429253873d9c5b269774d6
4
+ data.tar.gz: 8939f372f3a5fba107d4879b56ee04c02c2a885b
5
5
  SHA512:
6
- metadata.gz: fe56f2ccbb13af7c74e7f14f6d95a97a117d5b995081ac906e8be85b62c979d9b852f271b72c00626ed3df074bc08b0cda7f94a1dcad8f74b4eb451881aee795
7
- data.tar.gz: 4bfddc0639cc2b3cb6b208f128e0ddf97ba7718a4c3d7b16c199fec49ac489d3b58a3c154eb0eda48d9378d437409e972ec76b47f4d1c89f581fa5e5967ff67e
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| Question.new(config, 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' => Fixnum,
135
- 'limit' => Fixnum,
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
- # Compond classes (e.g. a Response which has many Answers) should use this method to re-set
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module TypeformData
3
- VERSION = '0.2.0'
3
+ VERSION = '1.0.0'
4
4
  end
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.2.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: 2016-09-11 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler