qualtrics_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +141 -0
- data/Rakefile +7 -0
- data/fixtures/vcr_cassettes/response_export_start_success.yml +32 -0
- data/fixtures/vcr_cassettes/response_export_update_success.yml +61 -0
- data/fixtures/vcr_cassettes/survey_collection_fetch_fail.yml +33 -0
- data/fixtures/vcr_cassettes/survey_collection_fetch_sucess.yml +33 -0
- data/fixtures/vcr_cassettes/survey_collection_fetch_with_scopeId_success.yml +33 -0
- data/lib/qualtrics_api.rb +23 -0
- data/lib/qualtrics_api/client.rb +32 -0
- data/lib/qualtrics_api/request_error_handler.rb +37 -0
- data/lib/qualtrics_api/response_export.rb +40 -0
- data/lib/qualtrics_api/response_export_collection.rb +24 -0
- data/lib/qualtrics_api/services/response_export_service.rb +90 -0
- data/lib/qualtrics_api/survey.rb +29 -0
- data/lib/qualtrics_api/survey_collection.rb +64 -0
- data/lib/qualtrics_api/url.rb +3 -0
- data/lib/qualtrics_api/version.rb +3 -0
- data/qualtrics_api.gemspec +30 -0
- data/spec/lib/client_spec.rb +47 -0
- data/spec/lib/response_export_collection_spec.rb +33 -0
- data/spec/lib/response_export_spec.rb +94 -0
- data/spec/lib/services/response_export_service_spec.rb +110 -0
- data/spec/lib/survey_collection_spec.rb +106 -0
- data/spec/lib/survey_spec.rb +60 -0
- data/spec/qualtrics_api_spec.rb +14 -0
- data/spec/spec_helper.rb +9 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 629272d717f8d529b095c1771e54a7a3e2482a16
|
4
|
+
data.tar.gz: cf3fa9bf32e67fc055b5ead552334106d824b2cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9a1db695a3d34f476fd90da22cdc6c6653606053f5602de3e18d4836f42fb91d414ed37f62483c30ce86e32f95339c05c01e549e7a76585fbca3ee0bbf9a1811
|
7
|
+
data.tar.gz: 0234a120e01f2d24b4e879c973207a330c28bfefee8685ed34aa5c8c62812916c7dfe3e9c604425ed022570bc8bd32a9708630760770b6ae0876af34b4a4bdc4
|
data/.gitignore
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#----------------------------------------------------------------------------
|
2
|
+
# Ignore these files when commiting to a git repository.
|
3
|
+
#
|
4
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
5
|
+
#
|
6
|
+
# The original version of this file is found here:
|
7
|
+
# https://github.com/RailsApps/rails3-application-templates/raw/master/files/gitignore.txt
|
8
|
+
#
|
9
|
+
# Corrections? Improvements? Create a GitHub issue:
|
10
|
+
# http://github.com/RailsApps/rails3-application-templates/issues
|
11
|
+
#----------------------------------------------------------------------------
|
12
|
+
/.yardoc
|
13
|
+
/Gemfile.lock
|
14
|
+
/_yardoc/
|
15
|
+
/coverage/
|
16
|
+
/doc/
|
17
|
+
/pkg/
|
18
|
+
/spec/reports/
|
19
|
+
/tmp/
|
20
|
+
*.bundle
|
21
|
+
*.so
|
22
|
+
*.o
|
23
|
+
*.a
|
24
|
+
mkmf.log
|
25
|
+
|
26
|
+
# bundler state
|
27
|
+
/.bundle/
|
28
|
+
/vendor/bundle/
|
29
|
+
|
30
|
+
# tmp files and logs
|
31
|
+
/log/*
|
32
|
+
/tmp/*
|
33
|
+
|
34
|
+
# various artifacts
|
35
|
+
**.war
|
36
|
+
.rspec
|
37
|
+
.tags
|
38
|
+
.env
|
39
|
+
|
40
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
41
|
+
# or operating system, you probably want to add a global ignore instead:
|
42
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
43
|
+
#
|
44
|
+
# Here are some files you may want to ignore globally:
|
45
|
+
|
46
|
+
# scm revert files
|
47
|
+
**.orig
|
48
|
+
|
49
|
+
# Mac finder artifacts
|
50
|
+
.DS_Store
|
51
|
+
|
52
|
+
# Netbeans project directory
|
53
|
+
/nbproject/
|
54
|
+
|
55
|
+
# RubyMine project files
|
56
|
+
.idea
|
57
|
+
|
58
|
+
# Textmate project files
|
59
|
+
/*.tmproj
|
60
|
+
|
61
|
+
# vim artifacts
|
62
|
+
**.swp
|
63
|
+
|
64
|
+
# local todo file
|
65
|
+
TODO
|
66
|
+
|
67
|
+
# sublime
|
68
|
+
/*.sublime-project
|
69
|
+
/*.sublime-workspace
|
70
|
+
|
71
|
+
# floobits
|
72
|
+
.floo
|
73
|
+
.flooignore
|
74
|
+
FLOOBITS_README.md
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Yurui Zhang
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# QualtricsAPI
|
2
|
+
|
3
|
+
Ruby wrapper for Qualtrics REST ControlPanel API version 3.0.
|
4
|
+
[API Documents/Play Ground](https://co1.qualtrics.com/APIDocs/)
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'qualtrics_api'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install qualtrics_api
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### Initialize
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
client = QualtricsAPI.new "YOUR_QUALTRICS_API_KEY"
|
28
|
+
# => #<QualtricsAPI::Client:0x007fcb74496528 @api_token="YOUR_QUALTRICS_API_KEY">
|
29
|
+
```
|
30
|
+
|
31
|
+
### Surveys
|
32
|
+
|
33
|
+
To get all your surveys:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
client.surveys.fetch
|
37
|
+
# => #<QualtricsAPI::SurveyCollection:0x007fcb72cce350 ....>
|
38
|
+
```
|
39
|
+
|
40
|
+
You can also add a scopeId:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
client.surveys.fetch(scope_id: "someOwnerIdMaybe")
|
44
|
+
# => #<QualtricsAPI::SurveyCollection:0x007fcb72adaf21 ....>
|
45
|
+
```
|
46
|
+
|
47
|
+
After you have received results, you can search for a survey by id:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
survey = client.surveys.find("surveyIdHere")
|
51
|
+
# => #<QualtricsAPI::Survey:0x007fcb724f9468 @id="surveyIdHere" ...>
|
52
|
+
```
|
53
|
+
|
54
|
+
or just:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
survey = client.surveys["surveyIdHere"]
|
58
|
+
# => #<QualtricsAPI::Survey:0x007fcb724f9468 @id="surveyIdHere" ...>
|
59
|
+
```
|
60
|
+
|
61
|
+
#### Export Responses From a Survey
|
62
|
+
|
63
|
+
Once you have a `survey` object (`QualtricsAPI::Survey`], you can start
|
64
|
+
an export like so:
|
65
|
+
|
66
|
+
(You can pass any supported options in ruby style!)
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
export_service = survey.export_responses({ start_date: "2015-03-03 11:11:10" })
|
70
|
+
# => #<QualtricsAPI::Services::ResponseExportService:0x007fcb742e4e50 ....>
|
71
|
+
```
|
72
|
+
|
73
|
+
or you can configure it laster...
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
export_service = survey.export_responses
|
77
|
+
# => #<QualtricsAPI::Services::ResponseExport:0x007fcb742e4e50 ....>
|
78
|
+
export_service.start_date = "2015-03-03 11:11:10"
|
79
|
+
```
|
80
|
+
(See Qualtrics API doc for a full list of options)
|
81
|
+
|
82
|
+
Then start the export:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
export = export_service.start
|
86
|
+
# => #<QualtricsAPI::ResponseExport:0x007fcb742e4e50 ....>
|
87
|
+
```
|
88
|
+
|
89
|
+
Then to check the progress
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
export.status
|
93
|
+
# => "20.333333%"
|
94
|
+
|
95
|
+
export.completed?
|
96
|
+
# => fasle
|
97
|
+
|
98
|
+
# call again to refresh
|
99
|
+
export.status
|
100
|
+
# => "100%"
|
101
|
+
|
102
|
+
export.completed?
|
103
|
+
# => true
|
104
|
+
```
|
105
|
+
|
106
|
+
Once it's finished, you can get the response file URL:
|
107
|
+
```ruby
|
108
|
+
export.file_url
|
109
|
+
# => "https://some.amazon.s3.com/file/path?withTimeStamps=AndOtherStuff"
|
110
|
+
```
|
111
|
+
|
112
|
+
#### Checking status on a previous response export
|
113
|
+
|
114
|
+
Each response export yeilds an `id`
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
export = survey.export_responses({ }).start
|
118
|
+
# => #<QualtricsAPI::ResponseExport:0x007fcb742e4e50 ....>
|
119
|
+
|
120
|
+
export.id
|
121
|
+
# => "someExportID"
|
122
|
+
```
|
123
|
+
|
124
|
+
You can save it somewhere in your app and check back later (if you know
|
125
|
+
it's gonna take a while!)
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
client = QualtricsAPI.new "YOUR QUALTRICS API TOKEN"
|
129
|
+
export = client.response_exports["someExportID"]
|
130
|
+
# => #<QualtricsAPI::ResponseExport:0x007fcb742e4e50 ....>
|
131
|
+
export.status
|
132
|
+
=> "99.99999%"
|
133
|
+
```
|
134
|
+
|
135
|
+
## Contributing
|
136
|
+
|
137
|
+
1. Fork it ( https://github.com/pallymore/qualtrics_api/fork )
|
138
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
139
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
140
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
141
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://co1.qualtrics.com/API/v1/surveys/SV_djzgZ6eJXqnIUyF/responseExports?apiToken=6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ&decimalFormat=.&fileType=CSV&useLabels=false&useLocalTime=false
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- Apache-Coyote/1.1
|
19
|
+
content-type:
|
20
|
+
- application/json
|
21
|
+
content-length:
|
22
|
+
- '178'
|
23
|
+
date:
|
24
|
+
- Mon, 23 Mar 2015 00:05:00 GMT
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: '{"result":{"exportStatus":"http://co1.qualtrics.com/API/v1/surveys/responseExports/ES_cwLvnQHobKfV9t3"},"meta":{"status":"Success","qualtricsErrorCode":null,"errorMessage":null}}'
|
30
|
+
http_version:
|
31
|
+
recorded_at: Mon, 23 Mar 2015 00:05:01 GMT
|
32
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://co1.qualtrics.com/API/v1/surveys/responseExports/ES_cwLvnQHobKfV9t3?apiToken=6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 301
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
location:
|
18
|
+
- https://co1.qualtrics.com/API/v1/surveys/responseExports/ES_cwLvnQHobKfV9t3?apiToken=6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ
|
19
|
+
server:
|
20
|
+
- BigIP
|
21
|
+
content-length:
|
22
|
+
- '0'
|
23
|
+
date:
|
24
|
+
- Mon, 23 Mar 2015 00:58:29 GMT
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: ''
|
30
|
+
http_version:
|
31
|
+
recorded_at: Mon, 23 Mar 2015 00:58:29 GMT
|
32
|
+
- request:
|
33
|
+
method: get
|
34
|
+
uri: https://co1.qualtrics.com/API/v1/surveys/responseExports/ES_cwLvnQHobKfV9t3?apiToken=6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ''
|
38
|
+
headers:
|
39
|
+
User-Agent:
|
40
|
+
- Faraday v0.8.9
|
41
|
+
response:
|
42
|
+
status:
|
43
|
+
code: 200
|
44
|
+
message:
|
45
|
+
headers:
|
46
|
+
server:
|
47
|
+
- Apache-Coyote/1.1
|
48
|
+
content-type:
|
49
|
+
- application/json
|
50
|
+
content-length:
|
51
|
+
- '278'
|
52
|
+
date:
|
53
|
+
- Mon, 23 Mar 2015 00:58:30 GMT
|
54
|
+
connection:
|
55
|
+
- close
|
56
|
+
body:
|
57
|
+
encoding: UTF-8
|
58
|
+
string: '{"result":{"percentComplete":100.0,"fileUrl":"https://qualtrics-export.s3.amazonaws.com/F_bJamXsfzuGyjRWJ?Expires=1427673600&AWSAccessKeyId=AKIAI3EW3KB5A6DT2WDA&Signature=cBuebySMaFIU/St4q8idIUuxuG4%3D"},"meta":{"status":"Success","qualtricsErrorCode":null,"errorMessage":null}}'
|
59
|
+
http_version:
|
60
|
+
recorded_at: Mon, 23 Mar 2015 00:58:30 GMT
|
61
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://co1.qualtrics.com/API/v1/surveys?apiToken=6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ&scopeId=fake
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 404
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- Apache-Coyote/1.1
|
19
|
+
content-type:
|
20
|
+
- application/json
|
21
|
+
content-length:
|
22
|
+
- '186'
|
23
|
+
date:
|
24
|
+
- Sun, 22 Mar 2015 21:05:58 GMT
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: '{"meta":{"status":"Error","errorMessage":"You do not have permission
|
30
|
+
to access this resource.","internalErrorCode":"GS_5","errorId":"3d6a9018-3b87-4265-b662-572ad96bbe6c"},"result":null}'
|
31
|
+
http_version:
|
32
|
+
recorded_at: Sun, 22 Mar 2015 21:05:58 GMT
|
33
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://co1.qualtrics.com/API/v1/surveys?apiToken=6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- Apache-Coyote/1.1
|
19
|
+
content-type:
|
20
|
+
- application/json
|
21
|
+
content-length:
|
22
|
+
- '223'
|
23
|
+
date:
|
24
|
+
- Sun, 22 Mar 2015 21:05:57 GMT
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: '{"result":[{"id":"SV_djzgZ6eJXqnIUyF","name":"test_survey","ownerId":"UR_3fnAz35QCGlr725","lastModified":"2015-03-20
|
30
|
+
12:56:33","status":"Inactive"}],"meta":{"status":"Success","qualtricsErrorCode":null,"errorMessage":null}}'
|
31
|
+
http_version:
|
32
|
+
recorded_at: Sun, 22 Mar 2015 21:05:57 GMT
|
33
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://co1.qualtrics.com/API/v1/surveys?apiToken=6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ&scopeId=UR_3fnAz35QCGlr725
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
server:
|
18
|
+
- Apache-Coyote/1.1
|
19
|
+
content-type:
|
20
|
+
- application/json
|
21
|
+
content-length:
|
22
|
+
- '223'
|
23
|
+
date:
|
24
|
+
- Sun, 22 Mar 2015 21:05:58 GMT
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: '{"result":[{"id":"SV_djzgZ6eJXqnIUyF","name":"test_survey","ownerId":"UR_3fnAz35QCGlr725","lastModified":"2015-03-20
|
30
|
+
12:56:33","status":"Inactive"}],"meta":{"status":"Success","qualtricsErrorCode":null,"errorMessage":null}}'
|
31
|
+
http_version:
|
32
|
+
recorded_at: Sun, 22 Mar 2015 21:05:58 GMT
|
33
|
+
recorded_with: VCR 2.9.3
|