survey-gizmo-ruby 6.1.2 → 6.1.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/CHANGELOG.md +1 -0
- data/README.md +2 -2
- data/lib/survey-gizmo-ruby.rb +1 -0
- data/lib/survey_gizmo/api/response.rb +1 -1
- data/lib/survey_gizmo/configuration.rb +23 -3
- data/lib/survey_gizmo/faraday_middleware/parse_survey_gizmo.rb +1 -1
- data/lib/survey_gizmo/version.rb +1 -1
- data/spec/configuration_spec.rb +35 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d6ac831f23cde9a33a402318e0156e444e8a4fe
|
4
|
+
data.tar.gz: 26c120f520f737920fb22d55344210dd06b31875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f39778fccf60c152b5b53856f7289382b95a727da34900f6bc8ebcba4be621a8943b3c7d4c5f86e9b12ca439668d8423b66471dfcc86f0f29f93a5356032db93
|
7
|
+
data.tar.gz: fa8e6251c2634bba965bf2097be1f9f5937acb2c28f339733a5ccb6c889cfaf6dd3d18d26c19b7dd13b17a29cb4dceaef63d99fdce7fab77e8aaec93ef90e6e3
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
## Major Changes in 6.x
|
4
4
|
* **BREAKING CHANGE**: SurveyGizmo changed the authentication so you need to configure `api_token` and `api_token_secret` instead of user and password.
|
5
5
|
* **BREAKING CHANGE**: Pester has been removed as the retry source in favor of `Retriable`.
|
6
|
+
* FEATURE: `Configuration#region` will configure the region to use the corresponding api and time zone.
|
6
7
|
|
7
8
|
## Major Changes in 5.x
|
8
9
|
|
data/README.md
CHANGED
@@ -29,8 +29,8 @@ SurveyGizmo.configure do |config|
|
|
29
29
|
# Optional - Defaults to v4, but you can probably set to v3 safely if you suspect a bug in v4
|
30
30
|
config.api_version = 'v4'
|
31
31
|
|
32
|
-
# Optional - Set if you need to hit a different
|
33
|
-
config.
|
32
|
+
# Optional - Set if you need to hit a different region (e.g. the .eu domain)
|
33
|
+
config.region = :eu
|
34
34
|
|
35
35
|
# Optional - Defaults to 50, maximum 500. Setting too high may cause SurveyGizmo to start throwing timeouts.
|
36
36
|
config.results_per_page = 100
|
data/lib/survey-gizmo-ruby.rb
CHANGED
@@ -10,7 +10,7 @@ module SurveyGizmo::API
|
|
10
10
|
{
|
11
11
|
field: 'datesubmitted',
|
12
12
|
operator: '>=',
|
13
|
-
value: time.in_time_zone(SurveyGizmo
|
13
|
+
value: time.in_time_zone(SurveyGizmo.configuration.api_time_zone).strftime('%Y-%m-%d %H:%M:%S')
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
@@ -19,19 +19,30 @@ module SurveyGizmo
|
|
19
19
|
end
|
20
20
|
|
21
21
|
class Configuration
|
22
|
-
DEFAULT_REST_API_URL = 'https://restapi.surveygizmo.com'
|
23
22
|
DEFAULT_API_VERSION = 'v4'
|
24
23
|
DEFAULT_RESULTS_PER_PAGE = 50
|
25
24
|
DEFAULT_TIMEOUT_SECONDS = 300
|
26
25
|
DEFAULT_RETRIES = 3
|
27
26
|
DEFAULT_RETRY_INTERVAL = 60
|
28
|
-
|
27
|
+
DEFAULT_REGION = :us
|
28
|
+
|
29
|
+
REGION_INFO = {
|
30
|
+
us: {
|
31
|
+
url: 'https://restapi.surveygizmo.com',
|
32
|
+
locale: 'Eastern Time (US & Canada)'
|
33
|
+
},
|
34
|
+
eu: {
|
35
|
+
url: 'https://restapi.surveygizmo.eu',
|
36
|
+
locale: 'Berlin'
|
37
|
+
}
|
38
|
+
}
|
29
39
|
|
30
40
|
attr_accessor :api_token
|
31
41
|
attr_accessor :api_token_secret
|
32
42
|
|
33
43
|
attr_accessor :api_debug
|
34
44
|
attr_accessor :api_url
|
45
|
+
attr_accessor :api_time_zone
|
35
46
|
attr_accessor :api_version
|
36
47
|
attr_accessor :logger
|
37
48
|
attr_accessor :results_per_page
|
@@ -45,16 +56,25 @@ module SurveyGizmo
|
|
45
56
|
@api_token = ENV['SURVEYGIZMO_API_TOKEN'] || nil
|
46
57
|
@api_token_secret = ENV['SURVEYGIZMO_API_TOKEN_SECRET'] || nil
|
47
58
|
|
48
|
-
@api_url = DEFAULT_REST_API_URL
|
49
59
|
@api_version = DEFAULT_API_VERSION
|
50
60
|
@results_per_page = DEFAULT_RESULTS_PER_PAGE
|
51
61
|
|
52
62
|
@timeout_seconds = DEFAULT_TIMEOUT_SECONDS
|
53
63
|
@retry_attempts = DEFAULT_RETRIES
|
54
64
|
@retry_interval = DEFAULT_RETRY_INTERVAL
|
65
|
+
self.region = DEFAULT_REGION
|
55
66
|
|
56
67
|
@logger = SurveyGizmo::Logger.new(STDOUT)
|
57
68
|
@api_debug = ENV['GIZMO_DEBUG'].to_s =~ /^(true|t|yes|y|1)$/i
|
58
69
|
end
|
70
|
+
|
71
|
+
def region=(region)
|
72
|
+
region_infos = REGION_INFO[region]
|
73
|
+
ArgumentError.new("Unknown region: #{region}") unless region_infos
|
74
|
+
|
75
|
+
@api_url = region_infos[:url]
|
76
|
+
@api_time_zone = region_infos[:locale]
|
77
|
+
end
|
59
78
|
end
|
79
|
+
|
60
80
|
end
|
@@ -42,7 +42,7 @@ module SurveyGizmo
|
|
42
42
|
# SurveyGizmo returns date information using US/Eastern timezone but does not provide time zone information.
|
43
43
|
# See https://apihelp.surveygizmo.com/help/article/link/surveyresponse-returned-fields#examplereturns
|
44
44
|
TIME_FIELDS.each do |time_key|
|
45
|
-
datum[time_key] = ActiveSupport::TimeZone.new(SurveyGizmo
|
45
|
+
datum[time_key] = ActiveSupport::TimeZone.new(SurveyGizmo.configuration.api_time_zone).parse(datum[time_key]) unless datum[time_key].blank?
|
46
46
|
end
|
47
47
|
|
48
48
|
datum.keys.grep(/^\[/).each do |key|
|
data/lib/survey_gizmo/version.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
@@ -24,4 +24,39 @@ describe SurveyGizmo::Configuration do
|
|
24
24
|
|
25
25
|
expect(SurveyGizmo::Connection.send(:connection).params).to eq('api_token' => 'slimthug', 'api_token_secret' => 'fourfourz')
|
26
26
|
end
|
27
|
+
|
28
|
+
describe '#region=' do
|
29
|
+
it 'should set US region by default' do
|
30
|
+
SurveyGizmo.configure
|
31
|
+
expect(SurveyGizmo.configuration.api_url).to eq('https://restapi.surveygizmo.com')
|
32
|
+
expect(SurveyGizmo.configuration.api_time_zone).to eq('Eastern Time (US & Canada)')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should set US region with :us symbol specified' do
|
36
|
+
SurveyGizmo.configure do |config|
|
37
|
+
config.region = :us
|
38
|
+
end
|
39
|
+
|
40
|
+
expect(SurveyGizmo.configuration.api_url).to eq('https://restapi.surveygizmo.com')
|
41
|
+
expect(SurveyGizmo.configuration.api_time_zone).to eq('Eastern Time (US & Canada)')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should set EU region with :eu symbol specified' do
|
45
|
+
SurveyGizmo.configure do |config|
|
46
|
+
config.region = :eu
|
47
|
+
end
|
48
|
+
|
49
|
+
expect(SurveyGizmo.configuration.api_url).to eq('https://restapi.surveygizmo.eu')
|
50
|
+
expect(SurveyGizmo.configuration.api_time_zone).to eq('Berlin')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should fail with an unavailable region' do
|
54
|
+
expect {
|
55
|
+
SurveyGizmo.configure do |config|
|
56
|
+
config.region = :cz
|
57
|
+
end
|
58
|
+
}.to raise_error
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
27
62
|
end
|
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.1.
|
4
|
+
version: 6.1.3
|
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-06-
|
14
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -267,4 +267,3 @@ test_files:
|
|
267
267
|
- spec/test_json/page.json
|
268
268
|
- spec/test_json/question.json
|
269
269
|
- spec/test_json/survey.json
|
270
|
-
has_rdoc:
|