roqua-rom-api 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c0f791ffb54619a1c58c609cdba40d5bd3d7398
4
- data.tar.gz: e33f8f99892cbda235533616f39f2fb79ac08bbf
3
+ metadata.gz: 9b191aee54049eed911532caa0bd2d3d16459626
4
+ data.tar.gz: f5b755d2759a8920984a8f36dca1c0136f721855
5
5
  SHA512:
6
- metadata.gz: e7751a11b6a9b5baa9a9cbeee9c7d5cf43d75447f43900654f3e77e573c531d6097117230e769011634c9dbef4ba217ea02cb9d6448d96d045740dc6a7cd7f91
7
- data.tar.gz: 5c7cc83c86d705afe41537b6b32d5a758df1150e3d85bbfb0d04e77f1b2f0cb47f84d5baf3ce1832626fffcbbeb64d004835cdb35b0064a08457ac3fe1339e3b
6
+ metadata.gz: f599a248e80d020849a6f2771e13116110895d8ec912daac8a94d8ec7b5271974013fed867b7d3932717580f8b6d0fea725ea0e02e99dd0c514e0799ce0a0a2c
7
+ data.tar.gz: 14539ad8b98495ec7bdeb86a8084dd08dcd33df26be5af254643a2ef4b04e83657263a1774625954a7fb68b0a931bbf1c1be61c5f91c8040172dd3da99d39306
data/ChangeLog.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
 
4
4
 
5
+ ### 0.1.12 / 2014-10-28
6
+
7
+ * Add started_at timestamp to response create and update api endpoint
8
+
5
9
  ### 0.1.11 / 2014-10-20
6
10
 
7
11
  * Add textvars parameter to protocol subscriptions
@@ -5,7 +5,7 @@ module Roqua
5
5
  string :dossier_id
6
6
  array :questionnaire_keys, default: [] { string }
7
7
  string :respondent_type, default: nil
8
- string :callback_url
8
+ string :callback_url, default: nil
9
9
  array :reminders, default: []
10
10
  time :open_from, default: nil, allow_nil: true
11
11
  time :open_till, default: nil, allow_nil: true
@@ -26,7 +26,7 @@ module Roqua
26
26
  end
27
27
 
28
28
  def response_to_result(response)
29
- response['id']
29
+ Models::FillOutRequest.new(response)
30
30
  end
31
31
  end
32
32
  end
@@ -1,2 +1,3 @@
1
1
  require 'roqua/rom_api/models/response'
2
+ require 'roqua/rom_api/models/fill_out_request'
2
3
  require 'roqua/rom_api/models/protocol_subscription'
@@ -0,0 +1,15 @@
1
+ require 'virtus'
2
+
3
+ module Roqua
4
+ module RomApi
5
+ module Models
6
+ class FillOutRequest
7
+ include Virtus.model
8
+
9
+ attribute :id, Integer
10
+ attribute :respondent_type, String
11
+ attribute :completing_url, String
12
+ end
13
+ end
14
+ end
15
+ end
@@ -11,6 +11,7 @@ module Roqua
11
11
  attribute :questionnaire_key, String
12
12
  attribute :open_from, DateTime
13
13
  attribute :open_till, DateTime
14
+ attribute :started_at, DateTime
14
15
  attribute :completing_url, String
15
16
  attribute :completer_type, String
16
17
  attribute :completed_at, DateTime
@@ -5,15 +5,17 @@ module Roqua
5
5
  string :questionnaire_key
6
6
  string :dossier_id
7
7
  integer :id
8
- hash :answer_data, strip: false
9
- time :filled_out_at, default: nil
8
+ hash :answer_data, strip: false
9
+ time :filled_out_at, default: nil
10
+ time :started_at, default: nil
10
11
 
11
12
  def execute
12
13
  validate_response_for do
13
14
  RomApi.basic_auth_session.patch "/dossiers/#{dossier_id}/responses/#{id}",
14
15
  questionnaire_key: questionnaire_key,
15
16
  answer_data: answer_data,
16
- filled_out_at: (filled_out_at.to_i if filled_out_at)
17
+ filled_out_at: (filled_out_at.to_i if filled_out_at),
18
+ started_at: (started_at.to_i if started_at)
17
19
  end
18
20
  end
19
21
 
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module RomApi
3
- VERSION = '0.1.11'
3
+ VERSION = '0.1.12'
4
4
  end
5
5
  end
@@ -33,10 +33,10 @@ describe CreateFillOutRequest do
33
33
  CreateFillOutRequest.run!(options)
34
34
  end
35
35
 
36
- it 'returns the id of the created fill_out_request' do
36
+ it 'returns a FillOutRequest' do
37
37
  response['id'] = 'fill_out_request_id'
38
38
  outcome = CreateFillOutRequest.run(options)
39
- expect(outcome.result).to eq('fill_out_request_id')
39
+ expect(outcome.result.id).to eq('fill_out_request_id')
40
40
  end
41
41
 
42
42
  it 'accepts explicit nil values' do
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe FillOutRequest do
4
+ let(:response_body) do
5
+ {'id' => 123,
6
+ 'respondent_type' => 'patient_version',
7
+ 'completing_url' => 'http://roqua.dev/client/session/new?token=26aee9a4'
8
+ }
9
+ end
10
+
11
+ it 'assigns fields to attr_accessors' do
12
+ response = FillOutRequest.new response_body
13
+ expect(response.id).to eq 123
14
+ expect(response.respondent_type).to eq 'patient_version'
15
+ expect(response.completing_url).to eq 'http://roqua.dev/client/session/new?token=26aee9a4'
16
+ end
17
+ end
@@ -6,6 +6,7 @@ describe Response do
6
6
  'questionnaire_key' => 'rs12',
7
7
  'open_from' => '2014-02-19T14:15:49+01:00',
8
8
  'open_till' => '2014-02-20T14:15:49+01:00',
9
+ 'started_at' => '2014-02-19T15:15:49+01:00',
9
10
  'completer_type' => 'patient',
10
11
  'completed_at' => nil,
11
12
  'status' => 'open',
@@ -20,6 +21,7 @@ describe Response do
20
21
  expect(response.questionnaire_key).to eq 'rs12'
21
22
  expect(response.open_from).to eq DateTime.parse('2014-02-19T14:15:49+01:00')
22
23
  expect(response.open_till).to eq DateTime.parse('2014-02-20T14:15:49+01:00')
24
+ expect(response.started_at).to eq DateTime.parse('2014-02-19T15:15:49+01:00')
23
25
  expect(response.completed_at).to eq nil
24
26
  expect(response.completer_type).to eq 'patient'
25
27
  expect(response.status).to eq 'open'
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  describe UpdateResponse do
4
4
  let(:session) { Sessions::BasicAuthSession.new }
5
5
  let(:response) { httparty_response(questionnaire_name: 'Some Questionnaire') }
6
+ let(:started_at) { 10.minutes.ago}
6
7
  before do
7
8
  allow(Sessions::BasicAuthSession).to receive(:new).and_return session
8
9
  allow(session).to receive(:patch).and_return response
@@ -13,12 +14,14 @@ describe UpdateResponse do
13
14
  expect(session).to receive(:patch).with '/dossiers/some_dossier_id/responses/230',
14
15
  questionnaire_key: 'some_questionnaire_key',
15
16
  answer_data: {some: 'answer_data'},
16
- filled_out_at: filled_out_at.to_i
17
+ filled_out_at: filled_out_at.to_i,
18
+ started_at: started_at.to_i
17
19
  UpdateResponse.run! dossier_id: 'some_dossier_id',
18
20
  questionnaire_key: 'some_questionnaire_key',
19
21
  id: 230,
20
22
  answer_data: {some: 'answer_data'},
21
- filled_out_at: filled_out_at
23
+ filled_out_at: filled_out_at,
24
+ started_at: started_at
22
25
  end
23
26
 
24
27
  it 'returns a response object' do
@@ -26,6 +29,7 @@ describe UpdateResponse do
26
29
  questionnaire_key: 'some_questionnaire_key',
27
30
  answer_data: {some: 'answer_data'},
28
31
  respondent: 'patient',
32
+ started_at: started_at,
29
33
  id: 230
30
34
  expect(response).to be_a(Response)
31
35
  expect(response.questionnaire_name).to eq('Some Questionnaire')
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rspec'
2
2
  require 'fabrication'
3
3
  require 'roqua-rom-api'
4
+ require 'active_support/core_ext/numeric/time'
4
5
  include Roqua::RomApi
5
6
  include Roqua::RomApi::Sessions
6
7
  include Roqua::RomApi::Models
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.11
4
+ version: 0.1.12
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-10-20 00:00:00.000000000 Z
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -147,6 +147,7 @@ files:
147
147
  - lib/roqua/rom_api/list_protocol_subscriptions.rb
148
148
  - lib/roqua/rom_api/list_responses.rb
149
149
  - lib/roqua/rom_api/models.rb
150
+ - lib/roqua/rom_api/models/fill_out_request.rb
150
151
  - lib/roqua/rom_api/models/protocol_subscription.rb
151
152
  - lib/roqua/rom_api/models/response.rb
152
153
  - lib/roqua/rom_api/report_calculations.rb
@@ -164,6 +165,7 @@ files:
164
165
  - spec/lib/roqua/rom_api/endpoint_spec.rb
165
166
  - spec/lib/roqua/rom_api/list_protocol_subscriptions_spec.rb
166
167
  - spec/lib/roqua/rom_api/list_responses_spec.rb
168
+ - spec/lib/roqua/rom_api/models/fill_out_request_spec.rb
167
169
  - spec/lib/roqua/rom_api/models/protocol_subscription_spec.rb
168
170
  - spec/lib/roqua/rom_api/models/response_spec.rb
169
171
  - spec/lib/roqua/rom_api/report_calculations_spec.rb
@@ -207,6 +209,7 @@ test_files:
207
209
  - spec/lib/roqua/rom_api/endpoint_spec.rb
208
210
  - spec/lib/roqua/rom_api/list_protocol_subscriptions_spec.rb
209
211
  - spec/lib/roqua/rom_api/list_responses_spec.rb
212
+ - spec/lib/roqua/rom_api/models/fill_out_request_spec.rb
210
213
  - spec/lib/roqua/rom_api/models/protocol_subscription_spec.rb
211
214
  - spec/lib/roqua/rom_api/models/response_spec.rb
212
215
  - spec/lib/roqua/rom_api/report_calculations_spec.rb