roqua-core-api 0.0.29 → 0.0.30

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: 70bf516ce8a737fd14c3cc0aed3a92996d2eca4b
4
- data.tar.gz: a6a4b41dc4710c314455523fa27d458087de3cd5
3
+ metadata.gz: a2762926c89271ebf2621c18b6e70751d5a1bf12
4
+ data.tar.gz: 99fdc324bb06fa148994b54cdd5df39a8c4bbc48
5
5
  SHA512:
6
- metadata.gz: de559891d6fb4784894cd00917a5a2cbd37eb342dfb16a0662ce21e7fadd4be151b3c7471cb57731f04d12c4c37ee6c1510d873b0b873286915a48a679a1bb6f
7
- data.tar.gz: 517d546f471b74a509dc8ca1ff2eb23ce58ed2a291d87f2b64051cce08946928543c3c79220ad2f39181cad0d4134b56fb241d4b0e96c5d46a57a73de128cb91
6
+ metadata.gz: 294370405ee1b0dd66096a9b58d9345e29619d29712680e8d3dc0d3cd39e2301344247e63192969a6af9ca4228970672d78c61058c206313e91cb46f2b4032c6
7
+ data.tar.gz: daa1d7cb0070459f4950743147a7d9084604b730fcbe7ee8d9b5b584af61cd317a3b5b3e918e075a2380719e13c1b4a9fb598474b5e6df789225dab9e16eea84
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.0.30 / 2014-05-07
2
+
3
+ * Added ListDossierGroupRights and DeleteDossierGroupRight
4
+
1
5
  ### 0.0.29 / 2014-05-01
2
6
 
3
7
  * Removed ENV['CORE_LOGIN_TITLE'] support
data/README.md CHANGED
@@ -15,6 +15,11 @@ TODO: Description
15
15
 
16
16
  require 'core_api'
17
17
 
18
+ # List all professionals under a dossier group.
19
+ Roqua.CoreApi.DossierGroupRights.run!(dossier_group_id:,session:).each do |r|
20
+ puts r.id, r.firstname, r.lastname
21
+ end
22
+
18
23
  ## Requirements
19
24
 
20
25
  ## Install
@@ -0,0 +1,20 @@
1
+ module Roqua
2
+ module CoreApi
3
+ class Base < ActiveInteraction::Base
4
+ private
5
+
6
+ def create_enum(headers, rows)
7
+ row_class = Struct.new(*headers.map(&:to_sym))
8
+ rows.lazy.map { |row| row_class.new(*row) }.to_enum
9
+ end
10
+
11
+ def errors_to_object(response, obj)
12
+ response['errors'].each do |attribute, errors|
13
+ errors.each do |error|
14
+ obj.errors.add(attribute, I18n.t("errors.messages.#{error}"))
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module Roqua
2
+ module CoreApi
3
+ # @api private
4
+ class CreateProfessional < Base
5
+ model :session, class: Sessions::OAuthSession
6
+ string :dossier_group_id
7
+ model :person, class: Models::Person
8
+
9
+ def execute
10
+ response = session.post "/dossier_groups/#{dossier_group_id}/people",
11
+ person: person.as_json
12
+ if response.code == 422
13
+ errors_to_object(response, person)
14
+ person
15
+ else
16
+ Models::Person.new(response['person'])
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ module Roqua
2
+ module CoreApi
3
+ # @api private
4
+ class DeleteDossierGroupRight < Base
5
+ model :session, class: Sessions::OAuthSession
6
+ string :dossier_group_id
7
+ string :right_id
8
+
9
+ def execute
10
+ session.delete "/dossier_groups/#{dossier_group_id}/rights/#{right_id}"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  module Roqua
2
2
  module CoreApi
3
3
  # @api private
4
- class Dossiers < ActiveInteraction::Base
4
+ class Dossiers < Base
5
5
  model :session, class: Sessions::OAuthSession
6
6
 
7
7
  # usage:
@@ -12,11 +12,6 @@ module Roqua
12
12
  response = session.get "/dossiers"
13
13
  create_enum(response['headers'], response['rows'])
14
14
  end
15
-
16
- def create_enum(headers, rows)
17
- row_class = Struct.new(*headers.map(&:to_sym))
18
- rows.lazy.map { |row| row_class.new(*row) }.to_enum
19
- end
20
15
  end
21
16
  end
22
17
  end
@@ -0,0 +1,14 @@
1
+ module Roqua
2
+ module CoreApi
3
+ # @api private
4
+ class ListDossierGroupRights < Base
5
+ model :session, class: Sessions::OAuthSession
6
+ string :dossier_group_id
7
+
8
+ def execute
9
+ response = session.get "/dossier_groups/#{dossier_group_id}/rights"
10
+ create_enum(response['headers'], response['rows'])
11
+ end
12
+ end
13
+ end
14
+ end
@@ -8,6 +8,11 @@ class Roqua::CoreApi::Models::ActiveVirtus
8
8
  include ActiveModel::Serialization
9
9
  include Virtus.model
10
10
 
11
+ def initialize(params = nil)
12
+ super
13
+ dates_from_xi(params)
14
+ end
15
+
11
16
  def attributes=(params)
12
17
  dates_from_xi(params)
13
18
  super
@@ -21,6 +26,7 @@ class Roqua::CoreApi::Models::ActiveVirtus
21
26
 
22
27
  # set Date and DateTime attributes by "name(1i)" style params
23
28
  def dates_from_xi(params)
29
+ return unless params
24
30
  dates_to_change = self.class.attribute_set.select do |a|
25
31
  a.type.primitive <= Date && params.key?("#{a.name}(1i)")
26
32
  end
@@ -19,7 +19,7 @@ class Roqua::CoreApi::Models::Person < Roqua::CoreApi::Models::ActiveVirtus
19
19
  attribute :zipcode, String
20
20
  attribute :country, String
21
21
 
22
- validates :role, inclusion: { in: %w( professional patient parent ) }
22
+ validates :role, inclusion: { in: %w( admin professional patient parent ) }
23
23
 
24
24
  def persisted?
25
25
  id.present?
@@ -1,7 +1,7 @@
1
1
  module Roqua
2
2
  module CoreApi
3
3
  # @api private
4
- class UpdatePerson < ActiveInteraction::Base
4
+ class UpdatePerson < Base
5
5
  model :session, class: Sessions::OAuthSession
6
6
  model :person, class: Models::Person
7
7
 
@@ -18,16 +18,6 @@ module Roqua
18
18
  true
19
19
  end
20
20
  end
21
-
22
- private
23
-
24
- def errors_to_object(json, obj)
25
- json['errors'].each do |attribute, errors|
26
- errors.each do |error|
27
- obj.errors.add(attribute, I18n.t("errors.messages.#{error}"))
28
- end
29
- end
30
- end
31
21
  end
32
22
  end
33
23
  end
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module CoreApi
3
- VERSION = '0.0.29'
3
+ VERSION = '0.0.30'
4
4
  end
5
5
  end
@@ -2,8 +2,12 @@ require 'active_interaction'
2
2
  require 'roqua/core_api/version'
3
3
  require 'roqua/core_api/sessions'
4
4
  require 'roqua/core_api/models'
5
+ require 'roqua/core_api/base'
5
6
  require 'roqua/core_api/dossiers'
6
7
  require 'roqua/core_api/dossier_groups'
8
+ require 'roqua/core_api/list_dossier_group_rights'
9
+ require 'roqua/core_api/delete_dossier_group_right'
10
+ require 'roqua/core_api/create_professional'
7
11
  require 'roqua/core_api/create_dossier'
8
12
  require 'roqua/core_api/create_dossier_group'
9
13
  require 'roqua/core_api/send_email_to'
@@ -20,6 +20,10 @@ module Roqua
20
20
  subject.attributes = { 'date(1i)' => '1999', 'date(2i)' => '12', 'date(3i)' => '32'}
21
21
  expect(subject.errors[:date][0]).to match 'invalid_date'
22
22
  end
23
+ it 'can create new with date(i1) params' do
24
+ foo = Foo.new('date(1i)' => '1999', 'date(2i)' => '12', 'date(3i)' => '8')
25
+ expect(foo.date).to eq Date.new(1999, 12, 8)
26
+ end
23
27
  end
24
28
 
25
29
  describe 'DateTime' do
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.29
4
+ version: 0.0.30
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-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -183,10 +183,14 @@ files:
183
183
  - core_api.gemspec
184
184
  - lib/roqua-core-api.rb
185
185
  - lib/roqua/core_api.rb
186
+ - lib/roqua/core_api/base.rb
186
187
  - lib/roqua/core_api/create_dossier.rb
187
188
  - lib/roqua/core_api/create_dossier_group.rb
189
+ - lib/roqua/core_api/create_professional.rb
190
+ - lib/roqua/core_api/delete_dossier_group_right.rb
188
191
  - lib/roqua/core_api/dossier_groups.rb
189
192
  - lib/roqua/core_api/dossiers.rb
193
+ - lib/roqua/core_api/list_dossier_group_rights.rb
190
194
  - lib/roqua/core_api/models.rb
191
195
  - lib/roqua/core_api/models/active_virtus.rb
192
196
  - lib/roqua/core_api/models/dossier.rb