lifen 1.1.0 → 1.2.0

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: 48d8b72c4e7250d82b16d02e3f58f1f160e06289
4
- data.tar.gz: ea331938beaafdf10c457464a141b77af6c71713
3
+ metadata.gz: 892ab61ff3b07c5171f3627d98eebcf2ec772a87
4
+ data.tar.gz: eaadb00f864025512401a0f095d4f162f6e710c3
5
5
  SHA512:
6
- metadata.gz: bf51797de230eb1f6abc04cf09e858d8d72461eaed547919b4d3e7f04164209e8fc5fb272e3194e30ad583bee3d746988efecb169ba02b093db304c286b8ddf0
7
- data.tar.gz: 2d855c4608cd0c93bda9b4d3fe47079d959f9986531e9e08f66fa095cd23cdb5ed35f7d6fbab214c280c50b3b64f43f5eec08af20b5205abb4ff0ce9cf79350d
6
+ metadata.gz: 458453b20d8211dc2bf8a0369ab3a3683f4a68cc5a289e8cac6c35c9f10d4127e98036258092f3ac6a76526d933904e1544fed7405031c8c0910aa782312f8d7
7
+ data.tar.gz: 7c6f77974e97e926cbb934aaf9b5874c7570baca6ac6db9482b33ea22a286dd55ae7f6f6d050f79ff17c69ffaacdc4ccfc9d9613c9fb3cafdcf8e9c2534a60ff
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.2.0
2
+ -----
3
+
4
+ - Added user settings management
5
+
1
6
  1.1.0
2
7
  -----
3
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lifen (1.1.0)
4
+ lifen (1.2.0)
5
5
  faraday (>= 0.9)
6
6
  inflecto
7
7
  virtus (>= 1.0)
data/README.md CHANGED
@@ -28,9 +28,9 @@ Lifen can be configured (ideally inside an initializer) like so:
28
28
  Lifen.configure do |config|
29
29
  config.site = "https://develop.lifen.fr/"
30
30
  config.application_access_token = "application_access_token"
31
-
31
+
32
32
  # optionnal
33
- config.proxy_url = "http://my.proxy.fr/"
33
+ config.proxy_url = "http://my.proxy.fr/"
34
34
  config.expiration_margin = 60 # in seconds, default: 0
35
35
  end
36
36
  ```
@@ -49,6 +49,16 @@ user.token.refresh
49
49
  user.status.refresh
50
50
  ```
51
51
 
52
+ ### Managing users' settings
53
+
54
+ ```ruby
55
+ user.settings
56
+ user.settings.refresh
57
+ user.settings.push_notifications
58
+ user.settings.push_notifications = false
59
+ user.settings.save
60
+ ```
61
+
52
62
  ### Managing flows
53
63
 
54
64
  ```ruby
data/lib/lifen.rb CHANGED
@@ -14,6 +14,7 @@ module Lifen
14
14
  require 'lifen/base'
15
15
  require 'lifen/token'
16
16
  require 'lifen/status'
17
+ require 'lifen/settings'
17
18
  require 'lifen/user'
18
19
  require 'lifen/flow'
19
20
  require 'lifen/flows'
@@ -0,0 +1,41 @@
1
+ module Lifen
2
+ class Settings
3
+
4
+ include Virtus.model(finalize: false)
5
+
6
+ attribute :user, "Lifen::User"
7
+
8
+ attribute :email_notifications, Boolean
9
+ attribute :push_notifications, Boolean
10
+
11
+ def refresh
12
+ json = client.get("central/api/settings")
13
+
14
+ load_from_json(json)
15
+
16
+ self
17
+ end
18
+
19
+ def save
20
+ params = {"emailNotifications" => email_notifications, "pushNotifications" => push_notifications}
21
+
22
+ json = client.post("central/api/settings", params)
23
+
24
+ load_from_json(json)
25
+
26
+ self
27
+ end
28
+
29
+ private
30
+
31
+ def client
32
+ @client ||= user.client
33
+ end
34
+
35
+ def load_from_json(json)
36
+ self.email_notifications = json["emailNotifications"]
37
+ self.push_notifications = json["pushNotifications"]
38
+ end
39
+
40
+ end
41
+ end
data/lib/lifen/user.rb CHANGED
@@ -2,8 +2,9 @@ module Lifen
2
2
  class User
3
3
  include Virtus.model(finalize: false)
4
4
 
5
- attribute :token, "Lifen::Token"#, default: proc { Lifen::Token.new() }
5
+ attribute :token, "Lifen::Token"
6
6
  attribute :status, "Lifen::Status"
7
+ attribute :settings, "Lifen::Settings"
7
8
 
8
9
  attribute :uuid, String
9
10
  attribute :email, String
@@ -39,6 +40,10 @@ module Lifen
39
40
  @status ||= Lifen::Status.new(user: self)
40
41
  end
41
42
 
43
+ def settings
44
+ @settings ||= Lifen::Settings.new(user: self).refresh
45
+ end
46
+
42
47
  def client
43
48
  UserAuthenticatedClient.new(token)
44
49
  end
data/lib/lifen/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lifen
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://develop.lifen.fr/central/api/settings
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer
14
+ Content-Type:
15
+ - application/json
16
+ Accept:
17
+ - application/json
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - d422e101e6e70ba
31
+ X-B3-Traceid:
32
+ - d422e101e6e70ba
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ Cache-Control:
38
+ - no-cache, no-store, max-age=0, must-revalidate
39
+ Pragma:
40
+ - no-cache
41
+ Expires:
42
+ - '0'
43
+ Content-Type:
44
+ - application/json;charset=UTF-8
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Date:
48
+ - Mon, 19 Dec 2016 12:39:16 GMT
49
+ Connection:
50
+ - close
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"medicalReportSentDisplay":false,"dailyNotifications":false,"addPatientToRecipients":false,"popup":true,"fontSize":"small","realTimeNotifications":true,"weeklyNotifications":true,"emailNotifications":false,"medicalReportReception":"paperAndElectronic","sound":true,"pushNotifications":false}'
54
+ http_version:
55
+ recorded_at: Mon, 19 Dec 2016 12:38:30 GMT
56
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://develop.lifen.fr/central/api/settings
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer valid_token
14
+ Content-Type:
15
+ - application/json
16
+ Accept:
17
+ - application/json
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - a64ddec53d7f3e6c
31
+ X-B3-Traceid:
32
+ - a64ddec53d7f3e6c
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ Cache-Control:
38
+ - no-cache, no-store, max-age=0, must-revalidate
39
+ Pragma:
40
+ - no-cache
41
+ Expires:
42
+ - '0'
43
+ Content-Type:
44
+ - application/json;charset=UTF-8
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Date:
48
+ - Mon, 19 Dec 2016 12:41:02 GMT
49
+ Connection:
50
+ - close
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"medicalReportSentDisplay":false,"dailyNotifications":false,"addPatientToRecipients":false,"popup":true,"fontSize":"small","realTimeNotifications":true,"weeklyNotifications":true,"emailNotifications":false,"medicalReportReception":"paperAndElectronic","sound":true,"pushNotifications":true}'
54
+ http_version:
55
+ recorded_at: Mon, 19 Dec 2016 12:40:16 GMT
56
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/central/api/settings
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"emailNotifications":false,"pushNotifications":true}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer valid_token
14
+ Content-Type:
15
+ - application/json
16
+ Accept:
17
+ - application/json
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - e38446194e727bb8
31
+ X-B3-Traceid:
32
+ - e38446194e727bb8
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ Cache-Control:
38
+ - no-cache, no-store, max-age=0, must-revalidate
39
+ Pragma:
40
+ - no-cache
41
+ Expires:
42
+ - '0'
43
+ Content-Type:
44
+ - application/json;charset=UTF-8
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Date:
48
+ - Mon, 19 Dec 2016 12:41:00 GMT
49
+ Connection:
50
+ - close
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"medicalReportSentDisplay":false,"dailyNotifications":false,"addPatientToRecipients":false,"popup":true,"fontSize":"small","realTimeNotifications":true,"weeklyNotifications":true,"emailNotifications":false,"medicalReportReception":"paperAndElectronic","sound":true,"pushNotifications":true}'
54
+ http_version:
55
+ recorded_at: Mon, 19 Dec 2016 12:40:14 GMT
56
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lifen::Settings do
4
+
5
+ let(:valid_token_value) { "valid_token" }
6
+
7
+ let(:valid_token) { Lifen::Token.new(value: valid_token_value, expires_at: Time.now.to_i + 60) }
8
+
9
+ let(:user) { Lifen::User.new(uuid: "11e6c5e3-0702-ca3f-b073-0242ac110002", token: valid_token) }
10
+
11
+ describe 'integration scenario' do
12
+
13
+ it 'knows the the correct user settings' do
14
+ VCR.use_cassette "settings/initial_state" do
15
+ @settings = user.settings
16
+ end
17
+
18
+ expect(@settings.push_notifications).to be_falsy
19
+
20
+ @settings.push_notifications = true
21
+
22
+ VCR.use_cassette "settings/update" do
23
+ @settings.save
24
+ end
25
+
26
+ expect(@settings.push_notifications).to be_truthy
27
+
28
+ VCR.use_cassette "settings/refresh" do
29
+ @settings.refresh
30
+ end
31
+
32
+ expect(@settings.push_notifications).to be_truthy
33
+ end
34
+
35
+ end
36
+
37
+ 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: 1.1.0
4
+ version: 1.2.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: 2016-12-14 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -161,6 +161,7 @@ files:
161
161
  - lib/lifen/flow.rb
162
162
  - lib/lifen/flows.rb
163
163
  - lib/lifen/message.rb
164
+ - lib/lifen/settings.rb
164
165
  - lib/lifen/status.rb
165
166
  - lib/lifen/token.rb
166
167
  - lib/lifen/user.rb
@@ -178,6 +179,9 @@ files:
178
179
  - spec/cassettes/flows/invalid_token.yml
179
180
  - spec/cassettes/flows/valid_token.yml
180
181
  - spec/cassettes/messages/valid_message.yml
182
+ - spec/cassettes/settings/initial_state.yml
183
+ - spec/cassettes/settings/refresh.yml
184
+ - spec/cassettes/settings/update.yml
181
185
  - spec/cassettes/users/create/existing_user.yml
182
186
  - spec/cassettes/users/create/invalid_token.yml
183
187
  - spec/cassettes/users/create/missing_fields.yml
@@ -189,6 +193,7 @@ files:
189
193
  - spec/configuration_spec.rb
190
194
  - spec/flows_spec.rb
191
195
  - spec/messages_spec.rb
196
+ - spec/settings_spec.rb
192
197
  - spec/spec_helper.rb
193
198
  - spec/token_spec.rb
194
199
  - spec/users_spec.rb
@@ -228,6 +233,9 @@ test_files:
228
233
  - spec/cassettes/flows/invalid_token.yml
229
234
  - spec/cassettes/flows/valid_token.yml
230
235
  - spec/cassettes/messages/valid_message.yml
236
+ - spec/cassettes/settings/initial_state.yml
237
+ - spec/cassettes/settings/refresh.yml
238
+ - spec/cassettes/settings/update.yml
231
239
  - spec/cassettes/users/create/existing_user.yml
232
240
  - spec/cassettes/users/create/invalid_token.yml
233
241
  - spec/cassettes/users/create/missing_fields.yml
@@ -239,6 +247,7 @@ test_files:
239
247
  - spec/configuration_spec.rb
240
248
  - spec/flows_spec.rb
241
249
  - spec/messages_spec.rb
250
+ - spec/settings_spec.rb
242
251
  - spec/spec_helper.rb
243
252
  - spec/token_spec.rb
244
253
  - spec/users_spec.rb