roqua-core-api 0.2.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/ChangeLog.md +22 -0
  3. data/lib/roqua-core-api.rb +2 -2
  4. data/lib/roqua/core_api.rb +2 -0
  5. data/lib/roqua/core_api/models/active_virtus.rb +1 -1
  6. data/lib/roqua/core_api/send_email_to.rb +0 -1
  7. data/lib/roqua/core_api/send_notification.rb +31 -0
  8. data/lib/roqua/core_api/send_text_message_to.rb +21 -0
  9. data/lib/roqua/core_api/sessions.rb +6 -11
  10. data/lib/roqua/core_api/sessions/hmac_auth_request.rb +1 -1
  11. data/lib/roqua/core_api/version.rb +1 -1
  12. data/spec/lib/roqua/core_api/create_dossier_group_spec.rb +1 -1
  13. data/spec/lib/roqua/core_api/create_dossier_spec.rb +1 -1
  14. data/spec/lib/roqua/core_api/dossiers_spec.rb +1 -1
  15. data/spec/lib/roqua/core_api/send_email_to_spec.rb +0 -2
  16. data/spec/lib/roqua/core_api/send_invite_email_spec.rb +1 -1
  17. data/spec/lib/roqua/core_api/send_text_message_to_spec.rb +14 -0
  18. data/spec/lib/roqua/core_api/sessions/auth_session_spec.rb +3 -3
  19. data/spec/lib/roqua/core_api/sessions/token_session_spec.rb +3 -3
  20. data/spec/lib/roqua/core_api/update_dossier_spec.rb +1 -1
  21. metadata +33 -86
  22. data/.document +0 -3
  23. data/.gitignore +0 -6
  24. data/.rspec +0 -1
  25. data/.yardopts +0 -2
  26. data/Gemfile +0 -16
  27. data/Guardfile +0 -4
  28. data/Rakefile +0 -41
  29. data/core_api.gemspec +0 -32
  30. data/lib/roqua/core_api/sessions/oauth_session.rb +0 -38
  31. data/lib/roqua/omniauth/rails_initializer.rb +0 -12
  32. data/lib/roqua/omniauth/strategies/doorkeeper.rb +0 -25
  33. data/spec/core_api_spec.rb +0 -7
  34. data/spec/fabricators/auth_session_fabricator.rb +0 -9
  35. data/spec/fabricators/basic_auth_session_fabricator.rb +0 -7
  36. data/spec/fabricators/dossier_fabricator.rb +0 -5
  37. data/spec/fabricators/oauth_session_fabricator.rb +0 -5
  38. data/spec/fabricators/person_fabricator.rb +0 -7
  39. data/spec/lib/roqua/core_api/sessions/oauth_session_spec.rb +0 -63
  40. data/spec/spec_helper.rb +0 -16
  41. data/spec/support/httpparty_helpers.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 684f4a6cbec3185083dc457c736c3fb63b1b567a
4
- data.tar.gz: 2fc3f48a9f305c1ec6eb1ec2400592f07b55e7cd
2
+ SHA256:
3
+ metadata.gz: 30f8c823e4ff8e1a50c7b299b99fd9b61a250642253e7e86b6b1b5243843917b
4
+ data.tar.gz: e579c453635e8a91d55b49c0ec9c7bad4f6e941718e243928a9a862036ee9cce
5
5
  SHA512:
6
- metadata.gz: 6b051a343c8ac695cfb19646c1fc19fb429e26efa71b375f1a51012785701f11d42e5e3ace83212ae166ab6d97df68b3ff25780be90ef0dc197d153fa91bfb5d
7
- data.tar.gz: fcef952a87d0206325f58f86e3fcecfba61306f797dc43020eb729967555d968fe63e097ba3787c62515b0f40b28608cfd2bb4f293dd9b46f30bf7e99c3e6dea
6
+ metadata.gz: ea8e37b35220405c19a1dbf95d9dc3a0a6373c35c765207387cb13b3feb7513b2a5b2c0996099d0db4d618aecd19800c905ae9479455bfcd0c26d6d0f655a032
7
+ data.tar.gz: 152e5994dd65d27b81f4ee04e8cee2cda0140693c0f64f71174121b1e19b800ab47fa2223bf1c682df011f35d83c9da39bf342b4f043ee9277a5459f22cb0321
data/ChangeLog.md CHANGED
@@ -1,3 +1,25 @@
1
+ ### 0.5.0
2
+
3
+ require ruby 2.7
4
+ loosen httparty gem requirement
5
+
6
+ ### 0.4.0
7
+
8
+ * remove oauth_session
9
+
10
+ ### 0.3.1
11
+
12
+ * Added Notification endpoint
13
+ * Deprecated email and text_message endpoint
14
+
15
+ ### 0.3.0
16
+
17
+ * BACKWARD INCOMPATIBLE: SendTextMessage now expects a session instead of username/password
18
+
19
+ ### 0.2.4
20
+
21
+ * Add SendTextMessage
22
+
1
23
  ### 0.2.3
2
24
 
3
25
  * Update httparty dependency
@@ -1,2 +1,2 @@
1
- require ::File.expand_path('../roqua/core_api', __FILE__)
2
- require ::File.expand_path('../i18n/core_api_i18n', __FILE__)
1
+ require ::File.expand_path('roqua/core_api', __dir__)
2
+ require ::File.expand_path('i18n/core_api_i18n', __dir__)
@@ -24,6 +24,8 @@ module Roqua
24
24
  autoload :People
25
25
  autoload :Person
26
26
  autoload :SendEmailTo
27
+ autoload :SendNotification
28
+ autoload :SendTextMessageTo
27
29
  autoload :SendInviteEmail
28
30
  autoload :SsoLogin
29
31
  autoload :UpdatePerson
@@ -44,7 +44,7 @@ class Roqua::CoreApi::Models::ActiveVirtus
44
44
  min: params.fetch("#{attribute}(5i)", 0),
45
45
  sec: params.fetch("#{attribute}(6i)", 0)
46
46
  }
47
- rescue
47
+ rescue StandardError
48
48
  errors.add(attribute, I18n.t("errors.messages.invalid_date"))
49
49
  end
50
50
  end
@@ -6,7 +6,6 @@ module Roqua
6
6
  hash :attributes do
7
7
  string :subject
8
8
  string :body
9
- string :bcc, default: nil
10
9
  string :content_type, default: 'text/html'
11
10
  string :mail_type, default: nil
12
11
  end
@@ -0,0 +1,31 @@
1
+ module Roqua
2
+ module CoreApi
3
+ # @api private
4
+ class SendNotification < ActiveInteraction::Base
5
+ string :person_id, default: nil # if nil, to must be present.
6
+ string :dossier_id, default: nil
7
+ hash :attributes do
8
+ string :body_short
9
+ string :body_long
10
+ string :notification_type, default: nil
11
+ string :reference
12
+ string :subject
13
+ hash :addresses, default: nil, strip: false
14
+ hash :variables, strip: false, default: {}
15
+ array :notify_by do # [:sms, :email]
16
+ string
17
+ end
18
+ end
19
+
20
+ # Possible variables in the body/subject are:
21
+ # %firstname%,
22
+ # %lastname%,
23
+ # %initials%
24
+ def execute
25
+ CoreApi.basic_auth_session.post "/notifications", notification: attributes,
26
+ person_id: person_id,
27
+ dossier_id: dossier_id
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ module Roqua
2
+ module CoreApi
3
+ # @api private
4
+ class SendTextMessageTo < ActiveInteraction::Base
5
+ object :session, class: Sessions::AuthSession
6
+ string :person_id
7
+ hash :attributes do
8
+ string :body
9
+ string :reference, default: nil
10
+ end
11
+
12
+ # Possible variables in the body are:
13
+ # %firstname%,
14
+ # %lastname%,
15
+ # %initials%
16
+ def execute
17
+ session.post "/text_messages", text_message: attributes, person_id: person_id
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,5 @@
1
1
  require 'httparty'
2
2
  require 'roqua/core_api/sessions/auth_session'
3
- require 'roqua/core_api/sessions/oauth_session'
4
3
  require 'roqua/core_api/sessions/token_session'
5
4
  require 'roqua/core_api/sessions/basic_auth_session'
6
5
  require 'roqua/core_api/sessions/hmac_auth_request'
@@ -8,20 +7,16 @@ require 'roqua/core_api/sessions/hmac_auth_session'
8
7
 
9
8
  module Roqua
10
9
  module CoreApi
11
- def self.oauth_session(*arguments, &block)
12
- Sessions::OAuthSession.new(*arguments, &block)
10
+ def self.token_session(...)
11
+ Sessions::TokenSession.new(...)
13
12
  end
14
13
 
15
- def self.token_session(*arguments, &block)
16
- Sessions::TokenSession.new(*arguments, &block)
14
+ def self.basic_auth_session(...)
15
+ Sessions::BasicAuthSession.new(...)
17
16
  end
18
17
 
19
- def self.basic_auth_session(*arguments, &block)
20
- Sessions::BasicAuthSession.new(*arguments, &block)
21
- end
22
-
23
- def self.hmac_auth_request(*arguments)
24
- Sessions::HmacAuthRequest(*arguments)
18
+ def self.hmac_auth_request(...)
19
+ Sessions::HmacAuthRequest(...)
25
20
  end
26
21
  end
27
22
  end
@@ -37,7 +37,7 @@ module Roqua
37
37
  end
38
38
 
39
39
  def calculate_hmac(request_method, path, params)
40
- checker = Authmac::HmacChecker.new(consumer_secret, '|', 'sha256')
40
+ checker = Authmac::HmacChecker.new(consumer_secret, digest_function: 'sha256', message_format: :json)
41
41
  params_to_sign = params.merge \
42
42
  'request_method' => request_method,
43
43
  'request_path' => "/api/v1#{path}",
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module CoreApi
3
- VERSION = '0.2.3'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CreateDossierGroup do
4
- let(:session) { Fabricate :roqua_core_api_oauth_session }
4
+ let(:session) { Fabricate :roqua_core_api_token_session }
5
5
 
6
6
  it 'performs a post on the /dossier_groups api path' do
7
7
  expect(session).to receive(:post).with('/dossier_groups', dossier_group: {some: 'attributes'},
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CreateDossier do
4
- let(:session) { Fabricate :roqua_core_api_oauth_session }
4
+ let(:session) { Fabricate :roqua_core_api_token_session }
5
5
  let(:person) { Fabricate :roqua_core_api_person, id: nil }
6
6
  let(:dossier) { Fabricate :roqua_core_api_dossier, id: nil }
7
7
  let(:response) { httparty_response('id' => 'some_id') }
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Dossiers do
4
- let(:session) { Fabricate :roqua_core_api_oauth_session }
4
+ let(:session) { Fabricate :roqua_core_api_token_session }
5
5
  let(:dossier_group_id) { 'some_dg_id' }
6
6
  let(:external_identifier) { 'some_eid' }
7
7
  let(:response) { {'headers' => %w(id birth_year gender firstname lastname),
@@ -7,7 +7,6 @@ describe SendEmailTo do
7
7
  it 'performs a post on the emails api path providing the person_id and the email attributes' do
8
8
  email_attributes = {subject: 'some_subject',
9
9
  body: 'some_body',
10
- bcc: 'some@bcc',
11
10
  content_type: 'some/content/type',
12
11
  mail_type: 'some_mail_type'}
13
12
  expect(session).to receive(:post).with '/emails', person_id: 'some_person_id', email: email_attributes
@@ -17,7 +16,6 @@ describe SendEmailTo do
17
16
  it 'defaults the content_type to text/html' do
18
17
  email_attributes = {subject: 'some_subject',
19
18
  body: 'some_body',
20
- bcc: 'some@bcc',
21
19
  mail_type: 'some_mail_type'}
22
20
  expect(session).to receive(:post).with '/emails', person_id: 'some_person_id',
23
21
  email: email_attributes.merge(content_type: 'text/html')
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SendInviteEmail do
4
- let(:session) { Fabricate :roqua_core_api_oauth_session }
4
+ let(:session) { Fabricate :roqua_core_api_token_session }
5
5
 
6
6
  context 'Dossier' do
7
7
  subject { SendInviteEmail.run! \
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe SendTextMessageTo do
4
+ let(:session) { Sessions::BasicAuthSession.new }
5
+ before { allow(Sessions::BasicAuthSession).to receive(:new).and_return session }
6
+
7
+ it 'performs a post on the text_messages api path providing the person_id and the text_message attributes' do
8
+ text_message_attributes = { body: 'some_body',
9
+ reference: 'some_reference'}
10
+ expect(session).to receive(:post).with '/text_messages', person_id: 'some_person_id',
11
+ text_message: text_message_attributes
12
+ SendTextMessageTo.run!(session: session, person_id: 'some_person_id', attributes: text_message_attributes)
13
+ end
14
+ end
@@ -34,7 +34,7 @@ describe AuthSession do
34
34
  it 'performs a get request' do
35
35
  allow(session).to receive(:basic_auth).and_return(username: 'some_username', password: 'some_password')
36
36
  allow(session).to receive(:headers).and_return(some: 'header')
37
- expect(HTTParty).to receive(:get).with('http://core.dev/api/v1/some_path.json',
37
+ expect(HTTParty).to receive(:get).with('http://core.roqua.eu/api/v1/some_path.json',
38
38
  query: {some: 'param'},
39
39
  headers: {some: 'header'},
40
40
  basic_auth: {username: 'some_username', password: 'some_password'},
@@ -44,7 +44,7 @@ describe AuthSession do
44
44
  end
45
45
 
46
46
  it 'returns the response on sucess status' do
47
- stub_request(:get, 'http://core.dev/api/v1/some_path.json?').to_return(
47
+ stub_request(:get, 'http://core.roqua.eu/api/v1/some_path.json?').to_return(
48
48
  status: 201,
49
49
  body: '{ "success": true }',
50
50
  headers: { 'Content-Type' => 'application/json' })
@@ -52,7 +52,7 @@ describe AuthSession do
52
52
  end
53
53
 
54
54
  it 'returns the response on a 422 status' do
55
- stub_request(:get, 'http://core.dev/api/v1/some_path.json?').to_return(
55
+ stub_request(:get, 'http://core.roqua.eu/api/v1/some_path.json?').to_return(
56
56
  status: 422,
57
57
  body: '{ "errors": { "column": ["wrong"] } }',
58
58
  headers: { 'Content-Type' => 'application/json' })
@@ -27,7 +27,7 @@ describe TokenSession do
27
27
 
28
28
  describe '#logout' do
29
29
  it 'sends a put request to the session#destroy' do
30
- expect(HTTParty).to receive(:delete).with("http://core.dev/api/v1sessions/destroy.json",
30
+ expect(HTTParty).to receive(:delete).with("http://core.roqua.eu/api/v1sessions/destroy.json",
31
31
  headers: {"Authorization" => "Session some_access_token"},
32
32
  query: {},
33
33
  basic_auth: nil,
@@ -49,7 +49,7 @@ describe TokenSession do
49
49
 
50
50
  describe '#access_denied' do
51
51
  it 'raises a no_session error when response is 401 with a no_session response' do
52
- stub_request(:get, 'http://core.dev/api/v1/some_path.json?').to_return(
52
+ stub_request(:get, 'http://core.roqua.eu/api/v1/some_path.json?').to_return(
53
53
  status: 401,
54
54
  body: '{ "no_session": true }',
55
55
  headers: { 'Content-Type' => 'application/json' })
@@ -57,7 +57,7 @@ describe TokenSession do
57
57
  end
58
58
 
59
59
  it 'raises a unauthorized error when response is 401 without a no_session response' do
60
- stub_request(:get, 'http://core.dev/api/v1/some_path.json?').to_return(
60
+ stub_request(:get, 'http://core.roqua.eu/api/v1/some_path.json?').to_return(
61
61
  status: 401,
62
62
  body: '',
63
63
  headers: { 'Content-Type' => 'application/json' })
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe UpdateDossier do
4
- let(:session) { Fabricate :roqua_core_api_oauth_session }
4
+ let(:session) { Fabricate :roqua_core_api_token_session }
5
5
  let(:dossier) { Fabricate :roqua_core_api_dossier }
6
6
  let(:response) { double }
7
7
 
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-core-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-12 00:00:00.000000000 Z
11
+ date: 2021-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: httparty
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.14.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.14.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: active_interaction
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +25,19 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '3.2'
41
27
  - !ruby/object:Gem::Dependency
42
- name: omniauth-oauth2
28
+ name: httparty
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '1.1'
33
+ version: '0.14'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '1.1'
40
+ version: '0.14'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: virtus
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -70,72 +56,72 @@ dependencies:
70
56
  name: bundler
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: '1.0'
61
+ version: '0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: '1.0'
68
+ version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: rake
70
+ name: dotenv
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '10.0'
75
+ version: '0.10'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '10.0'
82
+ version: '0.10'
97
83
  - !ruby/object:Gem::Dependency
98
- name: yard
84
+ name: fabrication
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0.8'
89
+ version: '2.9'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0.8'
96
+ version: '2.9'
111
97
  - !ruby/object:Gem::Dependency
112
- name: rspec
98
+ name: rake
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: '3.0'
103
+ version: '13.0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: '3.0'
110
+ version: '13.0'
125
111
  - !ruby/object:Gem::Dependency
126
- name: fabrication
112
+ name: rspec
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: '2.9'
117
+ version: '3.0'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: '2.9'
124
+ version: '3.0'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: webmock
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -151,37 +137,29 @@ dependencies:
151
137
  - !ruby/object:Gem::Version
152
138
  version: '1.17'
153
139
  - !ruby/object:Gem::Dependency
154
- name: dotenv
140
+ name: yard
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: '0.10'
145
+ version: '0.8'
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: '0.10'
152
+ version: '0.8'
167
153
  description: Provides authenticated access to Core
168
154
  email: marten@veldthuis.com
169
155
  executables: []
170
156
  extensions: []
171
157
  extra_rdoc_files: []
172
158
  files:
173
- - ".document"
174
- - ".gitignore"
175
- - ".rspec"
176
- - ".yardopts"
177
159
  - ChangeLog.md
178
- - Gemfile
179
- - Guardfile
180
160
  - LICENSE.txt
181
161
  - README.md
182
- - Rakefile
183
162
  - config/locales/validation_errors.yml
184
- - core_api.gemspec
185
163
  - lib/i18n/core_api_i18n.rb
186
164
  - lib/roqua-core-api.rb
187
165
  - lib/roqua/core_api.rb
@@ -207,25 +185,18 @@ files:
207
185
  - lib/roqua/core_api/person.rb
208
186
  - lib/roqua/core_api/send_email_to.rb
209
187
  - lib/roqua/core_api/send_invite_email.rb
188
+ - lib/roqua/core_api/send_notification.rb
189
+ - lib/roqua/core_api/send_text_message_to.rb
210
190
  - lib/roqua/core_api/sessions.rb
211
191
  - lib/roqua/core_api/sessions/auth_session.rb
212
192
  - lib/roqua/core_api/sessions/basic_auth_session.rb
213
193
  - lib/roqua/core_api/sessions/hmac_auth_request.rb
214
194
  - lib/roqua/core_api/sessions/hmac_auth_session.rb
215
- - lib/roqua/core_api/sessions/oauth_session.rb
216
195
  - lib/roqua/core_api/sessions/token_session.rb
217
196
  - lib/roqua/core_api/sso_login.rb
218
197
  - lib/roqua/core_api/update_dossier.rb
219
198
  - lib/roqua/core_api/update_person.rb
220
199
  - lib/roqua/core_api/version.rb
221
- - lib/roqua/omniauth/rails_initializer.rb
222
- - lib/roqua/omniauth/strategies/doorkeeper.rb
223
- - spec/core_api_spec.rb
224
- - spec/fabricators/auth_session_fabricator.rb
225
- - spec/fabricators/basic_auth_session_fabricator.rb
226
- - spec/fabricators/dossier_fabricator.rb
227
- - spec/fabricators/oauth_session_fabricator.rb
228
- - spec/fabricators/person_fabricator.rb
229
200
  - spec/lib/roqua/core_api/create_dossier_group_spec.rb
230
201
  - spec/lib/roqua/core_api/create_dossier_spec.rb
231
202
  - spec/lib/roqua/core_api/dossiers_spec.rb
@@ -234,18 +205,16 @@ files:
234
205
  - spec/lib/roqua/core_api/models/person_spec.rb
235
206
  - spec/lib/roqua/core_api/send_email_to_spec.rb
236
207
  - spec/lib/roqua/core_api/send_invite_email_spec.rb
208
+ - spec/lib/roqua/core_api/send_text_message_to_spec.rb
237
209
  - spec/lib/roqua/core_api/sessions/auth_session_spec.rb
238
210
  - spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
239
- - spec/lib/roqua/core_api/sessions/oauth_session_spec.rb
240
211
  - spec/lib/roqua/core_api/sessions/token_session_spec.rb
241
212
  - spec/lib/roqua/core_api/update_dossier_spec.rb
242
- - spec/spec_helper.rb
243
- - spec/support/httpparty_helpers.rb
244
213
  homepage: https://github.com/roqua/core/blob/master/core_api/README.markdown
245
214
  licenses:
246
215
  - MIT
247
216
  metadata: {}
248
- post_install_message:
217
+ post_install_message:
249
218
  rdoc_options: []
250
219
  require_paths:
251
220
  - lib
@@ -253,37 +222,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
253
222
  requirements:
254
223
  - - ">="
255
224
  - !ruby/object:Gem::Version
256
- version: '0'
225
+ version: '2.7'
257
226
  required_rubygems_version: !ruby/object:Gem::Requirement
258
227
  requirements:
259
228
  - - ">="
260
229
  - !ruby/object:Gem::Version
261
230
  version: '0'
262
231
  requirements: []
263
- rubyforge_project:
264
- rubygems_version: 2.5.1
265
- signing_key:
232
+ rubygems_version: 3.1.4
233
+ signing_key:
266
234
  specification_version: 4
267
235
  summary: API wrapper gem around Core's API
268
- test_files:
269
- - spec/core_api_spec.rb
270
- - spec/fabricators/auth_session_fabricator.rb
271
- - spec/fabricators/basic_auth_session_fabricator.rb
272
- - spec/fabricators/dossier_fabricator.rb
273
- - spec/fabricators/oauth_session_fabricator.rb
274
- - spec/fabricators/person_fabricator.rb
275
- - spec/lib/roqua/core_api/create_dossier_group_spec.rb
276
- - spec/lib/roqua/core_api/create_dossier_spec.rb
277
- - spec/lib/roqua/core_api/dossiers_spec.rb
278
- - spec/lib/roqua/core_api/models/active_virtus_spec.rb
279
- - spec/lib/roqua/core_api/models/dossier_spec.rb
280
- - spec/lib/roqua/core_api/models/person_spec.rb
281
- - spec/lib/roqua/core_api/send_email_to_spec.rb
282
- - spec/lib/roqua/core_api/send_invite_email_spec.rb
283
- - spec/lib/roqua/core_api/sessions/auth_session_spec.rb
284
- - spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
285
- - spec/lib/roqua/core_api/sessions/oauth_session_spec.rb
286
- - spec/lib/roqua/core_api/sessions/token_session_spec.rb
287
- - spec/lib/roqua/core_api/update_dossier_spec.rb
288
- - spec/spec_helper.rb
289
- - spec/support/httpparty_helpers.rb
236
+ test_files: []
data/.document DELETED
@@ -1,3 +0,0 @@
1
- -
2
- ChangeLog.md
3
- LICENSE.txt
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- Gemfile.lock
2
- doc/
3
- pkg/
4
- vendor/cache/*.gem
5
- .yardoc
6
- .bundle/*
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --colour --format documentation
data/.yardopts DELETED
@@ -1,2 +0,0 @@
1
- --markup markdown --title "core_api Documentation" --protected
2
- - 'config/locales/validation_errors.yml'
data/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
- gem 'httparty', '= 0.14.0'
5
- gem 'omniauth-oauth2', '= 1.1.0'
6
- gem 'virtus', '= 1.0.0'
7
-
8
- group :development do
9
- gem 'kramdown'
10
- end
11
-
12
- group :test do
13
- gem 'guard', '~> 2.6'
14
- gem 'guard-rspec', '~> 4.2'
15
- gem 'fuubar', '~> 2.0'
16
- end
data/Guardfile DELETED
@@ -1,4 +0,0 @@
1
- guard :rspec, failed_mode: 'none', all_after_pass: false, all_on_start: false, cmd: 'bundle exec rspec --format Fuubar --colour' do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- end
data/Rakefile DELETED
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
-
5
- begin
6
- require 'bundler'
7
- rescue LoadError => e
8
- warn e.message
9
- warn "Run `gem install bundler` to install Bundler."
10
- exit(-1)
11
- end
12
-
13
- begin
14
- Bundler.setup(:development)
15
- rescue Bundler::BundlerError => e
16
- warn e.message
17
- warn "Run `bundle install` to install missing gems."
18
- exit e.status_code
19
- end
20
-
21
- require 'rake'
22
-
23
- require 'rspec/core/rake_task'
24
- RSpec::Core::RakeTask.new
25
-
26
- task test: :spec
27
- task default: :spec
28
-
29
- # run bundle in parent dir to update Gemfile.lock
30
- task :release do
31
- Bundler.with_clean_env do
32
- `bundle --gemfile=../Gemfile`
33
- end
34
- `git add ../Gemfile.lock && git commit -m 'update roqua-core-api in Gemfile.lock'`
35
- end
36
-
37
- require "bundler/gem_tasks"
38
-
39
- require 'yard'
40
- YARD::Rake::YardocTask.new
41
- task doc: :yard
data/core_api.gemspec DELETED
@@ -1,32 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require File.expand_path('../lib/roqua/core_api/version', __FILE__)
4
-
5
- Gem::Specification.new do |gem|
6
- gem.name = "roqua-core-api"
7
- gem.version = Roqua::CoreApi::VERSION
8
- gem.summary = %q{API wrapper gem around Core's API}
9
- gem.description = %q{Provides authenticated access to Core}
10
- gem.license = "MIT"
11
- gem.authors = ["Marten Veldthuis"]
12
- gem.email = "marten@veldthuis.com"
13
- gem.homepage = "https://github.com/roqua/core/blob/master/core_api/README.markdown"
14
-
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ['lib']
19
-
20
- gem.add_dependency 'httparty', '~> 0.14.0'
21
- gem.add_dependency 'active_interaction', '~> 3.2'
22
- gem.add_dependency 'omniauth-oauth2', '~> 1.1'
23
- gem.add_dependency 'virtus', '~> 1.0'
24
-
25
- gem.add_development_dependency 'bundler', '~> 1.0'
26
- gem.add_development_dependency 'rake', '~> 10.0'
27
- gem.add_development_dependency 'yard', '~> 0.8'
28
- gem.add_development_dependency 'rspec', '~> 3.0'
29
- gem.add_development_dependency 'fabrication', '~> 2.9'
30
- gem.add_development_dependency 'webmock', '~> 1.17'
31
- gem.add_development_dependency 'dotenv', '~> 0.10'
32
- end
@@ -1,38 +0,0 @@
1
- module Roqua
2
- module CoreApi
3
- module Sessions
4
- class OAuthSession < AuthSession
5
- attr_reader :access_token
6
-
7
- def initialize(access_token:, **additional_arguments)
8
- @access_token = access_token
9
- super additional_arguments
10
- end
11
-
12
- def logout_url(return_to:)
13
- "#{core_site}/session/destroy?token=#{access_token}&return_to=#{CGI.escape return_to}"
14
- end
15
-
16
- # ping the server to check if session is still valid.
17
- # Will throw NoSession as usual if not.
18
- def ping
19
- get "/ping"
20
- end
21
-
22
- private
23
-
24
- def access_denied(response)
25
- if response['no_session']
26
- fail NoSession
27
- else
28
- fail Unauthorized
29
- end
30
- end
31
-
32
- def headers(_request_method, _path, _params)
33
- {"Authorization" => "Bearer #{access_token}"}
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,12 +0,0 @@
1
- require 'omniauth-oauth2'
2
- require 'roqua/omniauth/strategies/doorkeeper'
3
-
4
- OmniAuth.config.logger = Rails.logger
5
-
6
- Rails.application.config.middleware.use OmniAuth::Builder do
7
- provider :doorkeeper,
8
- ENV.fetch('CORE_OAUTH_CLIENT_ID'),
9
- ENV.fetch('CORE_OAUTH_CLIENT_SECRET'),
10
- client_options: {site: ENV.fetch('CORE_SITE')},
11
- authorize_params: {organization_id: ENV['CORE_ORGANIZATION']}
12
- end
@@ -1,25 +0,0 @@
1
- module OmniAuth
2
- module Strategies
3
- class Doorkeeper < OmniAuth::Strategies::OAuth2
4
- option :name, :doorkeeper
5
- option :client_options, site: 'http://core.dev',
6
- authorize_path: '/oauth/authorize'
7
-
8
- uid do
9
- raw_info["id"]
10
- end
11
-
12
- info do
13
- {dossier_id: raw_info['dossier_id'],
14
- username: raw_info['username'],
15
- role: raw_info['role'],
16
- person_id: raw_info['person_id'],
17
- dossier_groups: raw_info['dossier_groups']}
18
- end
19
-
20
- def raw_info
21
- @raw_info ||= access_token.get('/api/v1/me.json').parsed['me']
22
- end
23
- end
24
- end
25
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Roqua::CoreApi do
4
- it "should have a VERSION constant" do
5
- expect(subject.const_get('VERSION')).to_not be_empty
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- Fabricator(:roqua_core_api_auth_session, from: Roqua::CoreApi::Sessions::AuthSession) do
2
- initialize_with { Roqua::CoreApi::Sessions::AuthSession.new core_site: 'http://core.dev' }
3
- end
4
-
5
- Fabricator(:roqua_core_api_token_session, from: Roqua::CoreApi::Sessions::TokenSession) do
6
- initialize_with do
7
- Roqua::CoreApi::Sessions::TokenSession.new access_token: 'some_access_token', core_site: 'http://core.dev'
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- Fabricator(:roqua_core_api_basic_auth_session, from: Roqua::CoreApi::Sessions::BasicAuthSession) do
2
- initialize_with do
3
- Roqua::CoreApi::Sessions::BasicAuthSession.new username: 'some_username',
4
- password: 'some_password',
5
- core_site: 'http://core.dev'
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- Fabricator(:roqua_core_api_dossier, from: Roqua::CoreApi::Models::Dossier) do
2
- initialize_with { Roqua::CoreApi::Models::Dossier.new }
3
- id 'dossier-id'
4
- external_identifier 'external-dossier-identifier'
5
- end
@@ -1,5 +0,0 @@
1
- Fabricator(:roqua_core_api_oauth_session, from: Roqua::CoreApi::Sessions::OAuthSession) do
2
- initialize_with do
3
- Roqua::CoreApi::Sessions::OAuthSession.new access_token: 'some_access_token', core_site: 'http://core.dev'
4
- end
5
- end
@@ -1,7 +0,0 @@
1
- Fabricator(:roqua_core_api_person, from: Roqua::CoreApi::Models::Dossier) do
2
- initialize_with { Roqua::CoreApi::Models::Person.new }
3
- firstname 'John'
4
- lastname 'Doe'
5
- role 'patient'
6
- email { sequence(:email) { |i| "test#{i}@roqua.nl" } }
7
- end
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
- require 'webmock/rspec'
3
-
4
- describe OAuthSession do
5
- let(:session) { Fabricate :roqua_core_api_oauth_session }
6
- let(:response) { double('response', code: 201, parsed_response: 'some_response') }
7
-
8
- describe '#initialize' do
9
- it 'sets the access_token instance variable' do
10
- session = Roqua::CoreApi.oauth_session access_token: 'some_access_token'
11
- expect(session.access_token).to eq('some_access_token')
12
- end
13
-
14
- it 'allows to override the core_site variable' do
15
- session = Roqua::CoreApi.oauth_session access_token: 'some_access_token', core_site: 'some_core_site'
16
- expect(session.core_site).to eq('some_core_site')
17
- end
18
-
19
- it 'defaults the AuthSession core_site CORE_SITE env variable default value' do
20
- original_env_core_site = ENV['CORE_SITE']
21
- ENV['CORE_SITE'] = 'some_env_core_site'
22
- session = Roqua::CoreApi.oauth_session access_token: 'some_access_token'
23
- ENV['CORE_SITE'] = original_env_core_site
24
- expect(session.core_site).to eq('some_env_core_site')
25
- end
26
- end
27
-
28
- describe '#logout_url' do
29
- it 'returns the oauth session destroy url with an escaped redirect_to parameter' do
30
- expect(session.logout_url return_to: 'some redirect to')
31
- .to eq('http://core.dev/session/destroy?token=some_access_token&return_to=some+redirect+to')
32
- end
33
- end
34
-
35
- describe 'headers' do
36
- it 'sets the Authorization header' do
37
- expect(HTTParty).to receive(:get).with(an_instance_of(String),
38
- headers: {"Authorization" => "Bearer some_access_token"},
39
- query: {},
40
- basic_auth: nil,
41
- timeout: nil).and_return(response)
42
- session.get 'some_path'
43
- end
44
- end
45
-
46
- describe '#access_denied' do
47
- it 'raises a no_session error when response is 401 with a no_session response' do
48
- stub_request(:get, 'http://core.dev/api/v1/some_path.json?').to_return(
49
- status: 401,
50
- body: '{ "no_session": true }',
51
- headers: { 'Content-Type' => 'application/json' })
52
- expect { session.get '/some_path' }.to raise_error(NoSession)
53
- end
54
-
55
- it 'raises a unauthorized error when response is 401 without a no_session response' do
56
- stub_request(:get, 'http://core.dev/api/v1/some_path.json?').to_return(
57
- status: 401,
58
- body: '',
59
- headers: { 'Content-Type' => 'application/json' })
60
- expect { session.get '/some_path' }.to raise_error(Unauthorized)
61
- end
62
- end
63
- end
data/spec/spec_helper.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'rspec'
2
- require 'fabrication'
3
-
4
- require 'dotenv'
5
- Dotenv.load(File.expand_path("../../.env", File.dirname(__FILE__)))
6
-
7
- require 'roqua-core-api'
8
- include Roqua::CoreApi
9
- include Roqua::CoreApi::Sessions
10
- include Roqua::CoreApi::Models
11
-
12
- Dir[File.join(File.expand_path(File.dirname(__FILE__)), 'support', '*.rb')].each { |f| require f }
13
-
14
- I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__)), '..', 'config', 'locales', '*.yml')]
15
- I18n.enforce_available_locales = false
16
- I18n.default_locale = :nl
@@ -1,5 +0,0 @@
1
- def httparty_response(response_data, code = 200)
2
- allow(response_data).to receive(:code).and_return code
3
- allow(response_data).to receive(:parsed_response).and_return response_data
4
- response_data
5
- end