survey-gizmo-ruby 6.2.6 → 6.2.9
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/README.md +5 -4
- data/lib/survey_gizmo/connection.rb +7 -5
- data/lib/survey_gizmo/resource.rb +5 -2
- data/lib/survey_gizmo/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: 20a04949f16c25819c1023e91c871fa7db8aab13
|
4
|
+
data.tar.gz: 99f4d0a5c17a0f7a83a67c3ecb8039ec5643b0d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ffdb74e5fa62bd8e37744d8ecae7a18357110d3842b0a531af0ea0e1a92afb2f6b44ccc832bbb7523144129c13257881fff496b4e32c58ffb887942804e6323
|
7
|
+
data.tar.gz: dca6e6c8ff26776d48df6e66ad9850faf165773d91e4bb5968c83e733293895d684984cccd396f0cd154d3e11dd621382eb129ebe5ffddf3d1f7bcdaecc1f13e
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ And then your ruby code just has to make sure to call
|
|
58
58
|
SurveyGizmo.configure
|
59
59
|
````
|
60
60
|
|
61
|
-
once at some point.
|
61
|
+
once at some point to load the tokens out of the `ENV` and into the configuration.
|
62
62
|
|
63
63
|
## Usage
|
64
64
|
|
@@ -68,7 +68,7 @@ once at some point.
|
|
68
68
|
|
69
69
|
`SurveyGizmo::API::Klass.all` returns an `Enumerator` you can use to loop through your results/questions/surveys etc. It will actually iterate through ALL your results (pagination will be handled for you) if you pass `all_pages: true`.
|
70
70
|
|
71
|
-
Because `.all` returns an `Enumerator`, you have to call `.to_a` or some other enumerable method to trigger actual API data retrieval.
|
71
|
+
Because `.all` returns an `Enumerator`, you have to call `.each` or `.to_a` or some other enumerable method to trigger actual API data retrieval.
|
72
72
|
```ruby
|
73
73
|
SurveyGizmo::API::Survey.all(all_pages: true) # => #<Enumerator: #<Enumerator::Generator>:each>
|
74
74
|
SurveyGizmo::API::Survey.all(all_pages: true).to_a # => [Survey, Survey, Survey, ...]
|
@@ -107,8 +107,9 @@ question.destroy
|
|
107
107
|
# Iterate over all your Responses
|
108
108
|
survey.responses.each { |response| do_something_with(response) }
|
109
109
|
# Use filters to limit results - this example will iterate over page 3 of completed, non test data
|
110
|
-
# SurveyResponses submitted within the past 3 days for contact 999.
|
111
|
-
# the gem's built in filters/generators as well as how to construct
|
110
|
+
# SurveyResponses submitted within the past 3 days for contact 999. The example `filters` array
|
111
|
+
# demonstrates how to use some of the gem's built in filters/generators as well as how to construct
|
112
|
+
# an ad hoc filter hash.
|
112
113
|
# See: http://apihelp.surveygizmo.com/help/article/link/filters for more info on filters
|
113
114
|
filters = [
|
114
115
|
SurveyGizmo::API::Response::NO_TEST_DATA,
|
@@ -54,13 +54,15 @@ module SurveyGizmo
|
|
54
54
|
interval: SurveyGizmo.configuration.retry_interval,
|
55
55
|
tries: SurveyGizmo.configuration.retry_attempts + 1,
|
56
56
|
on: [
|
57
|
-
SurveyGizmo::BadResponseError,
|
58
|
-
SurveyGizmo::RateLimitExceededError,
|
59
57
|
Errno::ETIMEDOUT,
|
58
|
+
Faraday::Error::ClientError,
|
60
59
|
Net::ReadTimeout,
|
61
|
-
|
62
|
-
|
63
|
-
]
|
60
|
+
SurveyGizmo::BadResponseError,
|
61
|
+
SurveyGizmo::RateLimitExceededError
|
62
|
+
],
|
63
|
+
on_retry: Proc.new do |exception, tries|
|
64
|
+
SurveyGizmo.configuration.logger.warn("Retrying after #{exception.class}: #{tries} attempts.")
|
65
|
+
end
|
64
66
|
}
|
65
67
|
end
|
66
68
|
end
|
@@ -35,7 +35,7 @@ module SurveyGizmo
|
|
35
35
|
# Properties from the conditions hash (e.g. survey_id) will be added to the returned objects
|
36
36
|
def all(conditions = {})
|
37
37
|
fail ':all_pages and :page are mutually exclusive' if conditions[:page] && conditions[:all_pages]
|
38
|
-
logger.warn('
|
38
|
+
logger.warn('Only retrieving first page of results!') unless conditions[:page] || conditions[:all_pages]
|
39
39
|
|
40
40
|
all_pages = conditions.delete(:all_pages)
|
41
41
|
conditions[:resultsperpage] ||= SurveyGizmo.configuration.results_per_page
|
@@ -44,7 +44,9 @@ module SurveyGizmo
|
|
44
44
|
response = nil
|
45
45
|
|
46
46
|
while !response || (all_pages && response['page'] < response['total_pages'])
|
47
|
-
conditions[:page] = response ? response['page'] + 1 : conditions.fetch(:page, 1)
|
47
|
+
conditions[:page] = response ? response['page'] + 1 : conditions.fetch(:page, 1)
|
48
|
+
|
49
|
+
start_fetch_time = Time.now
|
48
50
|
logger.debug("Fetching #{name} page #{conditions} - #{conditions[:page]}#{response ? "/#{response['total_pages']}" : ''}...")
|
49
51
|
response = Connection.get(create_route(:create, conditions)).body
|
50
52
|
collection = response['data'].map { |datum| datum.is_a?(Hash) ? new(conditions.merge(datum)) : datum }
|
@@ -55,6 +57,7 @@ module SurveyGizmo
|
|
55
57
|
collection += collection.flat_map { |question| question.sub_questions }
|
56
58
|
end
|
57
59
|
|
60
|
+
logger.debug(" Fetched #{conditions[:resultsperpage]} of #{name} in #{(Time.now - start_fetch_time).to_i}s...")
|
58
61
|
collection.each { |e| yielder.yield(e) }
|
59
62
|
end
|
60
63
|
end
|
data/lib/survey_gizmo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: survey-gizmo-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.2.
|
4
|
+
version: 6.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kabari Hendrick
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-09-
|
14
|
+
date: 2016-09-04 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|