roqua-core-api 0.2.0 → 0.2.1
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 +4 -4
- data/ChangeLog.md +4 -1
- data/config/locales/validation_errors.yml +3 -2
- data/lib/roqua/core_api/create_dossier.rb +8 -4
- data/lib/roqua/core_api/models/credential.rb +10 -0
- data/lib/roqua/core_api/models.rb +1 -0
- data/lib/roqua/core_api/send_invite_email.rb +13 -2
- data/lib/roqua/core_api/version.rb +1 -1
- data/spec/lib/roqua/core_api/create_dossier_spec.rb +7 -2
- data/spec/lib/roqua/core_api/send_invite_email_spec.rb +38 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afcb8f55c765892ee686c50b9b069af7a42242cc
|
4
|
+
data.tar.gz: 231798c7c1c9f410237f4d9f4d683be12d3c8188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 053913480e04a70b7e0521b65ebc4bfac5fcb1901efcd7864a34e98642f1570e8c186bf54fd65271b88ead86d982c6e9575dd677d340efc4cfe43102770d7764
|
7
|
+
data.tar.gz: 9eb9cd12a83f09c7a8e956098b42d305ea639020a085eb3240403b90599b743951f5b442d140199eca9f743224f0f2f27a63c036707d75bd0ae7f22708311a91
|
data/ChangeLog.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
### 0.2.1
|
2
|
+
|
3
|
+
* Allow SendInviteEmail to receive a person_id instead of a dossier_id
|
2
4
|
|
3
5
|
### 0.2.0
|
4
6
|
|
@@ -7,6 +9,7 @@ Active interaction to v2.
|
|
7
9
|
### 0.1.1
|
8
10
|
|
9
11
|
* Add token session.
|
12
|
+
* Added TokenSession model and CreateTokenSession, DestroyTokenSession usecases.
|
10
13
|
|
11
14
|
### 0.1.0
|
12
15
|
|
@@ -22,13 +22,14 @@ nl:
|
|
22
22
|
odd: moet oneven zijn
|
23
23
|
record_invalid: ! 'Validatie mislukt: %{errors}'
|
24
24
|
taken: is al in gebruik
|
25
|
-
too_long: is te lang
|
26
|
-
too_short: is te kort
|
25
|
+
too_long: is te lang
|
26
|
+
too_short: is te kort
|
27
27
|
wrong_length: heeft onjuiste lengte (moet %{count} tekens lang zijn)
|
28
28
|
invalid_key: mag enkel kleine letters, cijfers en underscores bevatten en moet beginnen met een letter.
|
29
29
|
valid_ip_addresses: moeten geldige IP-adressen zijn
|
30
30
|
invalid_email: Geen geldig email adres
|
31
31
|
invalid_date: Niet een bestaande datum
|
32
|
+
already_exists: Bestaat al
|
32
33
|
template:
|
33
34
|
body: ! 'Controleer de volgende velden:'
|
34
35
|
header:
|
@@ -6,13 +6,17 @@ module Roqua
|
|
6
6
|
string :dossier_group_id
|
7
7
|
object :dossier, class: Models::Dossier, default: nil
|
8
8
|
object :person, class: Models::Person, default: nil
|
9
|
+
object :credential, class: Models::Credential, default: nil
|
9
10
|
|
10
11
|
def execute
|
11
12
|
response = session.post "/dossier_groups/#{dossier_group_id}/dossiers",
|
12
|
-
person:
|
13
|
+
person: attribute_hash(person),
|
14
|
+
dossier: dossier_attributes,
|
15
|
+
credential: attribute_hash(credential)
|
13
16
|
if response.code == 422
|
14
17
|
errors_to_object(response, person)
|
15
18
|
errors_to_object(response, dossier)
|
19
|
+
errors_to_object(response, credential)
|
16
20
|
end
|
17
21
|
Models::Dossier.new(response)
|
18
22
|
end
|
@@ -24,9 +28,9 @@ module Roqua
|
|
24
28
|
dossier.serializable_hash(except: :people).keep_if { |_k, v| !v.nil? }
|
25
29
|
end
|
26
30
|
|
27
|
-
def
|
28
|
-
return {} unless
|
29
|
-
|
31
|
+
def attribute_hash(obj)
|
32
|
+
return {} unless obj
|
33
|
+
obj.serializable_hash.keep_if { |_k, v| !v.nil? }
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
@@ -3,16 +3,27 @@ module Roqua
|
|
3
3
|
# @api private
|
4
4
|
class SendInviteEmail < ActiveInteraction::Base
|
5
5
|
object :session, class: Sessions::AuthSession
|
6
|
-
string :dossier_id
|
6
|
+
string :dossier_id, default: nil
|
7
|
+
string :person_id, default: nil
|
7
8
|
string :email_subject, default: nil
|
8
9
|
string :email_body, default: nil
|
9
10
|
|
11
|
+
validates :person_id, presence: true, unless: :dossier_id?
|
12
|
+
|
10
13
|
def execute
|
11
|
-
session.post
|
14
|
+
session.post url, params
|
12
15
|
end
|
13
16
|
|
14
17
|
private
|
15
18
|
|
19
|
+
def url
|
20
|
+
if person_id
|
21
|
+
"/people/#{person_id}/send_invite_email"
|
22
|
+
else
|
23
|
+
"/dossiers/#{dossier_id}/send_invite_email"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
16
27
|
def params
|
17
28
|
{
|
18
29
|
email_subject: email_subject, email_body: email_body
|
@@ -51,18 +51,23 @@ describe CreateDossier do
|
|
51
51
|
|
52
52
|
describe 'with validation errors' do
|
53
53
|
let(:response) { httparty_response({'errors' => {'person' => {'email' => ['invalid_email']},
|
54
|
-
'dossier' => {'external_identifier' => ['blank']}
|
54
|
+
'dossier' => {'external_identifier' => ['blank']},
|
55
|
+
'credential' => {'password' => ['too_short']}}},
|
55
56
|
422) }
|
57
|
+
let(:credential) { Roqua::CoreApi::Models::Credential.new \
|
58
|
+
username: 'foobar', password: '123', password_confirmation: '123' }
|
56
59
|
|
57
|
-
it '
|
60
|
+
it 'sets the errors on the objects' do
|
58
61
|
allow(session).to receive(:post).and_return(response)
|
59
62
|
new_dossier = CreateDossier.run!(session: session,
|
60
63
|
person: person,
|
61
64
|
dossier: dossier,
|
65
|
+
credential: credential,
|
62
66
|
dossier_group_id: 'some_dossier_group_id')
|
63
67
|
expect(new_dossier.persisted?).to be_falsy
|
64
68
|
expect(person.errors[:email]).to eq ['Geen geldig email adres']
|
65
69
|
expect(dossier.errors[:external_identifier]).to eq ['moet opgegeven zijn']
|
70
|
+
expect(credential.errors[:password]).to eq ['is te kort']
|
66
71
|
end
|
67
72
|
end
|
68
73
|
end
|
@@ -3,12 +3,43 @@ require 'spec_helper'
|
|
3
3
|
describe SendInviteEmail do
|
4
4
|
let(:session) { Fabricate :roqua_core_api_oauth_session }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
context 'Dossier' do
|
7
|
+
subject { SendInviteEmail.run! \
|
8
|
+
session: session,
|
9
|
+
dossier_id: 'some_dossier_id',
|
10
|
+
email_subject: 'account created',
|
11
|
+
email_body: 'visit %create_account_link% to set password' }
|
12
|
+
it 'performs a post on the send_invite_email api path' do
|
13
|
+
expect(session).to receive(:post).with '/dossiers/some_dossier_id/send_invite_email',
|
14
|
+
email_subject: 'account created',
|
15
|
+
email_body: 'visit %create_account_link% to set password'
|
16
|
+
subject
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "Person" do
|
21
|
+
subject { SendInviteEmail.run! \
|
22
|
+
session: session,
|
23
|
+
person_id: 'some_person_id',
|
24
|
+
email_subject: 'account created',
|
25
|
+
email_body: 'visit %create_account_link% to set password' }
|
26
|
+
it 'performs a post on the send_invite_email api path' do
|
27
|
+
expect(session).to receive(:post).with '/people/some_person_id/send_invite_email',
|
28
|
+
email_subject: 'account created',
|
29
|
+
email_body: 'visit %create_account_link% to set password'
|
30
|
+
subject
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "Neither Dossier nor Person" do
|
35
|
+
subject { SendInviteEmail.run \
|
36
|
+
session: session,
|
37
|
+
email_subject: 'account created',
|
38
|
+
email_body: 'visit %create_account_link% to set password' }
|
39
|
+
|
40
|
+
it 'performs a post on the send_invite_email api path' do
|
41
|
+
expect(subject).to be_invalid
|
42
|
+
expect(subject.errors).to include :person_id
|
43
|
+
end
|
13
44
|
end
|
14
45
|
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- lib/roqua/core_api/list_dossier_group_rights.rb
|
199
199
|
- lib/roqua/core_api/models.rb
|
200
200
|
- lib/roqua/core_api/models/active_virtus.rb
|
201
|
+
- lib/roqua/core_api/models/credential.rb
|
201
202
|
- lib/roqua/core_api/models/dossier.rb
|
202
203
|
- lib/roqua/core_api/models/dossier_group.rb
|
203
204
|
- lib/roqua/core_api/models/export.rb
|