surveymonkey_api 0.2.1 → 0.2.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/surveymonkey_api/client/survey.rb +15 -2
- data/lib/surveymonkey_api/client.rb +17 -0
- data/lib/surveymonkey_api/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: c8bc359925a55d08f4049c7c598e46033353fe89
|
4
|
+
data.tar.gz: 3e1b6949d60743c49718c10f53d5e6ebc260d1fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c7cd0fe6019484d6f1786e89c6d88a4ef92375bc222e574533301b46c75ff7bfb753d33f7cdc43dc872840dd0308664ef95e051dc5d9e75df89475cfffd44a8
|
7
|
+
data.tar.gz: 661890c803ecc86a3185fa3ea5e2597ed3cf7af12798644765d0758b91abe439657ab1fb7921e1047423b0d5910cf8be7183bdbe891afbb264f60b34d2807014
|
data/Gemfile.lock
CHANGED
@@ -27,13 +27,26 @@ module Surveymonkey
|
|
27
27
|
response.parsed_response
|
28
28
|
end
|
29
29
|
|
30
|
-
# Return all survey responses
|
30
|
+
# Return all survey responses paginated
|
31
31
|
def survey_responses(survey_id, options = {})
|
32
32
|
response = self.class.get("/surveys/#{survey_id}/responses/bulk", { query: options })
|
33
33
|
response.parsed_response
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
|
37
|
+
# Return all survey responses
|
38
|
+
def all_survey_responses(survey_id, options = {})
|
39
|
+
response = self.class.get("/surveys/#{survey_id}/responses/bulk", { query: options })
|
40
|
+
surveys = []
|
41
|
+
surveys << if response['total'] > response['per_page']
|
42
|
+
get_all_pages(response['links'])
|
43
|
+
else
|
44
|
+
response['data']
|
45
|
+
end
|
46
|
+
surveys.flatten
|
47
|
+
end
|
48
|
+
|
49
|
+
# Return survey response
|
37
50
|
def survey_response(survey_id, response_id, options = {})
|
38
51
|
response = self.class.get("/surveys/#{survey_id}/responses/#{response_id}/details", { query: options })
|
39
52
|
response.parsed_response
|
@@ -10,5 +10,22 @@ module Surveymonkey
|
|
10
10
|
@access_token = access_token || ENV['SURVEYMONKEY_API_TOKEN']
|
11
11
|
self.class.default_options.merge!(headers: { 'Authorization' => "bearer #{@access_token}" })
|
12
12
|
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def get_all_pages(links)
|
17
|
+
all_data = []
|
18
|
+
res = self.class.get(path_for(links['self']))
|
19
|
+
all_data << res['data']
|
20
|
+
while res['links']['next']
|
21
|
+
res = self.class.get(path_for(res['links']['next']))
|
22
|
+
all_data << res['data']
|
23
|
+
end
|
24
|
+
all_data
|
25
|
+
end
|
26
|
+
|
27
|
+
def path_for(url)
|
28
|
+
URI.parse(url).request_uri[3..-1]
|
29
|
+
end
|
13
30
|
end
|
14
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: surveymonkey_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|