lifen 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07a14dd0813fe91d0fe86a3347dbc0553ca2d3ce
4
- data.tar.gz: 4e539ba5ae948f39d3998c15cb3c17a3fa426da2
3
+ metadata.gz: 6adc4c05214d98c131b76fae1d12e1fee469adab
4
+ data.tar.gz: 4ad0289f54a54ae548ec0bb15ea246d4debab564
5
5
  SHA512:
6
- metadata.gz: 5429ce6b274cdb3a2499947d4db75f36d8942c2902eb3843c2ae41d55d7b00b1f9e2e2b5d35aaf2a69e21c02eb26d716fa00257cd9cbae3984d613b20d6d956a
7
- data.tar.gz: c27b76e4551ddd3a7f5f459988013157493475cf4aac94498b516c93b5e2f338bb7326d96fef208a01426eca2448d9a82aef4bf340dad8471466989b15ac1f29
6
+ metadata.gz: 05f67f7c831ab06ccfaff089b24e313e22d14c042e067c83667a5d4649b0deb2652c8c990189a404ef21d50dd8f9d55db1e553c704036fefdecef358e9d4a22f
7
+ data.tar.gz: ca39bfb00523b8ac8a993f467562b0dda712182f9a4055e27ee856763a428600e7c0f1b2bd35117471aa1221cf211c77f2833917ae5b77d166b5682d8abf2475
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lifen (0.1.4)
4
+ lifen (0.1.5)
5
5
  faraday (>= 0.9)
6
6
  virtus (>= 1.0)
7
7
 
data/README.md CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
  Lifen can be configured (ideally inside an initializer) like so:
24
24
 
25
25
  Lifen.configure do |config|
26
- config.site = "http://develop.lifen.fr/"
26
+ config.site = "https://develop.lifen.fr/"
27
27
  config.secret_key = "secret_key"
28
28
  config.proxy_url = "http://my.proxy.fr/"
29
29
  end
@@ -12,7 +12,13 @@ module Lifen
12
12
  req.body = JSON.generate(params)
13
13
  end
14
14
 
15
- raise Error, "Error 500, Internal server error" if response.status == 500
15
+ if response.status == 500
16
+ json = JSON.parse response.body
17
+
18
+ trace_id = json.fetch("X-B3-TraceId", "unknown")
19
+ raise Error, "Error 500, Internal server error (trace ID: #{trace_id})"
20
+ end
21
+
16
22
  raise Error, "Error 400" if response.status == 400
17
23
  raise Error, "Error 404, Page not found" if response.status == 404
18
24
  raise InvalidSecretTokenError if response.status == 401
@@ -17,6 +17,13 @@ module Lifen
17
17
  req.body = JSON.generate(params)
18
18
  end
19
19
 
20
+ if response.status == 500
21
+ json = JSON.parse response.body
22
+
23
+ trace_id = json.fetch("X-B3-TraceId", "unknown")
24
+ raise Error, "Error 500, Internal server error (trace ID: #{trace_id})"
25
+ end
26
+
20
27
  raise UnauthorizedError, "Token is not valid" if response.status == 401
21
28
  raise Error, "Action is forbidden" if response.status == 403
22
29
  raise InvalidParamsError, "Invalid params" if response.status == 400
@@ -1,3 +1,3 @@
1
1
  module Lifen
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/central/api/chats/invalid-uuid/attach_users?rel=activeUsers
5
+ uri: https://develop.lifen.fr/central/api/chats/invalid-uuid/attach_users?rel=activeUsers
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '["25588996-4ff1-2dbb-9643-eabb809fa654"]'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/central/api/chats/11e65eca-4af7-d795-bf1a-0242ac110002/attach_users?rel=activeUsers
5
+ uri: https://develop.lifen.fr/central/api/chats/11e65eca-4af7-d795-bf1a-0242ac110002/attach_users?rel=activeUsers
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '["invalid-uuid"]'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/central/api/chats/11e65eca-4af7-d795-bf1a-0242ac110002/attach_users?rel=activeUsers
5
+ uri: https://develop.lifen.fr/central/api/chats/11e65eca-4af7-d795-bf1a-0242ac110002/attach_users?rel=activeUsers
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '["25588996-4ff1-2dbb-9643-eabb809fa654"]'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/central/api/chats
5
+ uri: https://develop.lifen.fr/central/api/chats
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"title":"Rspec Flow"}'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/central/api/chats/11e65eca-4af7-d795-bf1a-0242ac110002/detach_users?rel=activeUsers
5
+ uri: https://develop.lifen.fr/central/api/chats/11e65eca-4af7-d795-bf1a-0242ac110002/detach_users?rel=activeUsers
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '["25588996-4ff1-2dbb-9643-eabb809fa654"]'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/central/api/chats/11e65eca-4af7-d795-bf1a-0242ac110002/detach_users?rel=activeUsers
5
+ uri: https://develop.lifen.fr/central/api/chats/11e65eca-4af7-d795-bf1a-0242ac110002/detach_users?rel=activeUsers
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '["25588996-4ff1-2dbb-9643-eabb809fa654"]'
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://develop.lifen.fr/central/api/chats
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.10.0
12
+ X-Auth-Token:
13
+ - valid_token
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 500
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - 8b7701489385096
31
+ X-B3-Traceid:
32
+ - 8b7701489385096
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/hal+json;charset=UTF-8
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Date:
48
+ - Mon, 28 Nov 2016 13:28:27 GMT
49
+ Connection:
50
+ - close
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"timestamp": "2016-11-28T13:31:26.135+0000","status": 500,"error": "Internal Server Error","code": "error.500","X-B3-TraceId": "2e2eac3a7e3fa2","X-B3-SpanId": "2e2eac3a7e3fa2"}'
54
+ http_version:
55
+ recorded_at: Mon, 28 Nov 2016 13:28:27 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/chats
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.10.0
12
+ X-Auth-Token:
13
+ - valid_token
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 500
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - 8b7701489385096
31
+ X-B3-Traceid:
32
+ - 8b7701489385096
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/hal+json;charset=UTF-8
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Date:
48
+ - Mon, 28 Nov 2016 13:28:27 GMT
49
+ Connection:
50
+ - close
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{}'
54
+ http_version:
55
+ recorded_at: Mon, 28 Nov 2016 13:28:27 GMT
56
+ recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://develop.lifen.fr/central/api/chats
5
+ uri: https://develop.lifen.fr/central/api/chats
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://develop.lifen.fr/central/api/chats
5
+ uri: https://develop.lifen.fr/central/api/chats
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -52,7 +52,7 @@ http_interactions:
52
52
  encoding: UTF-8
53
53
  string: '{"_embedded":{"flows":[{"uuid":"11e5c68b-85e9-96e8-9d33-027026ae8c87","version":0,"type":"regular"},{"uuid":"11e5c68c-464b-c5d5-9d33-027026ae8c87","version":0,"title":"Résultats
54
54
  de bio disponibles","type":"regular"},{"uuid":"11e5c68c-7dc2-fde8-9d33-027026ae8c87","version":0,"title":"Demande
55
- d''avis dermato","type":"regular"}]},"_links":{"self":{"href":"http://develop.lifen.fr/central/api/chats"}},"page":{"size":20,"totalElements":3,"totalPages":1,"number":0}}'
55
+ d''avis dermato","type":"regular"}]},"_links":{"self":{"href":"https://develop.lifen.fr/central/api/chats"}},"page":{"size":20,"totalElements":3,"totalPages":1,"number":0}}'
56
56
  http_version:
57
57
  recorded_at: Wed, 10 Aug 2016 07:15:12 GMT
58
58
  recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/authentication/api/register/third_party
5
+ uri: https://develop.lifen.fr/authentication/api/register/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"emailAddress":"existing-user@domain.tld","lastName":null,"firstName":null}'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/authentication/api/register/third_party
5
+ uri: https://develop.lifen.fr/authentication/api/register/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"emailAddress":"invalid-key-email@test.tld","lastName":null,"firstName":null}'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/authentication/api/register/third_party
5
+ uri: https://develop.lifen.fr/authentication/api/register/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"emailAddress":null,"lastName":null,"firstName":null}'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/authentication/api/register/third_party
5
+ uri: https://develop.lifen.fr/authentication/api/register/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"emailAddress":"valid-email-spec@domain.tld","lastName":null,"firstName":null}'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/authentication/api/authenticate/third_party
5
+ uri: https://develop.lifen.fr/authentication/api/authenticate/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"accountUuid":"invalid-user-uuid"}'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://develop.lifen.fr/authentication/api/authenticate/third_party
5
+ uri: https://develop.lifen.fr/authentication/api/authenticate/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"accountUuid":"valid_uuid"}'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://develop.lifen.fr/central/api/chats/status
5
+ uri: https://develop.lifen.fr/central/api/chats/status
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: "{}"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://develop.lifen.fr/central/api/chats/status
5
+ uri: https://develop.lifen.fr/central/api/chats/status
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: "{}"
@@ -19,6 +19,26 @@ describe Lifen::Flow do
19
19
 
20
20
  end
21
21
 
22
+ context "valid token but internal error" do
23
+ it 'raises an error' do
24
+
25
+ expect{
26
+ VCR.use_cassette "flows/internal_error" do
27
+ @flows = user.flows
28
+ end
29
+ }.to raise_error(Lifen::Error, "Error 500, Internal server error (trace ID: 2e2eac3a7e3fa2)")
30
+ end
31
+
32
+ it 'raises an error (without trace ID)' do
33
+ expect{
34
+ VCR.use_cassette "flows/internal_error_without_trace_id" do
35
+ @flows = user.flows
36
+ end
37
+ }.to raise_error(Lifen::Error, "Error 500, Internal server error (trace ID: unknown)")
38
+ end
39
+
40
+ end
41
+
22
42
  context "valid token" do
23
43
 
24
44
  before(:each) do
@@ -17,7 +17,7 @@ end
17
17
  RSpec.configure do |c|
18
18
  c.before(:each) do
19
19
  Lifen.configure do |config|
20
- config.site = "http://develop.lifen.fr/"
20
+ config.site = "https://develop.lifen.fr/"
21
21
  config.secret_key = "valid_secret_key"
22
22
  end
23
23
  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: 0.1.4
4
+ version: 0.1.5
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-11-22 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -157,6 +157,8 @@ files:
157
157
  - spec/cassettes/flows/create.yml
158
158
  - spec/cassettes/flows/detach_users/valid.yml
159
159
  - spec/cassettes/flows/detach_users/valid_again.yml
160
+ - spec/cassettes/flows/internal_error.yml
161
+ - spec/cassettes/flows/internal_error_without_trace_id.yml
160
162
  - spec/cassettes/flows/invalid_token.yml
161
163
  - spec/cassettes/flows/valid_token.yml
162
164
  - spec/cassettes/users/create/existing_user.yml
@@ -201,6 +203,8 @@ test_files:
201
203
  - spec/cassettes/flows/create.yml
202
204
  - spec/cassettes/flows/detach_users/valid.yml
203
205
  - spec/cassettes/flows/detach_users/valid_again.yml
206
+ - spec/cassettes/flows/internal_error.yml
207
+ - spec/cassettes/flows/internal_error_without_trace_id.yml
204
208
  - spec/cassettes/flows/invalid_token.yml
205
209
  - spec/cassettes/flows/valid_token.yml
206
210
  - spec/cassettes/users/create/existing_user.yml