roqua-core-api 0.0.37 → 0.0.38

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: 92b680690007a76389c6f04c503089c4fbcfae58
4
- data.tar.gz: 48857763265de4e5323be1add4ef9b3dadd1670f
3
+ metadata.gz: cfa7b18ae2ac2f8b75b200310a7d51922fad8a58
4
+ data.tar.gz: d8863c44b0107988d1795588bfedd05415c53d86
5
5
  SHA512:
6
- metadata.gz: a2d0964d4a0dc01cd80bc89930ef79cc0e4af690d55abee9b2df47d977e8bf6d3d24dc4b68c301e724c3abb91827163aafc44d3e1ceac3ed6c354966093d5f5b
7
- data.tar.gz: 1c65a3b817bca3d7ac01f6a53f46f1cbe87471837e85738c65244ff1cdefff946d5cbc89b430f560d6a8720f87d03dd945124982d27f48f48d1fb8baf79f6f3e
6
+ metadata.gz: bd2a9e447bc550397b09ef3de30e754f41b27f959441ec5a398a1cb950436a3dfaca8ca019424c73513cb1215d7532104d9eb9957591a76752cd92aee6348b22
7
+ data.tar.gz: 4149166bc8a35b4a274b7d553b039e1ce0fdabe1fcc1dbe735ab69cb3bc23dd7c35f85079f49d5f5e7aadebabbaf838ea5baee61218971adee942e2724ebb027
@@ -0,0 +1,14 @@
1
+ module Roqua
2
+ module CoreApi
3
+ # @api private
4
+ class CreateDossierGroupExportSynchronously < ActiveInteraction::Base
5
+ model :session, class: Sessions::AuthSession
6
+ string :dossier_group_id
7
+
8
+ def execute
9
+ response = session.post "/dossier_groups/#{dossier_group_id}/exports"
10
+ Models::Export.new(response['dossier_group_export'])
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,15 +1,11 @@
1
- module Roqua
2
- module CoreApi
3
- module Models
4
- class Dossier
5
- def initialize(attributes)
6
- @attributes = attributes
7
- end
1
+ require 'virtus'
8
2
 
9
- def id
10
- @attributes.fetch("id")
11
- end
12
- end
13
- end
3
+ class Roqua::CoreApi::Models::Dossier < Roqua::CoreApi::Models::ActiveVirtus
4
+ attribute :id, String
5
+ attribute :external_identifier, String
6
+ attribute :people, Array[Roqua::CoreApi::Models::Person]
7
+
8
+ def persisted?
9
+ id.present?
14
10
  end
15
11
  end
@@ -0,0 +1,5 @@
1
+ require 'virtus'
2
+
3
+ class Roqua::CoreApi::Models::Export < Roqua::CoreApi::Models::ActiveVirtus
4
+ attribute :dossiers, Array[Roqua::CoreApi::Models::Dossier]
5
+ end
@@ -1,5 +1,6 @@
1
1
  require 'roqua/core_api/models/dossier_group'
2
- require 'roqua/core_api/models/dossier'
3
2
  require 'active_model'
4
3
  require 'roqua/core_api/models/active_virtus'
5
4
  require 'roqua/core_api/models/person'
5
+ require 'roqua/core_api/models/dossier'
6
+ require 'roqua/core_api/models/export'
@@ -13,24 +13,40 @@ module Roqua
13
13
 
14
14
  def get(path, timeout: default_timeout, **params)
15
15
  perform_request_or_fail do
16
- HTTParty.get(full_url_for(path), headers: headers, query: params, basic_auth: basic_auth, timeout: timeout)
16
+ HTTParty.get(full_url_for(path),
17
+ headers: headers,
18
+ query: params,
19
+ basic_auth: basic_auth,
20
+ timeout: timeout)
17
21
  end
18
22
  end
19
23
 
20
24
  def post(path, timeout: default_timeout, **params)
21
25
  perform_request_or_fail do
22
- HTTParty.post(full_url_for(path), headers: headers, body: params, basic_auth: basic_auth, timeout: timeout)
26
+ HTTParty.post(full_url_for(path),
27
+ headers: headers.merge('Content-Type' => 'application/json'),
28
+ body: params.to_json,
29
+ basic_auth: basic_auth,
30
+ timeout: timeout)
23
31
  end
24
32
  end
25
33
 
26
34
  def patch(path, timeout: default_timeout, **params)
27
35
  perform_request_or_fail do
28
- HTTParty.patch(full_url_for(path), headers: headers, body: params, basic_auth: basic_auth, timeout: timeout)
36
+ HTTParty.patch(full_url_for(path),
37
+ headers: headers.merge('Content-Type' => 'application/json'),
38
+ body: params.to_json,
39
+ basic_auth: basic_auth,
40
+ timeout: timeout)
29
41
  end
30
42
  end
31
43
 
32
44
  def delete(path, timeout: default_timeout, **params)
33
- HTTParty.delete(full_url_for(path), headers: headers, query: params, basic_auth: basic_auth, timeout: timeout)
45
+ HTTParty.delete(full_url_for(path),
46
+ headers: headers,
47
+ query: params,
48
+ basic_auth: basic_auth,
49
+ timeout: timeout)
34
50
  end
35
51
 
36
52
  private
@@ -56,6 +72,7 @@ module Roqua
56
72
  end
57
73
 
58
74
  def headers
75
+ {}
59
76
  end
60
77
 
61
78
  def basic_auth
@@ -0,0 +1,22 @@
1
+ module Roqua
2
+ module CoreApi
3
+ # @api private
4
+ class UpdateDossier < Base
5
+ model :session, class: Sessions::AuthSession
6
+ model :dossier, class: Models::Dossier
7
+
8
+ # Saves the dossier attributes to server.
9
+ # Returns true on success, false on validation errors.
10
+ # Raises on other errors.
11
+ def execute
12
+ response = session.patch "/dossiers/#{dossier.id}", dossier: dossier.serializable_hash
13
+ if response.code == 422
14
+ errors_to_object(response, dossier)
15
+ false
16
+ else
17
+ true
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module CoreApi
3
- VERSION = '0.0.37'
3
+ VERSION = '0.0.38'
4
4
  end
5
5
  end
@@ -15,6 +15,8 @@ require 'roqua/core_api/send_invite_email'
15
15
  require 'roqua/core_api/people'
16
16
  require 'roqua/core_api/person'
17
17
  require 'roqua/core_api/update_person'
18
+ require 'roqua/core_api/update_dossier'
19
+ require 'roqua/core_api/create_dossier_group_export_synchronously'
18
20
 
19
21
  module Roqua
20
22
  module CoreApi
@@ -0,0 +1,6 @@
1
+ Fabricator(:dossier, from: Roqua::CoreApi::Models::Dossier) do
2
+ initialize_with do
3
+ Roqua::CoreApi::Models::Dossier.new id: 'dossier-id',
4
+ external_identifier: 'external-dossier-identifier'
5
+ end
6
+ end
@@ -38,6 +38,6 @@ describe Dossiers do
38
38
  it 'returns the results as an array of structs' do
39
39
  expect(session).to receive(:get).with('/dossiers', {}).and_return(response)
40
40
  dossiers = Dossiers.run!(session: session)
41
- expect(dossiers.force[0].firstname).to eq 'john'
41
+ expect(dossiers.first.firstname).to eq 'john'
42
42
  end
43
43
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ module Roqua
4
+ module CoreApi
5
+ module Models
6
+ describe Dossier do
7
+ let(:valid_dossier) { Dossier.new }
8
+
9
+ describe '#new' do
10
+ subject { Dossier.new external_identifier: 'ext_id' }
11
+ it 'accepts a hash of attributes' do
12
+ expect(subject.external_identifier).to eq 'ext_id'
13
+ end
14
+ end
15
+
16
+ describe '#assign_attributes' do
17
+ subject { Dossier.new external_identifier: 'ext_id' }
18
+ it 'allows assigning of attributes' do
19
+ subject.assign_attributes(external_identifier: 'external_identifier')
20
+ expect(subject.external_identifier).to eq 'external_identifier'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe UpdateDossier do
4
+ let(:session) { Fabricate :oauth_session }
5
+ let(:dossier) { Fabricate :dossier }
6
+ let(:response) { double }
7
+
8
+ before do
9
+ allow(response).to receive(:code) { 200 }
10
+ expect(session).to receive(:patch).with("/dossiers/#{dossier.id}",
11
+ dossier: dossier.serializable_hash)
12
+ .and_return(response)
13
+ end
14
+
15
+ describe 'performs a patch on the /dossiers api path' do
16
+ before do
17
+ @result = UpdateDossier.run!(session: session,
18
+ dossier: dossier)
19
+ end
20
+
21
+ it 'returns true when the call was correct' do
22
+ expect(@result).to be_truthy
23
+ end
24
+
25
+ it 'should not have any errors' do
26
+ expect(dossier.errors).to be_empty
27
+ end
28
+ end
29
+
30
+ describe 'returns false when the call was incorrect' do
31
+ let(:error) { { 'id' => ['empty'] } }
32
+ before do
33
+ allow(response).to receive(:[]).with('errors').and_return(error)
34
+
35
+ expect(response).to receive(:code).and_return(422)
36
+ @result = UpdateDossier.run!(session: session,
37
+ dossier: dossier)
38
+ end
39
+
40
+ it 'should return false' do
41
+ expect(@result).to be_falsey
42
+ end
43
+
44
+ it 'should add the errors to the dossier' do
45
+ expect(dossier.errors).to_not be_empty
46
+ expect(dossier.errors['id'][0]).to match(error['id'][0])
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-core-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.37
4
+ version: 0.0.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -188,6 +188,7 @@ files:
188
188
  - lib/roqua/core_api/base.rb
189
189
  - lib/roqua/core_api/create_dossier.rb
190
190
  - lib/roqua/core_api/create_dossier_group.rb
191
+ - lib/roqua/core_api/create_dossier_group_export_synchronously.rb
191
192
  - lib/roqua/core_api/create_professional.rb
192
193
  - lib/roqua/core_api/delete_dossier_group_right.rb
193
194
  - lib/roqua/core_api/dossier_groups.rb
@@ -197,6 +198,7 @@ files:
197
198
  - lib/roqua/core_api/models/active_virtus.rb
198
199
  - lib/roqua/core_api/models/dossier.rb
199
200
  - lib/roqua/core_api/models/dossier_group.rb
201
+ - lib/roqua/core_api/models/export.rb
200
202
  - lib/roqua/core_api/models/person.rb
201
203
  - lib/roqua/core_api/people.rb
202
204
  - lib/roqua/core_api/person.rb
@@ -206,6 +208,7 @@ files:
206
208
  - lib/roqua/core_api/sessions/auth_session.rb
207
209
  - lib/roqua/core_api/sessions/basic_auth_session.rb
208
210
  - lib/roqua/core_api/sessions/oauth_session.rb
211
+ - lib/roqua/core_api/update_dossier.rb
209
212
  - lib/roqua/core_api/update_person.rb
210
213
  - lib/roqua/core_api/version.rb
211
214
  - lib/roqua/omniauth/rails_initializer.rb
@@ -213,17 +216,20 @@ files:
213
216
  - spec/core_api_spec.rb
214
217
  - spec/fabricators/auth_session_fabricator.rb
215
218
  - spec/fabricators/basic_auth_session_fabricator.rb
219
+ - spec/fabricators/dossier_fabricator.rb
216
220
  - spec/fabricators/oauth_session_fabricator.rb
217
221
  - spec/lib/roqua/core_api/create_dossier_group_spec.rb
218
222
  - spec/lib/roqua/core_api/create_dossier_spec.rb
219
223
  - spec/lib/roqua/core_api/dossiers_spec.rb
220
224
  - spec/lib/roqua/core_api/models/active_virtus_spec.rb
225
+ - spec/lib/roqua/core_api/models/dossier_spec.rb
221
226
  - spec/lib/roqua/core_api/models/person_spec.rb
222
227
  - spec/lib/roqua/core_api/send_email_to_spec.rb
223
228
  - spec/lib/roqua/core_api/send_invite_email_spec.rb
224
229
  - spec/lib/roqua/core_api/sessions/auth_session_spec.rb
225
230
  - spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
226
231
  - spec/lib/roqua/core_api/sessions/oauth_session_spec.rb
232
+ - spec/lib/roqua/core_api/update_dossier_spec.rb
227
233
  - spec/spec_helper.rb
228
234
  homepage: https://github.com/roqua/core/blob/master/core_api/README.markdown
229
235
  licenses:
@@ -245,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
251
  version: '0'
246
252
  requirements: []
247
253
  rubyforge_project:
248
- rubygems_version: 2.3.0
254
+ rubygems_version: 2.2.2
249
255
  signing_key:
250
256
  specification_version: 4
251
257
  summary: API wrapper gem around Core's API
@@ -253,16 +259,19 @@ test_files:
253
259
  - spec/core_api_spec.rb
254
260
  - spec/fabricators/auth_session_fabricator.rb
255
261
  - spec/fabricators/basic_auth_session_fabricator.rb
262
+ - spec/fabricators/dossier_fabricator.rb
256
263
  - spec/fabricators/oauth_session_fabricator.rb
257
264
  - spec/lib/roqua/core_api/create_dossier_group_spec.rb
258
265
  - spec/lib/roqua/core_api/create_dossier_spec.rb
259
266
  - spec/lib/roqua/core_api/dossiers_spec.rb
260
267
  - spec/lib/roqua/core_api/models/active_virtus_spec.rb
268
+ - spec/lib/roqua/core_api/models/dossier_spec.rb
261
269
  - spec/lib/roqua/core_api/models/person_spec.rb
262
270
  - spec/lib/roqua/core_api/send_email_to_spec.rb
263
271
  - spec/lib/roqua/core_api/send_invite_email_spec.rb
264
272
  - spec/lib/roqua/core_api/sessions/auth_session_spec.rb
265
273
  - spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
266
274
  - spec/lib/roqua/core_api/sessions/oauth_session_spec.rb
275
+ - spec/lib/roqua/core_api/update_dossier_spec.rb
267
276
  - spec/spec_helper.rb
268
277
  has_rdoc: