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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6af1967f37d038aa4f6a5bd653562feaca1204e
4
- data.tar.gz: 1e45e2bcaa96d4f9740acfde1afac35a780dfcad
3
+ metadata.gz: c8bc359925a55d08f4049c7c598e46033353fe89
4
+ data.tar.gz: 3e1b6949d60743c49718c10f53d5e6ebc260d1fd
5
5
  SHA512:
6
- metadata.gz: 650b1b0be91dda97ec3021f3b301b80a385a35de8381e7c9d798890f71b0cd1fee9ffe5a0837d3d9e8471ed7761c33a1990291914156abb6b8562233fc52167c
7
- data.tar.gz: fbe19f818728f695174288bdd6bbe197400f9ed55ad019a8572e491a534b2a113b6c067dc97a4b8b2c468af4a52596dbcee3d160279ed2e2a2682a6cf6164416
6
+ metadata.gz: 3c7cd0fe6019484d6f1786e89c6d88a4ef92375bc222e574533301b46c75ff7bfb753d33f7cdc43dc872840dd0308664ef95e051dc5d9e75df89475cfffd44a8
7
+ data.tar.gz: 661890c803ecc86a3185fa3ea5e2597ed3cf7af12798644765d0758b91abe439657ab1fb7921e1047423b0d5910cf8be7183bdbe891afbb264f60b34d2807014
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- surveymonkey_api (0.2.0)
4
+ surveymonkey_api (0.2.2)
5
5
  httparty (~> 0.13)
6
6
 
7
7
  GEM
@@ -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
- # Return survey responses
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
@@ -1,3 +1,3 @@
1
1
  module SurveymonkeyApi
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  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.1
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-07-19 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler