qualtrics_api 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -7
  3. data/fixtures/vcr_cassettes/panel_collection_fetch_fail.yml +10 -8
  4. data/fixtures/vcr_cassettes/panel_collection_fetch_success.yml +14 -11
  5. data/fixtures/vcr_cassettes/panel_import_update_success.yml +12 -10
  6. data/fixtures/vcr_cassettes/panel_member_collection_create_fail.yml +4 -2
  7. data/fixtures/vcr_cassettes/panel_member_collection_create_success.yml +33 -26
  8. data/fixtures/vcr_cassettes/panel_member_collection_fetch_success.yml +15 -12
  9. data/fixtures/vcr_cassettes/response_export_start_success.yml +19 -14
  10. data/fixtures/vcr_cassettes/response_export_update_success.yml +12 -38
  11. data/fixtures/vcr_cassettes/survey_collection_fetch_fail.yml +4 -2
  12. data/fixtures/vcr_cassettes/survey_collection_fetch_sucess.yml +12 -10
  13. data/lib/qualtrics_api/client.rb +3 -3
  14. data/lib/qualtrics_api/panel_collection.rb +4 -4
  15. data/lib/qualtrics_api/panel_import.rb +1 -1
  16. data/lib/qualtrics_api/panel_member.rb +8 -8
  17. data/lib/qualtrics_api/panel_member_collection.rb +9 -6
  18. data/lib/qualtrics_api/request_error_handler.rb +5 -9
  19. data/lib/qualtrics_api/response_export.rb +2 -2
  20. data/lib/qualtrics_api/services/response_export_service.rb +13 -19
  21. data/lib/qualtrics_api/survey.rb +2 -4
  22. data/lib/qualtrics_api/survey_collection.rb +4 -30
  23. data/lib/qualtrics_api/url.rb +1 -1
  24. data/lib/qualtrics_api/version.rb +1 -1
  25. data/qualtrics_api.gemspec +3 -3
  26. data/spec/lib/client_spec.rb +0 -4
  27. data/spec/lib/panel_import_spec.rb +2 -2
  28. data/spec/lib/panel_member_collection_spec.rb +4 -4
  29. data/spec/lib/panel_member_spec.rb +8 -8
  30. data/spec/lib/response_export_spec.rb +1 -1
  31. data/spec/lib/services/response_export_service_spec.rb +25 -29
  32. data/spec/lib/survey_collection_spec.rb +1 -28
  33. data/spec/lib/survey_spec.rb +2 -6
  34. data/spec/spec_helper.rb +1 -1
  35. metadata +9 -10
  36. data/fixtures/vcr_cassettes/survey_collection_fetch_with_scopeId_success.yml +0 -33
@@ -66,14 +66,14 @@ describe QualtricsAPI::PanelMember do
66
66
 
67
67
  it "serialize array of panel members" do
68
68
  expect(JSON.parse(members)).to eq(
69
- [{ "RecipientID" => "ML_abcdefg",
70
- "FirstName" => "Thom",
71
- "LastName" => "Yorke",
72
- "Email" => "thom@radiohead.com",
73
- "Language" => "EN",
74
- "Unsubscribed" => 1,
75
- "ExternalReference" => "1234",
76
- "EmbeddedData" => { "a" => "b", "b" => "c" } }])
69
+ [{ "recipientID" => "ML_abcdefg",
70
+ "firstName" => "Thom",
71
+ "lastName" => "Yorke",
72
+ "email" => "thom@radiohead.com",
73
+ "language" => "EN",
74
+ "unsubscribed" => 1,
75
+ "externalReference" => "1234",
76
+ "embeddedData" => { "a" => "b", "b" => "c" } }])
77
77
  end
78
78
  end
79
79
 
@@ -75,7 +75,7 @@ describe QualtricsAPI::ResponseExport do
75
75
  describe "#update_status" do
76
76
  it "updates the status of the export then returns itself" do
77
77
  VCR.use_cassette("response_export_update_success") do
78
- subject = described_class.new id: "ES_cwLvnQHobKfV9t3"
78
+ subject = described_class.new id: "ES_abcd"
79
79
 
80
80
  result = subject.update_status
81
81
 
@@ -4,20 +4,17 @@ describe QualtricsAPI::Services::ResponseExportService do
4
4
  describe "initialize" do
5
5
  let(:params) do
6
6
  {
7
+ format: "file type",
7
8
  survey_id: "s_id",
8
- response_set_id: "r_set_id",
9
- file_type: "file type",
10
9
  last_response_id: "l_id",
11
10
  start_date: "03/22/2015 06:11:11",
12
11
  end_date: "03/25/2015 06:00:00",
13
12
  limit: "1000",
14
13
  included_question_ids: "ids,ids",
15
- max_rows: "1000",
16
14
  use_labels: true,
17
- decimal_format: ",",
15
+ decimal_separator: ",",
18
16
  seen_unanswered_recode: "something",
19
- use_local_time: true,
20
- spss_string_length: "15"
17
+ use_local_time: true
21
18
  }
22
19
  end
23
20
  subject { described_class.new params }
@@ -44,39 +41,38 @@ describe QualtricsAPI::Services::ResponseExportService do
44
41
  expect(subject.use_local_time).to eq false
45
42
  end
46
43
 
47
- it "has default @file_type - csv" do
48
- expect(subject.file_type).to eq 'CSV'
44
+ it "has default @format - csv" do
45
+ expect(subject.format).to eq 'csv'
49
46
  end
50
47
 
51
- it "has default @decimal_format - ." do
52
- expect(subject.decimal_format).to eq '.'
48
+ it "has default @decimal_separator - ." do
49
+ expect(subject.decimal_separator).to eq '.'
53
50
  end
54
51
  end
55
52
  end
56
53
 
57
54
  describe "#start" do
58
55
  it "calls url with export params" do
59
- expect(QualtricsAPI.connection).to receive(:get).with("surveys/s_id/responseExports", {
60
- "responseSetId" => "r_set_id",
61
- "fileType" => "file type",
62
- "lastResponseId" => "l_id",
63
- "startDate" => "03/22/2015 06:11:11",
64
- "endDate" => "03/25/2015 06:00:00",
65
- "limit" => "1000",
66
- "includedQuestionIds" => "ids,ids",
67
- "maxRows" => "1000",
68
- "useLabels" => true,
69
- "decimalFormat" => ",",
70
- "seenUnansweredRecode" => "something",
71
- "useLocalTime" => true,
72
- "spssStringLength" => "15"
73
- }).and_return(double('resBody', body: {"result" => { "exportStatus" => "some/url" }}))
56
+ expect(QualtricsAPI.connection)
57
+ .to receive(:post)
58
+ .with("responseexports",
59
+ "format" => "file type",
60
+ "surveyId" => "s_id",
61
+ "lastResponseId" => "l_id",
62
+ "startDate" => "03/22/2015 06:11:11",
63
+ "endDate" => "03/25/2015 06:00:00",
64
+ "limit" => "1000",
65
+ "includedQuestionIds" => "ids,ids",
66
+ "useLabels" => true,
67
+ "decimalSeparator" => ",",
68
+ "seenUnansweredRecode" => "something",
69
+ "useLocalTime" => true).and_return(double('resBody', body: { "result" => { "exportStatus" => "some/url" } }))
74
70
  subject.start
75
71
  end
76
72
 
77
73
  it "assigns and returns a ResponseExport with the id in the url" do
78
- allow(QualtricsAPI.connection).to receive(:get)
79
- .and_return(double('resBody', body: {"result" => { "exportStatus" => "some/url/exportId" }}))
74
+ allow(QualtricsAPI.connection).to receive(:post)
75
+ .and_return(double('resBody', body: { "result" => { "id" => "exportId" } }))
80
76
  sut = subject.start
81
77
  expect(sut).to be_a QualtricsAPI::ResponseExport
82
78
  expect(subject.result).to eq sut
@@ -87,14 +83,14 @@ describe QualtricsAPI::Services::ResponseExportService do
87
83
  describe "#integration" do
88
84
  subject do
89
85
  VCR.use_cassette("response_export_start_success") do
90
- QualtricsAPI.surveys["SV_djzgZ6eJXqnIUyF"].export_responses.start
86
+ QualtricsAPI.surveys["SV_bpCTGQvjOqgd4RD"].export_responses.start
91
87
  end
92
88
  end
93
89
 
94
90
  it "assigns @result with the export id" do
95
91
  expect(subject).to_not be_nil
96
92
  expect(subject).to be_a QualtricsAPI::ResponseExport
97
- expect(subject.id).to eq "ES_cwLvnQHobKfV9t3"
93
+ expect(subject.id).to eq "ES_to9jgploprbdnvi7uir84vq59l"
98
94
  end
99
95
  end
100
96
  end
@@ -1,27 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe QualtricsAPI::SurveyCollection do
4
- subject { described_class.new scope_id: "fake_scopeId" }
5
-
6
- it "has a scope_id" do
7
- expect(subject.scope_id).to eq "fake_scopeId"
8
- end
9
-
10
4
  it "has no @all when initialized" do
11
5
  expect(subject.all).to eq []
12
6
  end
13
7
 
14
- it "can assign scope_id" do
15
- expect(subject).to respond_to :scope_id=
16
- end
17
-
18
- describe "#query_attributes" do
19
- it "returns only scope_id" do
20
- expect(subject.query_attributes.size).to eq 1
21
- expect(subject.query_attributes[:scope_id]).to eq "fake_scopeId"
22
- end
23
- end
24
-
25
8
  describe "#find, #[]" do
26
9
  let(:survey_1) { QualtricsAPI::Survey.new "id" => "s1" }
27
10
  let(:survey_2) { QualtricsAPI::Survey.new "id" => "s2" }
@@ -69,21 +52,11 @@ describe QualtricsAPI::SurveyCollection do
69
52
  subject.instance_variable_set :@all, [QualtricsAPI::Survey.new({})]
70
53
  expect {
71
54
  VCR.use_cassette("survey_collection_fetch_fail") do
72
- subject.fetch(scope_id: "fake") rescue nil
55
+ subject.fetch rescue nil
73
56
  end
74
57
  }.to change { subject.all }.to([])
75
58
  end
76
59
  end
77
-
78
- describe "with options" do
79
- it "updates the options" do
80
- VCR.use_cassette("survey_collection_fetch_with_scopeId_success") do
81
- expect(subject.scope_id).to be_nil
82
- subject.fetch(scope_id: "UR_3fnAz35QCGlr725")
83
- expect(subject.scope_id).to eq "UR_3fnAz35QCGlr725"
84
- end
85
- end
86
- end
87
60
  end
88
61
  end
89
62
 
@@ -30,12 +30,8 @@ describe QualtricsAPI::Survey do
30
30
  expect(subject.last_modified).to eq qualtrics_response["lastModified"]
31
31
  end
32
32
 
33
- it "has created_at" do
34
- expect(subject.created_at).to eq qualtrics_response["SurveyCreationDate"]
35
- end
36
-
37
- it "has status" do
38
- expect(subject.status).to eq qualtrics_response["status"]
33
+ it "has is_active" do
34
+ expect(subject.is_active).to eq qualtrics_response["is_active"]
39
35
  end
40
36
 
41
37
  describe "export_responses" do
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@ require 'qualtrics_api'
2
2
  require 'pry'
3
3
  require 'vcr'
4
4
 
5
- TEST_API_TOKEN = "6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ"
5
+ TEST_API_TOKEN = "6Wpo0Vsx1cN1kcHivCaGTz5IhOvchLrg1o4L0KOZ".freeze
6
6
 
7
7
  VCR.configure do |config|
8
8
  config.cassette_library_dir = "fixtures/vcr_cassettes"
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.8
4
+ version: 0.0.9
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-08-19 00:00:00.000000000 Z
13
+ date: 2016-04-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -60,42 +60,42 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '1.7'
63
+ version: '1.11'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '1.7'
70
+ version: '1.11'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rake
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '10.0'
77
+ version: '11.1'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '10.0'
84
+ version: '11.1'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rspec
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: '3.2'
91
+ version: '3.4'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: '3.2'
98
+ version: '3.4'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: vcr
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -168,7 +168,6 @@ files:
168
168
  - fixtures/vcr_cassettes/response_export_update_success.yml
169
169
  - fixtures/vcr_cassettes/survey_collection_fetch_fail.yml
170
170
  - fixtures/vcr_cassettes/survey_collection_fetch_sucess.yml
171
- - fixtures/vcr_cassettes/survey_collection_fetch_with_scopeId_success.yml
172
171
  - lib/qualtrics_api.rb
173
172
  - lib/qualtrics_api/base_collection.rb
174
173
  - lib/qualtrics_api/base_model.rb
@@ -224,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
223
  version: '0'
225
224
  requirements: []
226
225
  rubyforge_project:
227
- rubygems_version: 2.4.6
226
+ rubygems_version: 2.5.1
228
227
  signing_key:
229
228
  specification_version: 4
230
229
  summary: A Ruby wrapper for Qualtrics REST API v3.0
@@ -1,33 +0,0 @@
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