lifen 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile.lock +16 -16
  4. data/README.md +0 -77
  5. data/lib/lifen.rb +0 -11
  6. data/lib/lifen/configuration.rb +3 -1
  7. data/lib/lifen/token.rb +7 -2
  8. data/lib/lifen/user.rb +0 -11
  9. data/lib/lifen/version.rb +1 -1
  10. data/spec/token_spec.rb +37 -13
  11. metadata +2 -41
  12. data/lib/lifen/attachment.rb +0 -26
  13. data/lib/lifen/binary.rb +0 -31
  14. data/lib/lifen/category.rb +0 -26
  15. data/lib/lifen/channel.rb +0 -31
  16. data/lib/lifen/communication_request.rb +0 -67
  17. data/lib/lifen/content_string.rb +0 -15
  18. data/lib/lifen/medium.rb +0 -17
  19. data/lib/lifen/patient.rb +0 -27
  20. data/lib/lifen/practitioner.rb +0 -97
  21. data/spec/binary_spec.rb +0 -29
  22. data/spec/cassettes/binary/download/invalid.yml +0 -65
  23. data/spec/cassettes/binary/download/valid.yml +0 -1320
  24. data/spec/cassettes/communication_request/send/invalid_medium.yml +0 -69
  25. data/spec/cassettes/communication_request/send/valid_attributes.yml +0 -75
  26. data/spec/cassettes/communication_request/send/valid_attributes_binary.yml +0 -74
  27. data/spec/cassettes/practitionner/create_channel/address/old_valid_attributes.yml +0 -71
  28. data/spec/cassettes/practitionner/create_channel/address/valid_attributes.yml +0 -71
  29. data/spec/cassettes/practitionner/create_channel/telecom/valid_attributes.yml +0 -70
  30. data/spec/cassettes/practitionner/find_by_rpps/existing_rpps.yml +0 -125
  31. data/spec/cassettes/practitionner/find_by_rpps/missing_line_attribute.yml +0 -122
  32. data/spec/cassettes/practitionner/find_by_rpps/wrong_rpps.yml +0 -68
  33. data/spec/category_spec.rb +0 -21
  34. data/spec/communication_request_spec.rb +0 -64
  35. data/spec/practitionner_spec.rb +0 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79deed444977cb5560f104a1507ad85d3f7066fa
4
- data.tar.gz: ca4895e8cf1356a51d01661e18acfd3d4e52e8a6
3
+ metadata.gz: 4bd1233dcbd537aaa00f92d9d557d7a975341d30
4
+ data.tar.gz: 9e8d5cb3f5412e859fe3625e8053c0caf7f8ab40
5
5
  SHA512:
6
- metadata.gz: f9a0a0d34c22b03898a17af6b078693e31d5d512073c1d7c35874d931d0c64e94743d3a8d584d8e388b8f597c03b9abfc333d3e2e5e82d831a2a33f17997b7f6
7
- data.tar.gz: 813dc3995c10b1d70f4bf9fccb3190cd7dc2b0757ca1d401bc312552c835ff929160af47467dd2eee0b55be2079eea33ae1180f56df3706c08066c0ad9b2e62c
6
+ metadata.gz: bf7d49d1777e98a42d017f31dfe8e4ecf803a77daca3388a406171ceded5a1f61da7a69e52d3af53868c6a18fc75ab367ccad17097683f571e54978939248e52
7
+ data.tar.gz: 249e90557b597e25d625289c82d3f631e5ed31e889b897d5aceefd60fb91922f3dc72906ee0630741d4da66a02de8136cddb4697e1f9b0391647f4ddc273c4f7
@@ -1,3 +1,8 @@
1
+ 4.0.0
2
+ -----
3
+
4
+ Removed all FHIR endpoints
5
+
1
6
  3.0.0
2
7
  -----
3
8
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lifen (3.0.0)
4
+ lifen (4.0.0)
5
5
  faraday (>= 0.9)
6
6
  inflecto
7
7
  virtus (>= 1.0)
@@ -9,9 +9,9 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.5.0)
12
+ addressable (2.5.1)
13
13
  public_suffix (~> 2.0, >= 2.0.2)
14
- awesome_print (1.7.0)
14
+ awesome_print (1.8.0)
15
15
  axiom-types (0.1.1)
16
16
  descendants_tracker (~> 0.0.4)
17
17
  ice_nine (~> 0.11.0)
@@ -24,27 +24,27 @@ GEM
24
24
  thread_safe (~> 0.3, >= 0.3.1)
25
25
  diff-lcs (1.3)
26
26
  equalizer (0.0.11)
27
- faraday (0.11.0)
27
+ faraday (0.12.1)
28
28
  multipart-post (>= 1.2, < 3)
29
- hashdiff (0.3.2)
29
+ hashdiff (0.3.4)
30
30
  ice_nine (0.11.2)
31
31
  inflecto (0.0.2)
32
32
  multipart-post (2.0.0)
33
33
  public_suffix (2.0.5)
34
34
  rake (10.5.0)
35
- rspec (3.5.0)
36
- rspec-core (~> 3.5.0)
37
- rspec-expectations (~> 3.5.0)
38
- rspec-mocks (~> 3.5.0)
39
- rspec-core (3.5.4)
40
- rspec-support (~> 3.5.0)
41
- rspec-expectations (3.5.0)
35
+ rspec (3.6.0)
36
+ rspec-core (~> 3.6.0)
37
+ rspec-expectations (~> 3.6.0)
38
+ rspec-mocks (~> 3.6.0)
39
+ rspec-core (3.6.0)
40
+ rspec-support (~> 3.6.0)
41
+ rspec-expectations (3.6.0)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.5.0)
44
- rspec-mocks (3.5.0)
43
+ rspec-support (~> 3.6.0)
44
+ rspec-mocks (3.6.0)
45
45
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.5.0)
47
- rspec-support (3.5.0)
46
+ rspec-support (~> 3.6.0)
47
+ rspec-support (3.6.0)
48
48
  safe_yaml (1.0.4)
49
49
  thread_safe (0.3.6)
50
50
  vcr (3.0.3)
data/README.md CHANGED
@@ -128,83 +128,6 @@ message = Lifen::Message.new(flow: flow, content: "Hello World !")
128
128
  message.create
129
129
  ```
130
130
 
131
- ### FHIR examples
132
-
133
- #### Managing a Binary
134
-
135
- ```ruby
136
- binary = Lifen::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276")
137
- binary.download
138
- ```
139
-
140
- #### Communications with an Attachment
141
-
142
- ```ruby
143
- sender = Lifen::Practitioner.find_by_rpps("899900018483")
144
-
145
- recipient = Lifen::Practitioner.find_by_rpps("899900018484")
146
- channel = recipient.channels.first
147
-
148
- category = Lifen::Category.new(code: "MEDICAL_REPORT") # default case, optionnal element
149
-
150
- attachment = Lifen::Attachment.new(title: "Test document", path: "path/to/file")
151
-
152
- patient = Lifen::Patient.new(first_name: "Jean", last_name: "Dupond", birthdate: Date.new(2000,1,1))
153
-
154
- communication_request = Lifen::CommunicationRequest.new(sender: sender, recipient: recipient, channel: channel, attachment: attachment, patient: patient, category: category)
155
- communication_request.send
156
-
157
- communication_request = Lifen::CommunicationRequest.find("valid-communication_request-uuid")
158
- communication_request.status
159
- ```
160
-
161
- ### Communications with a Binary
162
-
163
- ```ruby
164
- sender = Lifen::Practitioner.find_by_rpps("899900018483")
165
-
166
- recipient = Lifen::Practitioner.find_by_rpps("899900018484")
167
- channel = recipient.channels.first
168
-
169
- binary = Lifen::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276")
170
-
171
- communication_request = Lifen::CommunicationRequest.new(sender: sender, recipient: recipient, channel: channel, binary: binary, patient: patient, category: category)
172
-
173
- communication_request.send
174
-
175
- ```
176
-
177
- #### Communication requets with multiple recipients
178
-
179
- ```ruby
180
- sender = Lifen::Practitioner.find_by_rpps("899900018483")
181
-
182
- recipient = Lifen::Practitioner.find_by_rpps("899900018484")
183
- medium = Lifen::Medium(uuid: recipient.channels.first.uuid)
184
-
185
- other_recipient = Lifen::Practitioner.find_by_rpps("899900018484")
186
- other_medium = Lifen::Medium(uuid: other_recipient.channels.first.uuid)
187
-
188
- binary = Lifen::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276")
189
-
190
- communication_request_request = Lifen::CommunicationRequest.new(sender: sender, recipients: [recipient, other_recipient], medium: [medium, other_medium], binary: binary, patient: patient, category: category)
191
-
192
- communication_request_request.send
193
-
194
- ```
195
-
196
- #### Custom Channels management
197
-
198
- ```ruby
199
- recipient = Lifen::Practitioner.new(uuid: "valid-user-uuid")
200
-
201
- # To create a new mailing address channel
202
- channel = recipient.create_address(type: "address", lines: ["39 rue Aboukir"], city: "Paris", postal_code: "75002", country: "France")
203
-
204
- # To create a new telecom channel fax
205
- channel = recipient.create_telecom(type: "telecom", system: "fax", value: "+33102030405")
206
- ```
207
-
208
131
  ## Deploying to Rubygems
209
132
 
210
133
  Once the new version is validated, the deployment follows those steps :
@@ -3,7 +3,6 @@ module Lifen
3
3
  require 'virtus'
4
4
  require 'faraday'
5
5
  require 'inflecto'
6
- require 'base64'
7
6
 
8
7
  require "lifen/version"
9
8
 
@@ -22,16 +21,6 @@ module Lifen
22
21
  require 'lifen/flows'
23
22
  require 'lifen/message'
24
23
 
25
- require 'lifen/channel'
26
- require 'lifen/practitioner'
27
- require 'lifen/category'
28
- require 'lifen/medium'
29
- require 'lifen/attachment'
30
- require 'lifen/binary'
31
- require 'lifen/patient'
32
- require 'lifen/content_string'
33
- require 'lifen/communication_request'
34
-
35
24
  Virtus.finalize
36
25
 
37
26
  end
@@ -1,11 +1,13 @@
1
1
  module Lifen
2
2
  class Configuration
3
- attr_accessor :site, :application_access_token, :proxy_url, :expiration_margin
3
+ attr_accessor :site, :application_access_token, :proxy_url, :expiration_margin, :token_refresh_lock
4
4
 
5
5
  def initialize(args)
6
6
  args.each do |k,v|
7
7
  instance_variable_set("@#{k}", v) unless v.nil?
8
8
  end
9
+
10
+ @token_refresh_lock = Mutex.new
9
11
  end
10
12
 
11
13
  def site=(url)
@@ -1,7 +1,11 @@
1
1
  module Lifen
2
2
  class Token
3
3
 
4
- @@refresh_lock = Mutex.new
4
+ # def self.refresh_lock
5
+ # @refresh_lock ||= Mutex.new
6
+ # end
7
+
8
+ # @@refresh_lock = Mutex.new
5
9
 
6
10
  include Virtus.model(finalize: false)
7
11
 
@@ -45,11 +49,12 @@ module Lifen
45
49
  end
46
50
 
47
51
  def refresh_once_if_needed
48
- @@refresh_lock.synchronize do
52
+ Lifen.configuration.token_refresh_lock.synchronize do
49
53
 
50
54
  load_from_db.call(self) if load_from_db.is_a? Proc
51
55
 
52
56
  return if active?
57
+
53
58
  refresh
54
59
 
55
60
  save_to_db.call(self) if save_to_db.is_a? Proc
@@ -5,7 +5,6 @@ module Lifen
5
5
  attribute :token, "Lifen::Token"
6
6
  attribute :status, "Lifen::Status"
7
7
  attribute :settings, "Lifen::Settings"
8
- attribute :channels, ["Lifen::Channel"]
9
8
 
10
9
  attribute :uuid, String
11
10
  attribute :email, String
@@ -101,16 +100,6 @@ module Lifen
101
100
  UserAuthenticatedClient.new(token)
102
101
  end
103
102
 
104
- # def self.where(params)
105
- # json = application_client.get("fhir/Practitioner/", params)
106
-
107
- # users = []
108
-
109
- # users << new(user_json)
110
-
111
- # users
112
- # end
113
-
114
103
 
115
104
  private
116
105
 
@@ -1,3 +1,3 @@
1
1
  module Lifen
2
- VERSION = "3.0.0"
2
+ VERSION = "4.0.0"
3
3
  end
@@ -82,6 +82,7 @@ describe Lifen::Token do
82
82
 
83
83
  let(:user) { Lifen::User.new }
84
84
  let(:persisted_user) { TokenPersistedUser.new("expired_token", Time.now.to_i - 60) }
85
+ let(:perstiting) { double("Persisting") }
85
86
 
86
87
  let(:expired_token) {
87
88
  Lifen::Token.new( user: user,
@@ -90,14 +91,20 @@ describe Lifen::Token do
90
91
  load_from_db: ->(token) {
91
92
  # Loading data from DB
92
93
 
94
+ sleep 0.5
95
+
93
96
  token.value = persisted_user.token_value
94
97
  token.expires_at = persisted_user.token_expires_at
95
98
  },
96
99
  save_to_db: ->(token) {
97
100
  # Saving data to DB
98
101
 
102
+ # ap "saving to db on expired token #{token.expires_at}"
103
+
99
104
  persisted_user.token_value = token.value
100
105
  persisted_user.token_expires_at = token.expires_at
106
+
107
+ perstiting.persist
101
108
  }
102
109
  ) }
103
110
 
@@ -109,35 +116,52 @@ describe Lifen::Token do
109
116
  load_from_db: ->(token) {
110
117
  # Loading data from DB
111
118
 
119
+ sleep 0.5
120
+
112
121
  token.value = persisted_user.token_value
113
122
  token.expires_at = persisted_user.token_expires_at
123
+ },
124
+ save_to_db: ->(token) {
125
+ # Saving data to DB
126
+ # ap "saving to db on other expired token #{token.expires_at}"
127
+
128
+ persisted_user.token_value = token.value
129
+ persisted_user.token_expires_at = token.expires_at
130
+
131
+ perstiting.persist
114
132
  }
115
133
  ) }
116
134
 
117
135
  before do
118
136
  allow(expired_token).to receive(:refresh) do
119
137
  expired_token.value = "valid_token"
120
- expired_token.expires_at = Time.now.to_i + 60
138
+ expired_token.expires_at = Time.now.to_i + 180
139
+ end
140
+
141
+ allow(other_expired_token).to receive(:refresh) do
142
+ other_expired_token.value = "valid_token"
143
+ other_expired_token.expires_at = Time.now.to_i + 180
121
144
  end
122
145
  end
123
146
 
124
- it 'queues refresh calls' do
125
- expect(expired_token).to receive(:refresh).once
126
- expect(other_expired_token).to_not receive(:refresh)
147
+ 15.times do
148
+ it 'queues refresh calls' do
149
+ expect(perstiting).to receive(:persist).once
127
150
 
128
- threads = []
151
+ threads = []
129
152
 
130
- threads << Thread.new do
131
- expired_token.refresh_once_if_needed
132
- end
153
+ threads << Thread.new do
154
+ expired_token.refresh_once_if_needed
155
+ end
133
156
 
134
- sleep 0.1 # Making sure the mocked call is received first
157
+ # sleep 0.1 # Making sure the mocked call is received first
135
158
 
136
- threads << Thread.new do
137
- other_expired_token.refresh_once_if_needed
138
- end
159
+ threads << Thread.new do
160
+ other_expired_token.refresh_once_if_needed
161
+ end
139
162
 
140
- threads.map { |t| t.join } # waiting for all threads to finish
163
+ threads.map { |t| t.join } # waiting for all threads to finish
164
+ end
141
165
  end
142
166
 
143
167
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lifen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Etienne Depaulis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,22 +154,13 @@ files:
154
154
  - Rakefile
155
155
  - lib/lifen.rb
156
156
  - lib/lifen/app_authenticated_client.rb
157
- - lib/lifen/attachment.rb
158
157
  - lib/lifen/base.rb
159
- - lib/lifen/binary.rb
160
- - lib/lifen/category.rb
161
- - lib/lifen/channel.rb
162
158
  - lib/lifen/client.rb
163
- - lib/lifen/communication_request.rb
164
159
  - lib/lifen/configuration.rb
165
- - lib/lifen/content_string.rb
166
160
  - lib/lifen/error.rb
167
161
  - lib/lifen/flow.rb
168
162
  - lib/lifen/flows.rb
169
- - lib/lifen/medium.rb
170
163
  - lib/lifen/message.rb
171
- - lib/lifen/patient.rb
172
- - lib/lifen/practitioner.rb
173
164
  - lib/lifen/settings.rb
174
165
  - lib/lifen/status.rb
175
166
  - lib/lifen/token.rb
@@ -177,12 +168,6 @@ files:
177
168
  - lib/lifen/user_authenticated_client.rb
178
169
  - lib/lifen/version.rb
179
170
  - lifen.gemspec
180
- - spec/binary_spec.rb
181
- - spec/cassettes/binary/download/invalid.yml
182
- - spec/cassettes/binary/download/valid.yml
183
- - spec/cassettes/communication_request/send/invalid_medium.yml
184
- - spec/cassettes/communication_request/send/valid_attributes.yml
185
- - spec/cassettes/communication_request/send/valid_attributes_binary.yml
186
171
  - spec/cassettes/flows/attach_users/invalid_flow_uuid.yml
187
172
  - spec/cassettes/flows/attach_users/invalid_user_uuid.yml
188
173
  - spec/cassettes/flows/attach_users/valid.yml
@@ -195,12 +180,6 @@ files:
195
180
  - spec/cassettes/flows/update_valid_title.yml
196
181
  - spec/cassettes/flows/valid_token.yml
197
182
  - spec/cassettes/messages/valid_message.yml
198
- - spec/cassettes/practitionner/create_channel/address/old_valid_attributes.yml
199
- - spec/cassettes/practitionner/create_channel/address/valid_attributes.yml
200
- - spec/cassettes/practitionner/create_channel/telecom/valid_attributes.yml
201
- - spec/cassettes/practitionner/find_by_rpps/existing_rpps.yml
202
- - spec/cassettes/practitionner/find_by_rpps/missing_line_attribute.yml
203
- - spec/cassettes/practitionner/find_by_rpps/wrong_rpps.yml
204
183
  - spec/cassettes/settings/initial_state.yml
205
184
  - spec/cassettes/settings/reload.yml
206
185
  - spec/cassettes/settings/update.yml
@@ -221,12 +200,9 @@ files:
221
200
  - spec/cassettes/users/status/reload/valid_token.yml
222
201
  - spec/cassettes/users/token/refresh/invalid_user_uuid.yml
223
202
  - spec/cassettes/users/token/refresh/valid_user_uuid.yml
224
- - spec/category_spec.rb
225
- - spec/communication_request_spec.rb
226
203
  - spec/configuration_spec.rb
227
204
  - spec/flow_spec.rb
228
205
  - spec/message_spec.rb
229
- - spec/practitionner_spec.rb
230
206
  - spec/settings_spec.rb
231
207
  - spec/spec_helper.rb
232
208
  - spec/support/master_plan.pdf
@@ -257,12 +233,6 @@ signing_key:
257
233
  specification_version: 4
258
234
  summary: Lifen JSON API ruby client
259
235
  test_files:
260
- - spec/binary_spec.rb
261
- - spec/cassettes/binary/download/invalid.yml
262
- - spec/cassettes/binary/download/valid.yml
263
- - spec/cassettes/communication_request/send/invalid_medium.yml
264
- - spec/cassettes/communication_request/send/valid_attributes.yml
265
- - spec/cassettes/communication_request/send/valid_attributes_binary.yml
266
236
  - spec/cassettes/flows/attach_users/invalid_flow_uuid.yml
267
237
  - spec/cassettes/flows/attach_users/invalid_user_uuid.yml
268
238
  - spec/cassettes/flows/attach_users/valid.yml
@@ -275,12 +245,6 @@ test_files:
275
245
  - spec/cassettes/flows/update_valid_title.yml
276
246
  - spec/cassettes/flows/valid_token.yml
277
247
  - spec/cassettes/messages/valid_message.yml
278
- - spec/cassettes/practitionner/create_channel/address/old_valid_attributes.yml
279
- - spec/cassettes/practitionner/create_channel/address/valid_attributes.yml
280
- - spec/cassettes/practitionner/create_channel/telecom/valid_attributes.yml
281
- - spec/cassettes/practitionner/find_by_rpps/existing_rpps.yml
282
- - spec/cassettes/practitionner/find_by_rpps/missing_line_attribute.yml
283
- - spec/cassettes/practitionner/find_by_rpps/wrong_rpps.yml
284
248
  - spec/cassettes/settings/initial_state.yml
285
249
  - spec/cassettes/settings/reload.yml
286
250
  - spec/cassettes/settings/update.yml
@@ -301,12 +265,9 @@ test_files:
301
265
  - spec/cassettes/users/status/reload/valid_token.yml
302
266
  - spec/cassettes/users/token/refresh/invalid_user_uuid.yml
303
267
  - spec/cassettes/users/token/refresh/valid_user_uuid.yml
304
- - spec/category_spec.rb
305
- - spec/communication_request_spec.rb
306
268
  - spec/configuration_spec.rb
307
269
  - spec/flow_spec.rb
308
270
  - spec/message_spec.rb
309
- - spec/practitionner_spec.rb
310
271
  - spec/settings_spec.rb
311
272
  - spec/spec_helper.rb
312
273
  - spec/support/master_plan.pdf