typeform_data 4.0.0 → 5.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: d59e6ace3ebd1f11c50608dd55f8ab6473447540
4
- data.tar.gz: a56983d75dc15baa9b95c57401d208f025339f50
3
+ metadata.gz: 53983bf174d6a2657b1217c31b012e0c9001ae84
4
+ data.tar.gz: 78235d80e83fbc5621e921a3b7be9dcb1ff225d5
5
5
  SHA512:
6
- metadata.gz: 736daabbd96df999d30946e6c20d7b8b28d13562adb50c0b481f2bfd78c4c8e59532ea93753478863e26cf4b457bdcd1067f9199db8657ff7fbef2bf57ccdfbd
7
- data.tar.gz: 84873ab4d73b0f89be5a6fc01f2f5d9c9f4fe0535c6ab669fbc4842fdc95e173ec7b7446e1c6434df90deca6a352410787e563cc2dbefce14e0cd869c69386a3
6
+ metadata.gz: e5a863780ad0471d0c7064217ea6fa410b487d42173279635e567759338b0ee04ce3170409f53a0361dd7641d854a84b7c822f645da8fd556648200bd9bbc60a
7
+ data.tar.gz: 3b90e57b69fe8a8b793af87c56354ae4bc3d393b10f11db7a392181a6c6114dfd44ec0e0b97d0216d4cfba480df6064ef6bdef1627c9b686e26089e765f0d1d5
data/README.md CHANGED
@@ -49,7 +49,9 @@ typeform.responses.first.answers.map { |answer| [answer.field_text, answer.value
49
49
 
50
50
  ### Serialization & deserialization
51
51
 
52
- Your API key will not be serialized. `TypeformData::Client#dump` is just a pass-through to `Marshal#dump`, but `Client#load` will re-set your API key on each of the deserialized objects-- this ensures the object graph stays intact through the serialization process.
52
+ TypeformData supports serialization via both Marshal and JSON. In either case, your API key will not be serialized, and we throw an error if you attempt to serialize a `TypeformData::Client` instance.
53
+
54
+ When using Marshal, `TypeformData::Client#dump` is just a pass-through to `Marshal#dump`, but `Client#load` will re-set your API key on each of the deserialized objects-- this ensures the object graph stays intact through the serialization and deserialization process.
53
55
 
54
56
  ```
55
57
  serialized = client.dump(responses)
@@ -62,6 +64,8 @@ deserialized = client.load(serialized)
62
64
  => true
63
65
  ```
64
66
 
67
+ We do not yet support this sort of 'round-trip' serialization for JSON. PRs are welcome!
68
+
65
69
  ### Error-handling
66
70
 
67
71
  Unless you've encountered a bug, all exceptions raised by this gem should extend from `TypeformData::Error`. For the full exception hierarchy, see `lib/typeform_data/errors`.
@@ -30,7 +30,26 @@ module TypeformData
30
30
  set_questions(response['questions'])
31
31
 
32
32
  response['responses'].map { |api_hash|
33
- Response.new(config, api_hash.dup.tap { |hash| hash[:typeform_id] = id }, fields)
33
+ Response.new(
34
+ config,
35
+
36
+ api_hash.dup.tap { |hash|
37
+ hash[:typeform_id] = id
38
+
39
+ # Sadly, the API returns [] if there aren't any Hidden Fields, and { ... } if there
40
+ # are.
41
+ unless hash['hidden'].is_a?(Hash)
42
+ unless hash['hidden'] == []
43
+ config.logger.error "Received an unexpected value for a responses's hidden fields "\
44
+ "from the API: #{hash['hidden']}. Using {} instead. The full hash is:\n"\
45
+ "#{api_hash}"
46
+ end
47
+ hash['hidden'] = {}
48
+ end
49
+ },
50
+
51
+ fields,
52
+ )
34
53
  }
35
54
  end
36
55
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module TypeformData
3
- VERSION = '4.0.0'
3
+ VERSION = '5.0.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typeform_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Wallace
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-06-18 00:00:00.000000000 Z
12
+ date: 2017-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler