qualtrics_api 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe QualtricsAPI::EventSubscriptionCollection do
4
+ subject { described_class.new }
5
+
6
+ describe "can find subscriptions" do
7
+ it "returns the subscription if exists" do
8
+ VCR.use_cassette("event_subscription_find") do
9
+ subscription_id = "SUB_6XMPw9UoySyGNyl"
10
+ result = subject.find(subscription_id)
11
+ expect(result).to be_a QualtricsAPI::EventSubscription
12
+ expect(result.id).to eq subscription_id
13
+ end
14
+ end
15
+
16
+ it "raise an error if not exists" do
17
+ VCR.use_cassette("event_subscription_find_fail") do
18
+ subscription_id = "pewpewpewpew"
19
+ expect {
20
+ subject.find(subscription_id)
21
+ }.to raise_error(QualtricsAPI::NotFoundError)
22
+ end
23
+ end
24
+ end
25
+
26
+ describe "#create" do
27
+ it "creates subscription with publication url and topics" do
28
+ VCR.use_cassette("event_subscription_create") do
29
+ result = subject.create('https://some.random.url', 'controlpanel.activateSurvey')
30
+ expect(result).to be_a QualtricsAPI::EventSubscription
31
+ expect(result.id).to_not be_nil
32
+ expect(result.publication_url).to eq 'https://some.random.url'
33
+ end
34
+ end
35
+
36
+ describe "#create_completed_response_subscription" do
37
+ it "creates a subscription to the completedResponse event of the survey id specified" do
38
+ VCR.use_cassette("event_subscription_create_response_sub") do
39
+ survey_id = 'SV_SOME_SURVEY_ID'
40
+ url = 'https://some.url.fake'
41
+ result = subject.create_completed_response_subscription(url, survey_id)
42
+ expect(result).to be_a QualtricsAPI::EventSubscription
43
+ expect(result.id).to_not be_nil
44
+ expect(result.publication_url).to eq url
45
+ expect(result.topics).to eq "surveyengine.completedResponse.#{survey_id}"
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#create_completed_response_subscription" do
51
+ it "creates a subscription to the partialResponse event of the survey id specified" do
52
+ VCR.use_cassette("event_subscription_create_partial_response_sub") do
53
+ survey_id = 'SV_ANOTHER_SURVEY'
54
+ url = 'https://request.url.fake'
55
+ result = subject.create_partial_response_subscription(url, survey_id)
56
+ expect(result).to be_a QualtricsAPI::EventSubscription
57
+ expect(result.id).to_not be_nil
58
+ expect(result.publication_url).to eq url
59
+ expect(result.topics).to eq "surveyengine.partialResponse.#{survey_id}"
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ describe "#delete" do
66
+ it "deletes the subscription specified" do
67
+ VCR.use_cassette("event_subscription_delete_one") do
68
+ sub_id = 'SUB_5pPHcNfCaiADoFf'
69
+ subject.delete(sub_id)
70
+ #QualtricsAPI.event_subscriptions.delete(sub_id)
71
+ expect {
72
+ subject.find(sub_id)
73
+ #QualtricsAPI.event_subscriptions.find(sub_id)
74
+ }.to raise_error(QualtricsAPI::NotFoundError)
75
+ end
76
+ end
77
+ end
78
+
79
+ describe "#delete_all" do
80
+ it "deletes all subscriptions" do
81
+ VCR.use_cassette("event_subscription_delete_all") do
82
+ expect(subject.all.size).to eq 3
83
+ subject.delete_all
84
+ expect(subject.all.size).to eq 0
85
+ end
86
+ end
87
+ end
88
+
89
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe QualtricsAPI::EventSubscription do
4
+ let(:event_subscription) do
5
+ {
6
+ "id" => "SUB_012345678912345",
7
+ "scope" => "exampleorganizationid",
8
+ "topics" => "controlpanel.activateSurvey",
9
+ "publicationUrl" => "https://www.example.com/pub",
10
+ "encrypted" => false,
11
+ "successfulCalls" => 3
12
+ }
13
+ end
14
+
15
+ subject { described_class.new event_subscription }
16
+
17
+ it "has an id" do
18
+ expect(subject.id).to eq "SUB_012345678912345"
19
+ end
20
+
21
+ it "has scope" do
22
+ expect(subject.scope).to eq "exampleorganizationid"
23
+ end
24
+
25
+ it "has topics" do
26
+ expect(subject.topics).to eq "controlpanel.activateSurvey"
27
+ end
28
+
29
+ it "has publicationUrl" do
30
+ expect(subject.publication_url).to eq "https://www.example.com/pub"
31
+ end
32
+
33
+ it "shows if encrypted" do
34
+ expect(subject.encrypted?).to be false
35
+ end
36
+
37
+ it "shows number of successful calls" do
38
+ expect(subject.successful_calls).to eq 3
39
+ end
40
+
41
+ describe "#delete" do
42
+ it "deletes the subscription" do
43
+ VCR.use_cassette("event_subscription_delete") do
44
+ sub_id = 'SUB_2i7QDi3PXEK4eqx'
45
+ subscription = QualtricsAPI.event_subscriptions.find(sub_id)
46
+ subscription.delete
47
+ expect {
48
+ QualtricsAPI.event_subscriptions.find(sub_id)
49
+ }.to raise_error(QualtricsAPI::NotFoundError)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -5,8 +5,8 @@ describe QualtricsAPI do
5
5
  subject { QualtricsAPI }
6
6
 
7
7
  it 'two clients have different connection' do
8
- client_1 = QualtricsAPI::Client.new('some_id')
9
- client_2 = QualtricsAPI::Client.new('other_id')
8
+ client_1 = QualtricsAPI::Client.new('some_id', 'co1')
9
+ client_2 = QualtricsAPI::Client.new('other_id', 'co2')
10
10
  expect(client_1.connection).not_to eq(client_2.connection)
11
11
  end
12
12
 
@@ -15,7 +15,7 @@ describe QualtricsAPI do
15
15
  end
16
16
 
17
17
  it 'does not reuse connection with client' do
18
- client = QualtricsAPI::Client.new('some_id')
18
+ client = QualtricsAPI::Client.new('some_id', 'co1')
19
19
  expect(client.connection).not_to eq(QualtricsAPI.connection)
20
20
  end
21
21
 
@@ -28,7 +28,7 @@ describe QualtricsAPI do
28
28
  end
29
29
 
30
30
  context 'with client' do
31
- let(:client) { QualtricsAPI::Client.new(TEST_API_TOKEN) }
31
+ let(:client) { QualtricsAPI::Client.new(TEST_API_TOKEN, 'co1') }
32
32
  let(:members) do
33
33
  VCR.use_cassette('panel_member_collection_create_success') do
34
34
  client.panels.find('ML_bC2c5xBz1DxyOYB').members
@@ -44,7 +44,7 @@ describe QualtricsAPI do
44
44
  end
45
45
 
46
46
  context 'with different client' do
47
- let(:client_2) { QualtricsAPI::Client.new(TEST_API_TOKEN) }
47
+ let(:client_2) { QualtricsAPI::Client.new(TEST_API_TOKEN, 'co1') }
48
48
  let(:members_2) do
49
49
  VCR.use_cassette('panel_member_collection_create_success') do
50
50
  client_2.panels.find('ML_bC2c5xBz1DxyOYB').members
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.12
4
+ version: 0.0.13
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: 2016-05-10 00:00:00.000000000 Z
13
+ date: 2017-12-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 0.9.1
21
+ version: 0.13.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 0.9.1
28
+ version: 0.13.1
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: faraday_middleware
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: 0.9.1
35
+ version: 0.12.2
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: 0.9.1
42
+ version: 0.12.2
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: virtus
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -60,56 +60,56 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '1.11'
63
+ version: '1.16'
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.11'
70
+ version: '1.16'
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: '11.1'
77
+ version: '12.3'
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: '11.1'
84
+ version: '12.3'
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.4'
91
+ version: '3.7'
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.4'
98
+ version: '3.7'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: vcr
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '2.9'
105
+ version: '3.0'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '2.9'
112
+ version: '3.0'
113
113
  description: |-
114
114
  A Ruby wrapper for Qualtrics REST API version 3.0.
115
115
  See https://co1.qualtrics.com/APIDocs/ for API documents.
@@ -129,6 +129,14 @@ files:
129
129
  - LICENSE.txt
130
130
  - README.md
131
131
  - Rakefile
132
+ - fixtures/vcr_cassettes/event_subscription_create.yml
133
+ - fixtures/vcr_cassettes/event_subscription_create_partial_response_sub.yml
134
+ - fixtures/vcr_cassettes/event_subscription_create_response_sub.yml
135
+ - fixtures/vcr_cassettes/event_subscription_delete.yml
136
+ - fixtures/vcr_cassettes/event_subscription_delete_all.yml
137
+ - fixtures/vcr_cassettes/event_subscription_delete_one.yml
138
+ - fixtures/vcr_cassettes/event_subscription_find.yml
139
+ - fixtures/vcr_cassettes/event_subscription_find_fail.yml
132
140
  - fixtures/vcr_cassettes/panel_collection_fetch_fail.yml
133
141
  - fixtures/vcr_cassettes/panel_collection_fetch_success.yml
134
142
  - fixtures/vcr_cassettes/panel_find.yml
@@ -148,6 +156,8 @@ files:
148
156
  - lib/qualtrics_api/client.rb
149
157
  - lib/qualtrics_api/configurable.rb
150
158
  - lib/qualtrics_api/connectable.rb
159
+ - lib/qualtrics_api/event_subscription.rb
160
+ - lib/qualtrics_api/event_subscription_collection.rb
151
161
  - lib/qualtrics_api/extensions/serializable_collection.rb
152
162
  - lib/qualtrics_api/extensions/serializable_model.rb
153
163
  - lib/qualtrics_api/panel.rb
@@ -161,10 +171,11 @@ files:
161
171
  - lib/qualtrics_api/services/response_export_service.rb
162
172
  - lib/qualtrics_api/survey.rb
163
173
  - lib/qualtrics_api/survey_collection.rb
164
- - lib/qualtrics_api/url.rb
165
174
  - lib/qualtrics_api/version.rb
166
175
  - qualtrics_api.gemspec
167
176
  - spec/lib/client_spec.rb
177
+ - spec/lib/event_subscription_collection_spec.rb
178
+ - spec/lib/event_subscription_spec.rb
168
179
  - spec/lib/panel_collection_spec.rb
169
180
  - spec/lib/panel_import_spec.rb
170
181
  - spec/lib/panel_member_collection_spec.rb
@@ -189,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
200
  requirements:
190
201
  - - ">="
191
202
  - !ruby/object:Gem::Version
192
- version: 2.1.0
203
+ version: 2.3.0
193
204
  required_rubygems_version: !ruby/object:Gem::Requirement
194
205
  requirements:
195
206
  - - ">="
@@ -197,12 +208,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
208
  version: '0'
198
209
  requirements: []
199
210
  rubyforge_project:
200
- rubygems_version: 2.5.1
211
+ rubygems_version: 2.7.3
201
212
  signing_key:
202
213
  specification_version: 4
203
214
  summary: A Ruby wrapper for Qualtrics REST API v3.0
204
215
  test_files:
205
216
  - spec/lib/client_spec.rb
217
+ - spec/lib/event_subscription_collection_spec.rb
218
+ - spec/lib/event_subscription_spec.rb
206
219
  - spec/lib/panel_collection_spec.rb
207
220
  - spec/lib/panel_import_spec.rb
208
221
  - spec/lib/panel_member_collection_spec.rb
@@ -1,3 +0,0 @@
1
- module QualtricsAPI
2
- URL = "https://co1.qualtrics.com:443/API/v3/"
3
- end