qualtrics_api 0.0.3 → 0.0.4
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 +12 -12
- data/lib/qualtrics_api.rb +4 -2
- data/lib/qualtrics_api/client.rb +7 -8
- data/lib/qualtrics_api/configurable.rb +9 -0
- data/lib/qualtrics_api/panel.rb +1 -2
- data/lib/qualtrics_api/panel_collection.rb +3 -4
- data/lib/qualtrics_api/panel_import.rb +1 -2
- data/lib/qualtrics_api/panel_member.rb +1 -4
- data/lib/qualtrics_api/panel_member_collection.rb +6 -7
- data/lib/qualtrics_api/response_export.rb +1 -2
- data/lib/qualtrics_api/response_export_collection.rb +1 -2
- data/lib/qualtrics_api/services/response_export_service.rb +2 -3
- data/lib/qualtrics_api/survey.rb +1 -2
- data/lib/qualtrics_api/survey_collection.rb +3 -4
- data/lib/qualtrics_api/version.rb +1 -1
- data/qualtrics_api.gemspec +1 -0
- data/spec/lib/client_spec.rb +1 -17
- data/spec/lib/panel_collection_spec.rb +0 -17
- data/spec/lib/panel_import_spec.rb +1 -2
- data/spec/lib/panel_member_collection_spec.rb +2 -21
- data/spec/lib/panel_member_spec.rb +1 -2
- data/spec/lib/panel_spec.rb +1 -11
- data/spec/lib/response_export_collection_spec.rb +0 -9
- data/spec/lib/response_export_spec.rb +2 -5
- data/spec/lib/services/response_export_service_spec.rb +5 -14
- data/spec/lib/survey_collection_spec.rb +2 -16
- data/spec/lib/survey_spec.rb +2 -9
- data/spec/qualtrics_api_spec.rb +1 -4
- data/spec/spec_helper.rb +5 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9b596ee7f98f076fd177905c54611c0884181a7
|
4
|
+
data.tar.gz: ab95a05e5eb6b293d5fa6f92a2989cc27477695b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f3af6fe953f4d57bdc69e2968205464e2e9089c221bb79f888b797063d8ca83f00d4e43d223d18ec68ed537fbbf16057c36d143fcf42f741153970913aeec86
|
7
|
+
data.tar.gz: d38eb7ff62912c5ac57337f366200ba436306284483814e745b31edea564ccf5ad645bfab084deb0e0bb18410b218255f26344be40e292b1f3e61ad9cbeeead4
|
data/README.md
CHANGED
@@ -28,8 +28,9 @@ Or install it yourself as:
|
|
28
28
|
### Initialize
|
29
29
|
|
30
30
|
```ruby
|
31
|
-
|
32
|
-
|
31
|
+
QualtricsAPI.configure do |config|
|
32
|
+
config.api_token = "YOUR_QUALTRICS_API_KEY"
|
33
|
+
end
|
33
34
|
```
|
34
35
|
|
35
36
|
### Surveys
|
@@ -37,28 +38,28 @@ client = QualtricsAPI.new "YOUR_QUALTRICS_API_KEY"
|
|
37
38
|
To get all your surveys:
|
38
39
|
|
39
40
|
```ruby
|
40
|
-
|
41
|
+
QualtricsAPI.surveys.fetch
|
41
42
|
# => #<QualtricsAPI::SurveyCollection:0x007fcb72cce350 ....>
|
42
43
|
```
|
43
44
|
|
44
45
|
You can also add a scopeId:
|
45
46
|
|
46
47
|
```ruby
|
47
|
-
|
48
|
+
QualtricsAPI.surveys.fetch(scope_id: "someOwnerIdMaybe")
|
48
49
|
# => #<QualtricsAPI::SurveyCollection:0x007fcb72adaf21 ....>
|
49
50
|
```
|
50
51
|
|
51
52
|
After you have received results, you can search for a survey by id:
|
52
53
|
|
53
54
|
```ruby
|
54
|
-
survey =
|
55
|
+
survey = QualtricsAPI.surveys.find("surveyIdHere")
|
55
56
|
# => #<QualtricsAPI::Survey:0x007fcb724f9468 @id="surveyIdHere" ...>
|
56
57
|
```
|
57
58
|
|
58
59
|
or just:
|
59
60
|
|
60
61
|
```ruby
|
61
|
-
survey =
|
62
|
+
survey = QualtricsAPI.surveys["surveyIdHere"]
|
62
63
|
# => #<QualtricsAPI::Survey:0x007fcb724f9468 @id="surveyIdHere" ...>
|
63
64
|
```
|
64
65
|
|
@@ -129,8 +130,7 @@ You can save it somewhere in your app and check back later (if you know
|
|
129
130
|
it's gonna take a while!)
|
130
131
|
|
131
132
|
```ruby
|
132
|
-
|
133
|
-
export = client.response_exports["someExportID"]
|
133
|
+
export = QualtricsAPI.response_exports["someExportID"]
|
134
134
|
# => #<QualtricsAPI::ResponseExport:0x007fcb742e4e50 ....>
|
135
135
|
export.status
|
136
136
|
=> "99.99999%"
|
@@ -141,21 +141,21 @@ export.status
|
|
141
141
|
To get all the panels:
|
142
142
|
|
143
143
|
```ruby
|
144
|
-
|
144
|
+
QualtricsAPI.panels.fetch
|
145
145
|
# => #<QualtricsAPI::PanelCollection:0x007f8769aae2c0 ....>
|
146
146
|
```
|
147
147
|
|
148
148
|
After you have received results, you can search for a panel by id:
|
149
149
|
|
150
150
|
```ruby
|
151
|
-
panel =
|
151
|
+
panel = QualtricsAPI.panels.find("panelIdHere")
|
152
152
|
# => #<QualtricsAPI::Panel:0x007f876906f278 @id="panelIdHere" ...>
|
153
153
|
```
|
154
154
|
|
155
155
|
or just:
|
156
156
|
|
157
157
|
```ruby
|
158
|
-
panel =
|
158
|
+
panel = QualtricsAPI.panels["panelIdHere"]
|
159
159
|
# => #<QualtricsAPI::Panel:0x007f876906f278 @id="panelIdHere" ...>
|
160
160
|
```
|
161
161
|
|
@@ -164,7 +164,7 @@ panel = client.panels["panelIdHere"]
|
|
164
164
|
To add panel members to a panel:
|
165
165
|
|
166
166
|
```ruby
|
167
|
-
panel =
|
167
|
+
panel = QualtricsAPI.panels.fetch["panelIdHere"]
|
168
168
|
members = [QualtricsAPI::PanelMember.new(first_name: 'John', last_name: 'Doe', email: 'test@test.com')]
|
169
169
|
panel.members.create(members)
|
170
170
|
=> #<QualtricsAPI::PanelImport:0x007fb7db984668 ...>
|
data/lib/qualtrics_api.rb
CHANGED
@@ -8,6 +8,7 @@ require "qualtrics_api/url"
|
|
8
8
|
|
9
9
|
require "qualtrics_api/request_error_handler"
|
10
10
|
|
11
|
+
require "qualtrics_api/configurable"
|
11
12
|
require "qualtrics_api/client"
|
12
13
|
require "qualtrics_api/survey"
|
13
14
|
require "qualtrics_api/survey_collection"
|
@@ -22,7 +23,8 @@ require "qualtrics_api/panel_import"
|
|
22
23
|
require "qualtrics_api/services/response_export_service"
|
23
24
|
|
24
25
|
module QualtricsAPI
|
25
|
-
|
26
|
-
|
26
|
+
class << self
|
27
|
+
include QualtricsAPI::Configurable
|
28
|
+
include QualtricsAPI::Client
|
27
29
|
end
|
28
30
|
end
|
data/lib/qualtrics_api/client.rb
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
module QualtricsAPI
|
2
|
-
|
2
|
+
module Client
|
3
3
|
include Virtus.value_object
|
4
4
|
|
5
|
-
attribute :api_token, String
|
6
|
-
|
7
5
|
def surveys(options = {})
|
8
|
-
@surveys
|
6
|
+
@surveys = nil if @surveys && @surveys.scope_id != options[:scope_id]
|
7
|
+
@surveys ||= QualtricsAPI::SurveyCollection.new(options)
|
9
8
|
end
|
10
9
|
|
11
10
|
def response_exports(options = {})
|
12
|
-
@response_exports ||= QualtricsAPI::ResponseExportCollection.new(options
|
11
|
+
@response_exports ||= QualtricsAPI::ResponseExportCollection.new(options)
|
13
12
|
end
|
14
13
|
|
15
14
|
def panels(options = {})
|
16
|
-
@panels ||= QualtricsAPI::PanelCollection.new(options
|
15
|
+
@panels ||= QualtricsAPI::PanelCollection.new(options)
|
17
16
|
end
|
18
17
|
|
19
18
|
def connection
|
20
|
-
|
21
|
-
|
19
|
+
api_token ||= QualtricsAPI.api_token || fail('Please configure api token!')
|
20
|
+
@conn ||= Faraday.new(url: QualtricsAPI::URL, params: { apiToken: api_token }) do |faraday|
|
22
21
|
faraday.request :url_encoded
|
23
22
|
faraday.response :json, :content_type => /\bjson$/
|
24
23
|
|
data/lib/qualtrics_api/panel.rb
CHANGED
@@ -2,7 +2,6 @@ module QualtricsAPI
|
|
2
2
|
class Panel
|
3
3
|
include Virtus.value_object
|
4
4
|
|
5
|
-
attribute :connection
|
6
5
|
attribute :id, String
|
7
6
|
attribute :library_id, String
|
8
7
|
attribute :name, String
|
@@ -16,7 +15,7 @@ module QualtricsAPI
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def members(options = {})
|
19
|
-
@members ||= QualtricsAPI::PanelMemberCollection.new(options.merge(id: id
|
18
|
+
@members ||= QualtricsAPI::PanelMemberCollection.new(options.merge(id: id))
|
20
19
|
end
|
21
20
|
|
22
21
|
private
|
@@ -4,7 +4,6 @@ module QualtricsAPI
|
|
4
4
|
include Enumerable
|
5
5
|
include Virtus.value_object
|
6
6
|
|
7
|
-
attribute :connection
|
8
7
|
attribute :all, Array, :default => []
|
9
8
|
|
10
9
|
def_delegator :all, :each
|
@@ -12,7 +11,7 @@ module QualtricsAPI
|
|
12
11
|
|
13
12
|
def fetch(_options = {})
|
14
13
|
@all = []
|
15
|
-
parse_fetch_response(connection.get('panels'))
|
14
|
+
parse_fetch_response(QualtricsAPI.connection.get('panels'))
|
16
15
|
self
|
17
16
|
end
|
18
17
|
|
@@ -23,14 +22,14 @@ module QualtricsAPI
|
|
23
22
|
def find(panel_id)
|
24
23
|
@all.detect do |panel|
|
25
24
|
panel.id == panel_id
|
26
|
-
end || QualtricsAPI::Panel.new("panelId" => panel_id
|
25
|
+
end || QualtricsAPI::Panel.new("panelId" => panel_id)
|
27
26
|
end
|
28
27
|
|
29
28
|
private
|
30
29
|
|
31
30
|
def parse_fetch_response(response)
|
32
31
|
@all = response.body["result"].map do |result|
|
33
|
-
QualtricsAPI::Panel.new
|
32
|
+
QualtricsAPI::Panel.new(result)
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -2,12 +2,11 @@ module QualtricsAPI
|
|
2
2
|
class PanelImport
|
3
3
|
include Virtus.value_object
|
4
4
|
|
5
|
-
attribute :connection
|
6
5
|
attribute :id, String
|
7
6
|
attribute :panel_id, String
|
8
7
|
|
9
8
|
def update_status
|
10
|
-
res = connection.get("panels/#{panel_id}/members/panelImports/#{id}").body["result"]
|
9
|
+
res = QualtricsAPI.connection.get("panels/#{panel_id}/members/panelImports/#{id}").body["result"]
|
11
10
|
@import_progress = res["percentComplete"]
|
12
11
|
@completed = true if @import_progress == 100.0
|
13
12
|
self
|
@@ -2,7 +2,6 @@ module QualtricsAPI
|
|
2
2
|
class PanelMember
|
3
3
|
include Virtus.value_object
|
4
4
|
|
5
|
-
attribute :connection
|
6
5
|
attribute :id, String
|
7
6
|
attribute :first_name, String
|
8
7
|
attribute :last_name, String
|
@@ -26,9 +25,7 @@ module QualtricsAPI
|
|
26
25
|
private
|
27
26
|
|
28
27
|
def serialized_attributes
|
29
|
-
Hash[attributes.map { |k, v| [mapped_and_uppercased_attribute(k), v] }].
|
30
|
-
h.delete("Connection")
|
31
|
-
end.delete_if { |_k, v| v.nil? }
|
28
|
+
Hash[attributes.map { |k, v| [mapped_and_uppercased_attribute(k), v] }].delete_if { |_k, v| v.nil? }
|
32
29
|
end
|
33
30
|
|
34
31
|
def mapped_and_uppercased_attribute(attribute)
|
@@ -4,7 +4,6 @@ module QualtricsAPI
|
|
4
4
|
include Enumerable
|
5
5
|
include Virtus.value_object
|
6
6
|
|
7
|
-
attribute :connection
|
8
7
|
attribute :id, String
|
9
8
|
attribute :all, Array, :default => []
|
10
9
|
|
@@ -13,16 +12,16 @@ module QualtricsAPI
|
|
13
12
|
|
14
13
|
def fetch(_options = {})
|
15
14
|
@all = []
|
16
|
-
parse_fetch_response(connection.get("panels/#{id}/members"))
|
15
|
+
parse_fetch_response(QualtricsAPI.connection.get("panels/#{id}/members"))
|
17
16
|
self
|
18
17
|
end
|
19
18
|
|
20
19
|
def create(panel_members)
|
21
|
-
res = connection
|
22
|
-
.post("panels/#{id}/members", connection.params.merge(panelMembers: panel_members.to_json))
|
20
|
+
res = QualtricsAPI.connection
|
21
|
+
.post("panels/#{id}/members", QualtricsAPI.connection.params.merge(panelMembers: panel_members.to_json))
|
23
22
|
.body["result"]
|
24
23
|
import_id = res['importStatus'].split('/').last
|
25
|
-
QualtricsAPI::PanelImport.new(id: import_id, panel_id: id
|
24
|
+
QualtricsAPI::PanelImport.new(id: import_id, panel_id: id)
|
26
25
|
end
|
27
26
|
|
28
27
|
def [](member_id)
|
@@ -32,14 +31,14 @@ module QualtricsAPI
|
|
32
31
|
def find(member_id)
|
33
32
|
@all.detect do |panel_member|
|
34
33
|
panel_member.id == member_id
|
35
|
-
end || QualtricsAPI::PanelMember.new(:id => member_id
|
34
|
+
end || QualtricsAPI::PanelMember.new(:id => member_id)
|
36
35
|
end
|
37
36
|
|
38
37
|
private
|
39
38
|
|
40
39
|
def parse_fetch_response(response)
|
41
40
|
@all = response.body["result"].map do |result|
|
42
|
-
QualtricsAPI::PanelMember.new(result
|
41
|
+
QualtricsAPI::PanelMember.new(result)
|
43
42
|
end
|
44
43
|
end
|
45
44
|
end
|
@@ -2,11 +2,10 @@ module QualtricsAPI
|
|
2
2
|
class ResponseExport
|
3
3
|
include Virtus.value_object
|
4
4
|
|
5
|
-
attribute :connection
|
6
5
|
attribute :id, String
|
7
6
|
|
8
7
|
def update_status
|
9
|
-
res = connection.get('surveys/responseExports/' + id).body["result"]
|
8
|
+
res = QualtricsAPI.connection.get('surveys/responseExports/' + id).body["result"]
|
10
9
|
@export_progress = res["percentComplete"]
|
11
10
|
@file_url = res["fileUrl"]
|
12
11
|
@completed = true if @export_progress == 100.0
|
@@ -4,7 +4,6 @@ module QualtricsAPI
|
|
4
4
|
include Enumerable
|
5
5
|
include Virtus.value_object
|
6
6
|
|
7
|
-
attribute :connection
|
8
7
|
attribute :all, Array, :default => []
|
9
8
|
|
10
9
|
def_delegator :all, :each
|
@@ -17,7 +16,7 @@ module QualtricsAPI
|
|
17
16
|
def find(export_id)
|
18
17
|
@all.detect do |response_export|
|
19
18
|
response_export.id == export_id
|
20
|
-
end || QualtricsAPI::ResponseExport.new(:id => export_id
|
19
|
+
end || QualtricsAPI::ResponseExport.new(:id => export_id)
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -3,7 +3,6 @@ module QualtricsAPI
|
|
3
3
|
class ResponseExportService
|
4
4
|
include Virtus.value_object
|
5
5
|
|
6
|
-
attribute :connection
|
7
6
|
attribute :survey_id, String
|
8
7
|
attribute :response_set_id, String
|
9
8
|
attribute :file_type, String, :default => 'CSV'
|
@@ -23,9 +22,9 @@ module QualtricsAPI
|
|
23
22
|
attr_reader :result
|
24
23
|
|
25
24
|
def start
|
26
|
-
response = connection.get("surveys/#{survey_id}/responseExports", export_params)
|
25
|
+
response = QualtricsAPI.connection.get("surveys/#{survey_id}/responseExports", export_params)
|
27
26
|
export_id = response.body["result"]["exportStatus"].split('/').last
|
28
|
-
@result = ResponseExport.new(id: export_id
|
27
|
+
@result = ResponseExport.new(id: export_id)
|
29
28
|
end
|
30
29
|
|
31
30
|
def export_configurations
|
data/lib/qualtrics_api/survey.rb
CHANGED
@@ -2,7 +2,6 @@ module QualtricsAPI
|
|
2
2
|
class Survey
|
3
3
|
include Virtus.value_object
|
4
4
|
|
5
|
-
attribute :connection
|
6
5
|
attribute :id, String
|
7
6
|
attribute :name, String
|
8
7
|
attribute :owner_id, String
|
@@ -18,7 +17,7 @@ module QualtricsAPI
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def export_responses(export_options = {})
|
21
|
-
QualtricsAPI::Services::ResponseExportService.new(export_options.merge(survey_id: id
|
20
|
+
QualtricsAPI::Services::ResponseExportService.new(export_options.merge(survey_id: id))
|
22
21
|
end
|
23
22
|
|
24
23
|
private
|
@@ -4,7 +4,6 @@ module QualtricsAPI
|
|
4
4
|
include Enumerable
|
5
5
|
include Virtus.value_object
|
6
6
|
|
7
|
-
attribute :connection
|
8
7
|
attribute :scope_id, String
|
9
8
|
attribute :all, Array, :default => []
|
10
9
|
|
@@ -16,7 +15,7 @@ module QualtricsAPI
|
|
16
15
|
def fetch(options = {})
|
17
16
|
@all = []
|
18
17
|
update_query_attributes(options)
|
19
|
-
parse_fetch_response(connection.get('surveys', query_params))
|
18
|
+
parse_fetch_response(QualtricsAPI.connection.get('surveys', query_params))
|
20
19
|
self
|
21
20
|
end
|
22
21
|
|
@@ -37,7 +36,7 @@ module QualtricsAPI
|
|
37
36
|
def find(survey_id)
|
38
37
|
@all.detect do |survey|
|
39
38
|
survey.id == survey_id
|
40
|
-
end || QualtricsAPI::Survey.new("id" => survey_id
|
39
|
+
end || QualtricsAPI::Survey.new("id" => survey_id)
|
41
40
|
end
|
42
41
|
|
43
42
|
private
|
@@ -56,7 +55,7 @@ module QualtricsAPI
|
|
56
55
|
|
57
56
|
def parse_fetch_response(response)
|
58
57
|
@all = response.body["result"].map do |result|
|
59
|
-
QualtricsAPI::Survey.new result
|
58
|
+
QualtricsAPI::Survey.new result
|
60
59
|
end
|
61
60
|
end
|
62
61
|
end
|
data/qualtrics_api.gemspec
CHANGED
data/spec/lib/client_spec.rb
CHANGED
@@ -1,25 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QualtricsAPI::Client do
|
4
|
-
subject { QualtricsAPI
|
5
|
-
|
6
|
-
it "has an api token" do
|
7
|
-
expect(subject.api_token).to eq "someToken"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "does not allow changing the token once initialized" do
|
11
|
-
expect(subject).to_not respond_to(:api_token=)
|
12
|
-
end
|
4
|
+
subject { QualtricsAPI }
|
13
5
|
|
14
6
|
describe "#response_exports" do
|
15
7
|
it "returns a ResponseExportCollection" do
|
16
8
|
expect(subject.response_exports).to be_a QualtricsAPI::ResponseExportCollection
|
17
9
|
end
|
18
10
|
|
19
|
-
it "sets connection" do
|
20
|
-
expect(subject.surveys.connection).to eq subject.connection
|
21
|
-
end
|
22
|
-
|
23
11
|
it "caches the collection" do
|
24
12
|
expect(subject.response_exports.object_id).to eq subject.response_exports.object_id
|
25
13
|
end
|
@@ -30,10 +18,6 @@ describe QualtricsAPI::Client do
|
|
30
18
|
expect(subject.surveys).to be_a QualtricsAPI::SurveyCollection
|
31
19
|
end
|
32
20
|
|
33
|
-
it "sets connection" do
|
34
|
-
expect(subject.surveys.connection).to eq subject.connection
|
35
|
-
end
|
36
|
-
|
37
21
|
it "assigns scope_id if passed" do
|
38
22
|
expect(subject.surveys(:scope_id => "someId").scope_id).to eq "someId"
|
39
23
|
end
|
@@ -1,18 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QualtricsAPI::PanelCollection do
|
4
|
-
let(:connection) { double('connection') }
|
5
|
-
|
6
|
-
subject { described_class.new connection: connection }
|
7
|
-
|
8
4
|
it "has no @all when initialized" do
|
9
5
|
expect(subject.all).to eq []
|
10
6
|
end
|
11
7
|
|
12
|
-
it "takes a connection" do
|
13
|
-
expect(subject.connection).to eq connection
|
14
|
-
end
|
15
|
-
|
16
8
|
describe "#find, #[]" do
|
17
9
|
let(:panel_1) { QualtricsAPI::Panel.new "panelId" => "p1" }
|
18
10
|
let(:panel_2) { QualtricsAPI::Panel.new "panelId" => "p2" }
|
@@ -27,15 +19,10 @@ describe QualtricsAPI::PanelCollection do
|
|
27
19
|
new_panel = subject["p3"]
|
28
20
|
expect(new_panel).to be_a QualtricsAPI::Panel
|
29
21
|
expect(new_panel.id).to eq "p3"
|
30
|
-
expect(new_panel.connection).to eq connection
|
31
22
|
end
|
32
23
|
end
|
33
24
|
|
34
25
|
describe "integration" do
|
35
|
-
let(:client) { QualtricsAPI.new TEST_API_TOKEN }
|
36
|
-
|
37
|
-
subject { described_class.new connection: client.connection }
|
38
|
-
|
39
26
|
describe "#fetch" do
|
40
27
|
describe "when success" do
|
41
28
|
before do
|
@@ -53,10 +40,6 @@ describe QualtricsAPI::PanelCollection do
|
|
53
40
|
expect(subject.first).to be_a QualtricsAPI::Panel
|
54
41
|
end
|
55
42
|
|
56
|
-
it "passes down the connection" do
|
57
|
-
expect(subject.all.first.connection).to eq client.connection
|
58
|
-
end
|
59
|
-
|
60
43
|
it "returns itself" do
|
61
44
|
expect(result).to eq subject
|
62
45
|
end
|
@@ -2,8 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe QualtricsAPI::PanelImport do
|
4
4
|
describe "integration" do
|
5
|
-
|
6
|
-
subject { described_class.new(id: 'PGRS_bEJLYLkqMBs8Bwx', panel_id: 'ML_bC2c5xBz1DxyOYB', connection: connection) }
|
5
|
+
subject { described_class.new(id: 'PGRS_bEJLYLkqMBs8Bwx', panel_id: 'ML_bC2c5xBz1DxyOYB') }
|
7
6
|
|
8
7
|
describe "#update_status" do
|
9
8
|
let(:result) do
|
@@ -1,18 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QualtricsAPI::PanelMemberCollection do
|
4
|
-
let(:connection) { double('connection') }
|
5
|
-
|
6
|
-
subject { described_class.new connection: connection }
|
7
|
-
|
8
4
|
it "has no @all when initialized" do
|
9
5
|
expect(subject.all).to eq []
|
10
6
|
end
|
11
7
|
|
12
|
-
it "takes a connection" do
|
13
|
-
expect(subject.connection).to eq connection
|
14
|
-
end
|
15
|
-
|
16
8
|
describe "#find, #[]" do
|
17
9
|
let(:panel_member_1) { QualtricsAPI::PanelMember.new("panelMemberId" => "p1") }
|
18
10
|
let(:panel_member_2) { QualtricsAPI::PanelMember.new("panelMemberId" => "p2") }
|
@@ -27,14 +19,11 @@ describe QualtricsAPI::PanelMemberCollection do
|
|
27
19
|
new_panel_member = subject["p3"]
|
28
20
|
expect(new_panel_member).to be_a QualtricsAPI::PanelMember
|
29
21
|
expect(new_panel_member.id).to eq "p3"
|
30
|
-
expect(new_panel_member.connection).to eq connection
|
31
22
|
end
|
32
23
|
end
|
33
24
|
|
34
25
|
describe "integration" do
|
35
|
-
|
36
|
-
|
37
|
-
subject { described_class.new(connection: client.connection, id: 'ABCD') }
|
26
|
+
subject { described_class.new(id: 'ABCD') }
|
38
27
|
|
39
28
|
describe "#fetch" do
|
40
29
|
describe "when success" do
|
@@ -53,10 +42,6 @@ describe QualtricsAPI::PanelMemberCollection do
|
|
53
42
|
expect(subject.first).to be_a QualtricsAPI::PanelMember
|
54
43
|
end
|
55
44
|
|
56
|
-
it "passes down the connection" do
|
57
|
-
expect(subject.all.first.connection).to eq client.connection
|
58
|
-
end
|
59
|
-
|
60
45
|
it "returns itself" do
|
61
46
|
expect(result).to eq subject
|
62
47
|
end
|
@@ -77,7 +62,7 @@ describe QualtricsAPI::PanelMemberCollection do
|
|
77
62
|
describe "#create" do
|
78
63
|
let(:result) do
|
79
64
|
VCR.use_cassette(cassette) do
|
80
|
-
QualtricsAPI.
|
65
|
+
QualtricsAPI.panels.fetch['ML_bC2c5xBz1DxyOYB'].members.create(panel_members)
|
81
66
|
end
|
82
67
|
end
|
83
68
|
|
@@ -96,10 +81,6 @@ describe QualtricsAPI::PanelMemberCollection do
|
|
96
81
|
it "returns PanelImport with panel id" do
|
97
82
|
expect(result.panel_id).to eq('ML_bC2c5xBz1DxyOYB')
|
98
83
|
end
|
99
|
-
|
100
|
-
it "returns PanelImport with connection" do
|
101
|
-
expect(result.connection).not_to be_nil
|
102
|
-
end
|
103
84
|
end
|
104
85
|
|
105
86
|
describe "when failed" do
|
@@ -14,8 +14,7 @@ describe QualtricsAPI::PanelMember do
|
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
subject { described_class.new panel_member.merge(connection: connection) }
|
17
|
+
subject { described_class.new panel_member }
|
19
18
|
|
20
19
|
it "has a panel member id" do
|
21
20
|
expect(subject.id).to eq(panel_member["panelMemberId"])
|
data/spec/lib/panel_spec.rb
CHANGED
@@ -10,9 +10,7 @@ describe QualtricsAPI::Panel do
|
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
subject { described_class.new qualtrics_response.merge(connection: connection) }
|
13
|
+
subject { described_class.new qualtrics_response }
|
16
14
|
|
17
15
|
it "has an panelId" do
|
18
16
|
expect(subject.id).to eq qualtrics_response["panelId"]
|
@@ -30,19 +28,11 @@ describe QualtricsAPI::Panel do
|
|
30
28
|
expect(subject.category).to eq qualtrics_response["category"]
|
31
29
|
end
|
32
30
|
|
33
|
-
it "has a connection" do
|
34
|
-
expect(subject.connection).to eq(connection)
|
35
|
-
end
|
36
|
-
|
37
31
|
describe "#members" do
|
38
32
|
it "returns a PanelMemberCollection" do
|
39
33
|
expect(subject.members).to be_a QualtricsAPI::PanelMemberCollection
|
40
34
|
end
|
41
35
|
|
42
|
-
it "sets connection" do
|
43
|
-
expect(subject.members.connection).to eq subject.connection
|
44
|
-
end
|
45
|
-
|
46
36
|
it "assigns panel id" do
|
47
37
|
expect(subject.members.id).to eq subject.id
|
48
38
|
end
|
@@ -1,18 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QualtricsAPI::ResponseExportCollection do
|
4
|
-
let(:connection) { double('connection') }
|
5
|
-
|
6
|
-
subject { described_class.new(connection: connection) }
|
7
|
-
|
8
4
|
it "has no @all when initialized" do
|
9
5
|
expect(subject.all).to eq []
|
10
6
|
end
|
11
7
|
|
12
|
-
it "takes a connection" do
|
13
|
-
expect(subject.connection).to eq connection
|
14
|
-
end
|
15
|
-
|
16
8
|
describe "#find, #[]" do
|
17
9
|
let(:export_1) { QualtricsAPI::ResponseExport.new(:id => "export1") }
|
18
10
|
let(:export_2) { QualtricsAPI::ResponseExport.new(:id => "export2") }
|
@@ -27,7 +19,6 @@ describe QualtricsAPI::ResponseExportCollection do
|
|
27
19
|
sut = subject["eee 3"]
|
28
20
|
expect(sut).to be_a QualtricsAPI::ResponseExport
|
29
21
|
expect(sut.id).to eq "eee 3"
|
30
|
-
expect(sut.connection).to eq connection
|
31
22
|
end
|
32
23
|
end
|
33
24
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QualtricsAPI::ResponseExport do
|
4
|
-
|
5
|
-
subject { described_class.new id: "someId", connection: connection }
|
4
|
+
subject { described_class.new id: "someId" }
|
6
5
|
|
7
6
|
describe "#completed?" do
|
8
7
|
it "is true when @completed is true" do
|
@@ -74,11 +73,9 @@ describe QualtricsAPI::ResponseExport do
|
|
74
73
|
end
|
75
74
|
|
76
75
|
describe "#update_status" do
|
77
|
-
let(:client) { QualtricsAPI.new TEST_API_TOKEN }
|
78
|
-
|
79
76
|
it "updates the status of the export then returns itself" do
|
80
77
|
VCR.use_cassette("response_export_update_success") do
|
81
|
-
subject = described_class.new id: "ES_cwLvnQHobKfV9t3"
|
78
|
+
subject = described_class.new id: "ES_cwLvnQHobKfV9t3"
|
82
79
|
|
83
80
|
result = subject.update_status
|
84
81
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QualtricsAPI::Services::ResponseExportService do
|
4
|
-
|
5
4
|
describe "initialize" do
|
6
5
|
let(:params) do
|
7
6
|
{
|
@@ -21,9 +20,7 @@ describe QualtricsAPI::Services::ResponseExportService do
|
|
21
20
|
spss_string_length: "15"
|
22
21
|
}
|
23
22
|
end
|
24
|
-
|
25
|
-
|
26
|
-
subject { described_class.new params.merge(connection: connection) }
|
23
|
+
subject { described_class.new params }
|
27
24
|
|
28
25
|
describe "assign options" do
|
29
26
|
before do
|
@@ -36,12 +33,8 @@ describe QualtricsAPI::Services::ResponseExportService do
|
|
36
33
|
end
|
37
34
|
end
|
38
35
|
|
39
|
-
it "assigns connection" do
|
40
|
-
expect(subject.connection).to eq connection
|
41
|
-
end
|
42
|
-
|
43
36
|
describe "defaults" do
|
44
|
-
subject { described_class.new
|
37
|
+
subject { described_class.new }
|
45
38
|
|
46
39
|
it "has default @use_labels - false" do
|
47
40
|
expect(subject.use_labels).to eq false
|
@@ -63,7 +56,7 @@ describe QualtricsAPI::Services::ResponseExportService do
|
|
63
56
|
|
64
57
|
describe "#start" do
|
65
58
|
it "calls url with export params" do
|
66
|
-
expect(connection).to receive(:get).with("surveys/s_id/responseExports", {
|
59
|
+
expect(QualtricsAPI.connection).to receive(:get).with("surveys/s_id/responseExports", {
|
67
60
|
"responseSetId" => "r_set_id",
|
68
61
|
"fileType" => "file type",
|
69
62
|
"lastResponseId" => "l_id",
|
@@ -82,7 +75,7 @@ describe QualtricsAPI::Services::ResponseExportService do
|
|
82
75
|
end
|
83
76
|
|
84
77
|
it "assigns and returns a ResponseExport with the id in the url" do
|
85
|
-
allow(connection).to receive(:get)
|
78
|
+
allow(QualtricsAPI.connection).to receive(:get)
|
86
79
|
.and_return(double('resBody', body: {"result" => { "exportStatus" => "some/url/exportId" }}))
|
87
80
|
sut = subject.start
|
88
81
|
expect(sut).to be_a QualtricsAPI::ResponseExport
|
@@ -92,11 +85,9 @@ describe QualtricsAPI::Services::ResponseExportService do
|
|
92
85
|
end
|
93
86
|
|
94
87
|
describe "#integration" do
|
95
|
-
let(:client) { QualtricsAPI.new TEST_API_TOKEN }
|
96
|
-
|
97
88
|
subject do
|
98
89
|
VCR.use_cassette("response_export_start_success") do
|
99
|
-
|
90
|
+
QualtricsAPI.surveys["SV_djzgZ6eJXqnIUyF"].export_responses.start
|
100
91
|
end
|
101
92
|
end
|
102
93
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QualtricsAPI::SurveyCollection do
|
4
|
-
|
5
|
-
|
6
|
-
subject { described_class.new connection: connection, scope_id: "fake_scopeId" }
|
4
|
+
subject { described_class.new scope_id: "fake_scopeId" }
|
7
5
|
|
8
6
|
it "has a scope_id" do
|
9
7
|
expect(subject.scope_id).to eq "fake_scopeId"
|
@@ -17,10 +15,6 @@ describe QualtricsAPI::SurveyCollection do
|
|
17
15
|
expect(subject).to respond_to :scope_id=
|
18
16
|
end
|
19
17
|
|
20
|
-
it "takes a connection" do
|
21
|
-
expect(subject.connection).to eq connection
|
22
|
-
end
|
23
|
-
|
24
18
|
describe "#query_attributes" do
|
25
19
|
it "returns only scope_id" do
|
26
20
|
expect(subject.query_attributes.size).to eq 1
|
@@ -42,18 +36,14 @@ describe QualtricsAPI::SurveyCollection do
|
|
42
36
|
sut = subject["s3"]
|
43
37
|
expect(sut).to be_a QualtricsAPI::Survey
|
44
38
|
expect(sut.id).to eq "s3"
|
45
|
-
expect(sut.connection).to eq connection
|
46
39
|
end
|
47
40
|
end
|
48
41
|
|
49
42
|
describe "integration" do
|
50
|
-
|
51
|
-
|
52
|
-
subject { described_class.new connection: client.connection }
|
43
|
+
subject { described_class.new }
|
53
44
|
|
54
45
|
describe "#fetch" do
|
55
46
|
describe "when success" do
|
56
|
-
|
57
47
|
before do
|
58
48
|
expect(subject.size).to eq 0
|
59
49
|
end
|
@@ -69,10 +59,6 @@ describe QualtricsAPI::SurveyCollection do
|
|
69
59
|
expect(subject.first).to be_a QualtricsAPI::Survey
|
70
60
|
end
|
71
61
|
|
72
|
-
it "passes down the connection" do
|
73
|
-
expect(subject.all.first.connection).to eq client.connection
|
74
|
-
end
|
75
|
-
|
76
62
|
it "returns itself" do
|
77
63
|
expect(result).to eq subject
|
78
64
|
end
|
data/spec/lib/survey_spec.rb
CHANGED
@@ -12,9 +12,7 @@ describe QualtricsAPI::Survey do
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
subject { described_class.new qualtrics_response.merge(connection: connection) }
|
15
|
+
subject { described_class.new qualtrics_response }
|
18
16
|
|
19
17
|
it "has an id" do
|
20
18
|
expect(subject.id).to eq qualtrics_response["id"]
|
@@ -40,10 +38,6 @@ describe QualtricsAPI::Survey do
|
|
40
38
|
expect(subject.status).to eq qualtrics_response["status"]
|
41
39
|
end
|
42
40
|
|
43
|
-
it "has a connection" do
|
44
|
-
expect(subject.connection).to eq connection
|
45
|
-
end
|
46
|
-
|
47
41
|
describe "export_responses" do
|
48
42
|
let(:options) do
|
49
43
|
{
|
@@ -53,8 +47,7 @@ describe QualtricsAPI::Survey do
|
|
53
47
|
|
54
48
|
it "inits a ResponseExportService with options" do
|
55
49
|
expect(QualtricsAPI::Services::ResponseExportService).to receive(:new).with(start_date: options[:start_date],
|
56
|
-
survey_id: subject.id
|
57
|
-
connection: subject.connection)
|
50
|
+
survey_id: subject.id)
|
58
51
|
|
59
52
|
subject.export_responses(options)
|
60
53
|
end
|
data/spec/qualtrics_api_spec.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QualtricsAPI do
|
4
|
-
|
5
4
|
describe "#new" do
|
6
|
-
|
7
|
-
subject { QualtricsAPI.new("someToken") }
|
5
|
+
subject { QualtricsAPI }
|
8
6
|
|
9
7
|
it "initializes a Client with the token passed" do
|
10
8
|
expect(subject).to be_kind_of(QualtricsAPI::Client)
|
11
|
-
expect(subject.api_token).to eq "someToken"
|
12
9
|
end
|
13
10
|
end
|
14
11
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'qualtrics_api'
|
2
|
+
require 'pry'
|
2
3
|
require 'vcr'
|
3
4
|
|
4
5
|
TEST_API_TOKEN = "6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ"
|
@@ -7,3 +8,7 @@ VCR.configure do |config|
|
|
7
8
|
config.cassette_library_dir = "fixtures/vcr_cassettes"
|
8
9
|
config.hook_into :faraday
|
9
10
|
end
|
11
|
+
|
12
|
+
QualtricsAPI.configure do |config|
|
13
|
+
config.api_token = TEST_API_TOKEN
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qualtrics_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yurui Zhang
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -124,6 +124,20 @@ dependencies:
|
|
124
124
|
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '4.5'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: pry
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.10.1
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 0.10.1
|
127
141
|
description: |-
|
128
142
|
A Ruby wrapper for Qualtrics REST API version 3.0.
|
129
143
|
See https://co1.qualtrics.com/APIDocs/ for API documents.
|
@@ -157,6 +171,7 @@ files:
|
|
157
171
|
- fixtures/vcr_cassettes/survey_collection_fetch_with_scopeId_success.yml
|
158
172
|
- lib/qualtrics_api.rb
|
159
173
|
- lib/qualtrics_api/client.rb
|
174
|
+
- lib/qualtrics_api/configurable.rb
|
160
175
|
- lib/qualtrics_api/panel.rb
|
161
176
|
- lib/qualtrics_api/panel_collection.rb
|
162
177
|
- lib/qualtrics_api/panel_import.rb
|