qualtrics 0.5.7 → 0.5.8

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: 600642d8f538f174a3ff6d1ab855137cc4d2b002
4
- data.tar.gz: 7f54b4d3e98360d1be50193fe6472d69bb1a8155
3
+ metadata.gz: c4d90b05afe3ccaf9a2d35b379c7600bfe98d40b
4
+ data.tar.gz: c144ce0eeec7e63c18e3964edcf70baf9b041e26
5
5
  SHA512:
6
- metadata.gz: dbf5fc3a68675c2627b848c0895ec9e8d0d0cbdfcfed7fcf348106e1a5a14ef6cce02648035395a569dd59df36126cb979166c99c0a00ac6a48bc2935cdc4ece
7
- data.tar.gz: b7963341533c26e7810b37712edff9a42f1c88c0c7115d721df45044ef0169d543d51ecac673ea6a29e171f5fcf5304add8ab75fa1dbaec3499552194042357f
6
+ metadata.gz: 57a35f15099f12f0e0a53d93a8a32e56b5a540341e279484feb51b2217b6a4e09a4468b424a20a64c6f2c1150a6e8fc668edec3be76a4e6155ec0ea5a1f978c4
7
+ data.tar.gz: d4370401903c2822eecbd964edfc71d97b8ed925fac277cbed9fc13765cfc718c12fdb58dec8de9677ec49f094397fe8822463f7af892805f4299ffd92509375
@@ -50,4 +50,5 @@ module Qualtrics
50
50
  class ServerErrorEncountered < Error; end
51
51
  class UpdateNotAllowed < Error; end
52
52
  class UnexpectedRequestMethod < Error; end
53
+ class UnexpectedContentType < Error; end
53
54
  end
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require 'csv'
2
3
 
3
4
  module Qualtrics
4
5
  class Response
@@ -28,13 +29,29 @@ module Qualtrics
28
29
  if @body.nil?
29
30
  if @raw_response.body == ''
30
31
  @body = {}
31
- else
32
+ elsif content_type == 'application/json'
32
33
  @body = JSON.parse(@raw_response.body)
34
+ elsif content_type == 'application/vnd.msexcel'
35
+ @body = CSV.parse(@raw_response.body)
36
+ else
37
+ raise Qualtrics::UnexpectedContentType, content_type
33
38
  end
34
39
  end
35
40
  @body
36
41
  end
37
42
 
43
+ def content_type
44
+ if @content_type.nil?
45
+ header = @raw_response.headers['Content-Type']
46
+ if header.nil?
47
+ @content_type = {}
48
+ else
49
+ @content_type = header
50
+ end
51
+ end
52
+ @content_type
53
+ end
54
+
38
55
  private
39
56
  def error_message
40
57
  body['Meta'].nil? ? 'No error message' : body['Meta']['ErrorMessage']
@@ -1,3 +1,3 @@
1
1
  module Qualtrics
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.8"
3
3
  end
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: Category=Great+Category&Format=JSON&LibraryID=<QUALTRICS_LIBRARY_ID>&Name=Newest+Panel&Request=createPanel&Token=<QUALTRICS_TOKEN>&User=brookesidedev%40brookeside.com&Version=2.3
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.0
11
+ - Faraday v0.9.1
12
12
  Content-Type:
13
13
  - application/x-www-form-urlencoded
14
14
  Accept-Encoding:
@@ -25,42 +25,42 @@ http_interactions:
25
25
  Cache-Control:
26
26
  - max-age=315360000
27
27
  Expires:
28
- - Sun, 23 Feb 2025 16:46:01 GMT
28
+ - Fri, 28 Feb 2025 16:05:26 GMT
29
29
  P3p:
30
30
  - CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE", CP="CAO
31
31
  DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
32
32
  Servershortname:
33
- - w2
33
+ - w18
34
34
  X-Cnection:
35
35
  - close
36
36
  X-Edgeconnect-Midmile-Rtt:
37
- - '4'
38
- - '9'
37
+ - '1'
38
+ - '6'
39
39
  X-Edgeconnect-Origin-Mex-Latency:
40
- - '188'
41
- - '685'
40
+ - '230'
41
+ - '669'
42
42
  Content-Length:
43
43
  - '82'
44
44
  Content-Type:
45
45
  - application/json
46
46
  Date:
47
- - Thu, 26 Feb 2015 16:46:01 GMT
47
+ - Tue, 03 Mar 2015 16:05:26 GMT
48
48
  Connection:
49
49
  - keep-alive
50
50
  body:
51
51
  encoding: UTF-8
52
- string: '{"Meta":{"Status":"Success","Debug":""},"Result":{"PanelID":"ML_3K5ZfSGan8tHWO9"}}'
52
+ string: '{"Meta":{"Status":"Success","Debug":""},"Result":{"PanelID":"ML_emkzTL08MvdBaOV"}}'
53
53
  http_version:
54
- recorded_at: Thu, 26 Feb 2015 16:46:06 GMT
54
+ recorded_at: Tue, 03 Mar 2015 16:05:27 GMT
55
55
  - request:
56
56
  method: post
57
57
  uri: https://survey.qualtrics.com/WRAPI/ControlPanel/api.php
58
58
  body:
59
59
  encoding: UTF-8
60
- string: Format=JSON&LibraryID=<QUALTRICS_LIBRARY_ID>&PanelID=ML_3K5ZfSGan8tHWO9&Request=addRecipient&Token=<QUALTRICS_TOKEN>&User=brookesidedev%40brookeside.com&Version=2.3
60
+ string: Format=JSON&LibraryID=<QUALTRICS_LIBRARY_ID>&PanelID=ML_emkzTL08MvdBaOV&Request=addRecipient&Token=<QUALTRICS_TOKEN>&User=brookesidedev%40brookeside.com&Version=2.3
61
61
  headers:
62
62
  User-Agent:
63
- - Faraday v0.9.0
63
+ - Faraday v0.9.1
64
64
  Content-Type:
65
65
  - application/x-www-form-urlencoded
66
66
  Accept-Encoding:
@@ -77,7 +77,7 @@ http_interactions:
77
77
  Cache-Control:
78
78
  - max-age=315360000
79
79
  Expires:
80
- - Sun, 23 Feb 2025 16:46:01 GMT
80
+ - Fri, 28 Feb 2025 16:05:27 GMT
81
81
  P3p:
82
82
  - CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE", CP="CAO
83
83
  DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
@@ -86,33 +86,33 @@ http_interactions:
86
86
  X-Cnection:
87
87
  - close
88
88
  X-Edgeconnect-Midmile-Rtt:
89
- - '10'
90
- - '8'
89
+ - '14'
90
+ - '5'
91
91
  X-Edgeconnect-Origin-Mex-Latency:
92
- - '217'
93
- - '621'
92
+ - '222'
93
+ - '643'
94
94
  Content-Length:
95
95
  - '88'
96
96
  Content-Type:
97
97
  - application/json
98
98
  Date:
99
- - Thu, 26 Feb 2015 16:46:02 GMT
99
+ - Tue, 03 Mar 2015 16:05:27 GMT
100
100
  Connection:
101
101
  - keep-alive
102
102
  body:
103
103
  encoding: UTF-8
104
- string: '{"Meta":{"Status":"Success","Debug":""},"Result":{"RecipientID":"MLRP_0Apg2lyffylB6RL"}}'
104
+ string: '{"Meta":{"Status":"Success","Debug":""},"Result":{"RecipientID":"MLRP_8rch1z9XaqPya0Z"}}'
105
105
  http_version:
106
- recorded_at: Thu, 26 Feb 2015 16:46:07 GMT
106
+ recorded_at: Tue, 03 Mar 2015 16:05:28 GMT
107
107
  - request:
108
108
  method: post
109
109
  uri: https://survey.qualtrics.com/WRAPI/ControlPanel/api.php
110
110
  body:
111
111
  encoding: UTF-8
112
- string: Format=JSON&LibraryID=<QUALTRICS_LIBRARY_ID>&PanelID=ML_3K5ZfSGan8tHWO9&Request=deletePanel&Token=<QUALTRICS_TOKEN>&User=brookesidedev%40brookeside.com&Version=2.3
112
+ string: Format=JSON&LibraryID=<QUALTRICS_LIBRARY_ID>&PanelID=ML_emkzTL08MvdBaOV&Request=deletePanel&Token=<QUALTRICS_TOKEN>&User=brookesidedev%40brookeside.com&Version=2.3
113
113
  headers:
114
114
  User-Agent:
115
- - Faraday v0.9.0
115
+ - Faraday v0.9.1
116
116
  Content-Type:
117
117
  - application/x-www-form-urlencoded
118
118
  Accept-Encoding:
@@ -129,31 +129,31 @@ http_interactions:
129
129
  Cache-Control:
130
130
  - max-age=315360000
131
131
  Expires:
132
- - Sun, 23 Feb 2025 16:46:02 GMT
132
+ - Fri, 28 Feb 2025 16:05:28 GMT
133
133
  P3p:
134
134
  - CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE", CP="CAO
135
135
  DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
136
136
  Servershortname:
137
- - w17
137
+ - w541
138
138
  X-Cnection:
139
139
  - close
140
140
  X-Edgeconnect-Midmile-Rtt:
141
- - '2'
141
+ - '13'
142
142
  - '2'
143
143
  X-Edgeconnect-Origin-Mex-Latency:
144
- - '410'
145
- - '943'
144
+ - '273'
145
+ - '892'
146
146
  Content-Length:
147
147
  - '66'
148
148
  Content-Type:
149
149
  - application/json
150
150
  Date:
151
- - Thu, 26 Feb 2015 16:46:03 GMT
151
+ - Tue, 03 Mar 2015 16:05:28 GMT
152
152
  Connection:
153
153
  - keep-alive
154
154
  body:
155
155
  encoding: UTF-8
156
156
  string: '{"Meta":{"Status":"Success","Debug":""},"Result":{"Success":true}}'
157
157
  http_version:
158
- recorded_at: Thu, 26 Feb 2015 16:46:08 GMT
159
- recorded_with: VCR 2.9.2
158
+ recorded_at: Tue, 03 Mar 2015 16:05:29 GMT
159
+ recorded_with: VCR 2.9.3
@@ -7,10 +7,10 @@ describe Qualtrics::Response, :vcr do
7
7
  let(:test_endpoint) do
8
8
  Faraday.new do |builder|
9
9
  builder.adapter :test, Faraday::Adapter::Test::Stubs.new do |m|
10
- m.get('/success') { |env| [ 200, {}, '{"Meta":{"Status":"Success","Debug":""},"Result":{"PanelID":"ML_8BKIZdmCic6tkLb"}}' ]}
11
- m.get('/server_error') { |env| [500, {}, '']}
12
- m.get('/server_error2') { |env| [400, {}, '{"Meta":{"Status":"Fubar","Debug":"","ErrorMessage":"Invalid request. Missing or invalid parameter RecipientID."}}']}
13
- m.get('/failure') { |env| [ 200, {}, '{"Meta":{"Status":"Fubar","Debug":""}}' ]}
10
+ m.get('/success') { |env| [ 200, {'Content-Type'=>'application/json'}, '{"Meta":{"Status":"Success","Debug":""},"Result":{"PanelID":"ML_8BKIZdmCic6tkLb"}}' ]}
11
+ m.get('/server_error') { |env| [500, {'Content-Type'=>'application/json'}, '']}
12
+ m.get('/server_error2') { |env| [400, {'Content-Type'=>'application/json'}, '{"Meta":{"Status":"Fubar","Debug":"","ErrorMessage":"Invalid request. Missing or invalid parameter RecipientID."}}']}
13
+ m.get('/failure') { |env| [ 200, {'Content-Type'=>'application/json'}, '{"Meta":{"Status":"Fubar","Debug":""}}' ]}
14
14
  end
15
15
  end
16
16
  end
@@ -50,4 +50,36 @@ describe Qualtrics::Response, :vcr do
50
50
  end
51
51
  end
52
52
 
53
+ context 'parsing different content types' do
54
+ let(:content_endpoints) do
55
+ Faraday.new do |builder|
56
+ builder.adapter :test, Faraday::Adapter::Test::Stubs.new do |m|
57
+ m.get('/csv_response') { |env| [ 200, {'Content-Type'=>'application/vnd.msexcel'}, 'csv,stuff' ]}
58
+ m.get('/json_response') { |env| [ 200, {'Content-Type'=>'application/json'}, '{"Meta":{"Status":"Fubar","Debug":""}}' ]}
59
+ m.get('/random_content') { |env| [ 200, {'Content-Type'=>'random stuff'}, 'not a real body' ]}
60
+ end
61
+ end
62
+ end
63
+
64
+ it 'can parse csv' do
65
+ # s = Qualtrics::Submission.new(id: 'R_5msAm76fXKn1adf', survey_id:'SV_8deJytTY3InclQ9')
66
+ raw_response = content_endpoints.get('/csv_response')
67
+ response = Qualtrics::Response.new(raw_response)
68
+ expect(lambda{ response.send(:body) }).to_not raise_error
69
+ end
70
+
71
+ it 'can parse json' do
72
+ # s = Qualtrics::Submission.new(id: 'R_5msAm76fXKn1adf', survey_id:'SV_8deJytTY3InclQ9')
73
+ raw_response = content_endpoints.get('/json_response')
74
+ response = Qualtrics::Response.new(raw_response)
75
+ expect(lambda{ response.send(:body) }).to_not raise_error
76
+ end
77
+
78
+ it 'raises an error for other content types' do
79
+ # s = Qualtrics::Submission.new(id: 'R_5msAm76fXKn1adf', survey_id:'SV_8deJytTY3InclQ9')
80
+ raw_response = content_endpoints.get('/random_content')
81
+ response = Qualtrics::Response.new(raw_response)
82
+ expect(lambda{ response.send(:body) }).to raise_error(Qualtrics::UnexpectedContentType)
83
+ end
84
+ end
53
85
  end
@@ -2,8 +2,6 @@ require 'rspec'
2
2
  require 'pry'
3
3
  require 'qualtrics'
4
4
 
5
- require 'mocha/api'
6
-
7
5
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
8
6
 
9
7
  RSpec.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qualtrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sun
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-02 00:00:00.000000000 Z
12
+ date: 2015-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: configatron