roqua-rom-api 0.1.4 → 0.1.5

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: d487e0e9755a189bd7deb54b98c048ae6a57bae6
4
- data.tar.gz: 49e4bade533834bfb827a51a0a282e3569e99892
3
+ metadata.gz: da682d985d0f1bb2d2e18a3102d89b011e0afb75
4
+ data.tar.gz: 11a6c235df4e6e994b4d6eb3c82907fa22c1db1b
5
5
  SHA512:
6
- metadata.gz: cbe001619d66bcbca0ac093b80a1985879f73c0344127e3125e59d8523aa37fe65b11f903968873ce8b5696871e105e0c09f4fe7f29cc98be4a9591e71c2df47
7
- data.tar.gz: 5a640575f62476a13e25a7d460772b1941538f24420df25f7ac316b215af3f6c7bae3fd63c44559d92526e2d89d761f3480775377bdb7ebe01d692ba99d58752
6
+ metadata.gz: 9017fb16837df479fa72b5f9e49b27b04915fd161d1246a46c9bf5601145c550992023d7453d918f0208726cf1dff3e25e64944c652744f75047bc28f70a4bfe
7
+ data.tar.gz: 847a62e1c49da738586b52459656055a24d996e20ae8dc6ba434f3bd89fd1ded413e547689e321eead4ee19b2f291cf7253f26badb2ea7c19e5560b32cce1ae8
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.1.5 / 2014-06-10
2
+
3
+ * Added CreateFillOutRequest
4
+
1
5
  ### 0.1.4 / 2014-05-26
2
6
 
3
7
  * add answers and outcome to rom responses api
@@ -0,0 +1,32 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class CreateFillOutRequest < Endpoint
5
+ string :dossier_id
6
+ array :questionnaire_keys, default: [] do string end
7
+ string :respondent_type, default: nil
8
+ string :callback_url
9
+ array :reminders, default: []
10
+ time :open_from, default: nil, allow_nil: true
11
+ time :open_till, default: nil, allow_nil: true
12
+
13
+ def execute
14
+ validate_response_for do
15
+ RomApi.basic_auth_session.post("/dossiers/#{dossier_id}/fill_out_requests", fill_out_request: {
16
+ questionnaire_keys: questionnaire_keys,
17
+ respondent_type: respondent_type,
18
+ callback_url: callback_url,
19
+ reminders: reminders,
20
+ open_from: open_from && open_from.to_i,
21
+ open_till: open_till && open_till.to_i
22
+ }.keep_if { |k, v| v.present? } )
23
+
24
+ end
25
+ end
26
+
27
+ def response_to_result(response)
28
+ response['id']
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module RomApi
3
- VERSION = '0.1.4'
3
+ VERSION = '0.1.5'
4
4
  end
5
5
  end
data/lib/roqua/rom_api.rb CHANGED
@@ -6,6 +6,7 @@ require 'roqua/rom_api/endpoint'
6
6
  require 'roqua/rom_api/list_protocol_subscriptions'
7
7
  require 'roqua/rom_api/list_responses'
8
8
  require 'roqua/rom_api/start_fill_out_session'
9
+ require 'roqua/rom_api/create_fill_out_request'
9
10
  require 'roqua/rom_api/start_protocol_subscription'
10
11
  require 'roqua/rom_api/stop_protocol_subscription'
11
12
 
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe CreateFillOutRequest do
4
+ let(:options) { {dossier_id: 'some_dossier_id',
5
+ questionnaire_keys: ['qkey1', 'qkey2'],
6
+ respondent_type: 'patient_version',
7
+ callback_url: 'http://callback.url',
8
+ reminders: [1000, 2000],
9
+ open_from: Time.now,
10
+ open_till: Time.now + 100_000} }
11
+ let(:session) { Sessions::BasicAuthSession.new }
12
+ let(:response) { double('response', :[] => nil) }
13
+ before do
14
+ allow(Sessions::BasicAuthSession).to receive(:new).and_return session
15
+ allow(session).to receive(:post).and_return response
16
+ end
17
+
18
+ it 'does a post to the rom fill_out_sessions api' do
19
+ expect(session).to receive(:post).with("/dossiers/#{options[:dossier_id]}/fill_out_requests", fill_out_request: {
20
+ questionnaire_keys: options[:questionnaire_keys],
21
+ respondent_type: options[:respondent_type],
22
+ callback_url: options[:callback_url],
23
+ reminders: options[:reminders],
24
+ open_from: options[:open_from].to_i,
25
+ open_till: options[:open_till].to_i})
26
+ CreateFillOutRequest.run!(options)
27
+ end
28
+
29
+ it 'returns the id of the created fill_out_request' do
30
+ allow(session).to receive(:post).and_return 'id' => 'fill_out_request_id'
31
+ outcome = CreateFillOutRequest.run(options)
32
+ expect(outcome.result).to eq('fill_out_request_id')
33
+ end
34
+
35
+ it 'accepts explicit nil values' do
36
+ options[:open_from] = nil
37
+ options[:open_till] = nil
38
+ options[:reminders] = nil
39
+ expect(session).to receive(:post) do |path, args|
40
+ expect(args[:fill_out_request][:open_from]).to eq nil
41
+ expect(args[:fill_out_request][:open_till]).to eq nil
42
+ expect(args[:fill_out_request][:reminders]).to eq nil
43
+ {'id' => 'fill_out_request_id'}
44
+ end
45
+ CreateFillOutRequest.run!(options)
46
+ end
47
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-rom-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Esposito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-27 00:00:00.000000000 Z
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -141,6 +141,7 @@ files:
141
141
  - lib/i18n/i18n.rb
142
142
  - lib/roqua-rom-api.rb
143
143
  - lib/roqua/rom_api.rb
144
+ - lib/roqua/rom_api/create_fill_out_request.rb
144
145
  - lib/roqua/rom_api/endpoint.rb
145
146
  - lib/roqua/rom_api/list_protocol_subscriptions.rb
146
147
  - lib/roqua/rom_api/list_responses.rb
@@ -155,6 +156,7 @@ files:
155
156
  - lib/roqua/rom_api/version.rb
156
157
  - roqua_rom_api.gemspec
157
158
  - spec/fabricators/basic_auth_session_fabricator.rb
159
+ - spec/lib/roqua/rom_api/create_fill_out_request_spec.rb
158
160
  - spec/lib/roqua/rom_api/endpoint_spec.rb
159
161
  - spec/lib/roqua/rom_api/list_protocol_subscriptions_spec.rb
160
162
  - spec/lib/roqua/rom_api/list_responses_spec.rb
@@ -186,12 +188,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
188
  version: '0'
187
189
  requirements: []
188
190
  rubyforge_project:
189
- rubygems_version: 2.2.1
191
+ rubygems_version: 2.2.0
190
192
  signing_key:
191
193
  specification_version: 4
192
194
  summary: API wrapper gem around RoQua's ROM API
193
195
  test_files:
194
196
  - spec/fabricators/basic_auth_session_fabricator.rb
197
+ - spec/lib/roqua/rom_api/create_fill_out_request_spec.rb
195
198
  - spec/lib/roqua/rom_api/endpoint_spec.rb
196
199
  - spec/lib/roqua/rom_api/list_protocol_subscriptions_spec.rb
197
200
  - spec/lib/roqua/rom_api/list_responses_spec.rb