lifen 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/lifen/app_authenticated_client.rb +10 -6
- data/lib/lifen/client.rb +17 -4
- data/lib/lifen/user_authenticated_client.rb +9 -5
- data/lib/lifen/version.rb +1 -1
- data/spec/flows_spec.rb +5 -5
- data/spec/users_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f5c85c29e8ab9cc7f36987098d50f12a5beb96d
|
4
|
+
data.tar.gz: 74e319a77102bbc00630fa6f24acdec72d4ee789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6c8d52af33bb08e5c3926d8bbee08edbd50e6da9ded2303fe62f5b917e6c85c4e955d9233414f2ea79ab702624ef68589f16fe0c168f7e51aba58d68027ee32
|
7
|
+
data.tar.gz: 436d77f9de97847cf494d0336646a98a958ec12333bf9df5eaf7930d965e8b538fbba24da4d3338b4980fa2ba5986ec331756670f88a37b428c806cc96dc19d6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,22 +3,26 @@ module Lifen
|
|
3
3
|
|
4
4
|
private
|
5
5
|
|
6
|
-
def
|
7
|
-
super(response)
|
6
|
+
def handle_errors(response, params)
|
7
|
+
super(response, params)
|
8
8
|
|
9
9
|
case response.status
|
10
10
|
when 400
|
11
|
-
raise Error, "Error 400"
|
11
|
+
raise Error, "Error 400, Unknown error, #{response_error(response, params)}"
|
12
12
|
when 401
|
13
|
-
raise InvalidSecretTokenError
|
13
|
+
raise InvalidSecretTokenError, "Error 401, Invalid app bearer, #{response_error(response, params)}"
|
14
14
|
when 403
|
15
|
-
raise UserAlreadyExistingError
|
15
|
+
raise UserAlreadyExistingError, "Error 403, User already existing, #{response_error(response, params)}"
|
16
16
|
when 404
|
17
|
-
raise Error, "Error 404, Page not found"
|
17
|
+
raise Error, "Error 404, Page not found, #{response_error(response, params)}"
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
|
+
def response_error(response, params)
|
23
|
+
"App Client, #{super(response, params)}"
|
24
|
+
end
|
25
|
+
|
22
26
|
def bearer
|
23
27
|
Lifen.configuration.application_access_token
|
24
28
|
end
|
data/lib/lifen/client.rb
CHANGED
@@ -14,7 +14,7 @@ module Lifen
|
|
14
14
|
req.body = JSON.generate(params)
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
handle_errors(response, params)
|
18
18
|
|
19
19
|
json = JSON.parse response.body
|
20
20
|
|
@@ -31,18 +31,19 @@ module Lifen
|
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
-
def
|
34
|
+
def handle_errors(response, params)
|
35
35
|
if response.status == 500
|
36
|
+
|
36
37
|
json = JSON.parse response.body
|
37
38
|
|
38
39
|
trace_id = json.fetch("X-B3-TraceId", "unknown")
|
39
|
-
|
40
|
+
|
41
|
+
raise Error, "Error 500, Internal server error (trace ID: #{trace_id}), #{response_error(response, params)}"
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
45
|
def faraday_client
|
44
46
|
@faraday_client ||= Faraday.new(faraday_options) do |faraday|
|
45
|
-
faraday.request :url_encoded # form-encode POST params
|
46
47
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
47
48
|
end
|
48
49
|
end
|
@@ -66,6 +67,18 @@ module Lifen
|
|
66
67
|
def before_request
|
67
68
|
end
|
68
69
|
|
70
|
+
def response_error(response, params)
|
71
|
+
"#{response.env.method.upcase} '#{response.env.url}' with params '#{params.inspect}' and bearer '#{trucanted_bearer}'"
|
72
|
+
end
|
73
|
+
|
74
|
+
def trucanted_bearer
|
75
|
+
if m = /^(.{24})(.*)$/.match(bearer)
|
76
|
+
"#{m[1]}#{"*" * m[2].length}"
|
77
|
+
else
|
78
|
+
bearer
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
69
82
|
def bearer
|
70
83
|
raise "A bearer method must be defined"
|
71
84
|
end
|
@@ -9,20 +9,24 @@ module Lifen
|
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
def
|
13
|
-
super(response)
|
12
|
+
def handle_errors(response, params)
|
13
|
+
super(response, params)
|
14
14
|
|
15
15
|
case response.status
|
16
16
|
when 400
|
17
|
-
raise InvalidParamsError, "Invalid params"
|
17
|
+
raise InvalidParamsError, "Error 400, Invalid params, #{response_error(response, params)}"
|
18
18
|
when 401
|
19
|
-
raise UnauthorizedError, "Token is not valid"
|
19
|
+
raise UnauthorizedError, "Error 401, Token is not valid, #{response_error(response, params)}"
|
20
20
|
when 403
|
21
|
-
raise Error, "Action is forbidden"
|
21
|
+
raise Error, "Error 403, Action is forbidden, #{response_error(response, params)}"
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
+
def response_error(response, params)
|
27
|
+
"User Client, #{super(response, params)}"
|
28
|
+
end
|
29
|
+
|
26
30
|
def bearer
|
27
31
|
token.value
|
28
32
|
end
|
data/lib/lifen/version.rb
CHANGED
data/spec/flows_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe Lifen::Flow do
|
|
19
19
|
VCR.use_cassette "flows/invalid_token" do
|
20
20
|
user.flows
|
21
21
|
end
|
22
|
-
}.to raise_error(Lifen::UnauthorizedError)
|
22
|
+
}.to raise_error(Lifen::UnauthorizedError, "Error 401, Token is not valid, User Client, GET 'https://develop.lifen.fr/central/api/chats' with params '{}' and bearer 'invalid_token'")
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -31,7 +31,7 @@ describe Lifen::Flow do
|
|
31
31
|
VCR.use_cassette "flows/internal_error" do
|
32
32
|
user.flows
|
33
33
|
end
|
34
|
-
}.to raise_error(Lifen::Error, "Error 500, Internal server error (trace ID: 2e2eac3a7e3fa2)")
|
34
|
+
}.to raise_error(Lifen::Error, "Error 500, Internal server error (trace ID: 2e2eac3a7e3fa2), User Client, GET 'https://develop.lifen.fr/central/api/chats' with params '{}' and bearer 'valid_token'")
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'raises an error (without trace ID)' do
|
@@ -39,7 +39,7 @@ describe Lifen::Flow do
|
|
39
39
|
VCR.use_cassette "flows/internal_error_without_trace_id" do
|
40
40
|
user.flows
|
41
41
|
end
|
42
|
-
}.to raise_error(Lifen::Error, "Error 500, Internal server error (trace ID: unknown)")
|
42
|
+
}.to raise_error(Lifen::Error, "Error 500, Internal server error (trace ID: unknown), User Client, GET 'https://develop.lifen.fr/central/api/chats' with params '{}' and bearer 'valid_token'")
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
@@ -122,7 +122,7 @@ describe Lifen::Flow do
|
|
122
122
|
VCR.use_cassette "flows/attach_users/invalid_flow_uuid" do
|
123
123
|
flow.attach_users(user)
|
124
124
|
end
|
125
|
-
}.to raise_error(Lifen::InvalidParamsError)
|
125
|
+
}.to raise_error(Lifen::InvalidParamsError, "Error 400, Invalid params, User Client, POST 'https://develop.lifen.fr/central/api/chats/invalid-uuid/attach_users?rel=activeUsers' with params '[\"25588996-4ff1-2dbb-9643-eabb809fa654\"]' and bearer 'valid_token'")
|
126
126
|
end
|
127
127
|
|
128
128
|
end
|
@@ -141,7 +141,7 @@ describe Lifen::Flow do
|
|
141
141
|
VCR.use_cassette "flows/attach_users/invalid_user_uuid" do
|
142
142
|
flow.attach_users(invalid_user)
|
143
143
|
end
|
144
|
-
}.to raise_error(Lifen::InvalidParamsError)
|
144
|
+
}.to raise_error(Lifen::InvalidParamsError, "Error 400, Invalid params, User Client, POST 'https://develop.lifen.fr/central/api/chats/11e6be18-7a35-d759-9177-0242ac110002/attach_users?rel=activeUsers' with params '[\"invalid-uuid\"]' and bearer 'valid_token'")
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
data/spec/users_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe Lifen::User do
|
|
17
17
|
VCR.use_cassette "users/create/missing_fields" do
|
18
18
|
user.create
|
19
19
|
end
|
20
|
-
}.to raise_error(Lifen::Error)
|
20
|
+
}.to raise_error(Lifen::Error, "Error 401, Invalid app bearer, App Client, POST 'https://develop.lifen.fr/authentication/api/register/third_party' with params '{:emailAddress=>nil, :lastName=>nil, :firstName=>\"Marc\"}' and bearer 'valid_application_access******'")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -36,7 +36,7 @@ describe Lifen::User do
|
|
36
36
|
VCR.use_cassette "users/create/invalid_token" do
|
37
37
|
user.create
|
38
38
|
end
|
39
|
-
}.to raise_error(Lifen::InvalidSecretTokenError)
|
39
|
+
}.to raise_error(Lifen::InvalidSecretTokenError, "Error 401, Invalid app bearer, App Client, POST 'https://develop.lifen.fr/authentication/api/register/third_party' with params '{:emailAddress=>\"invalid-key-email@test.tld\", :lastName=>nil, :firstName=>nil}' and bearer 'invalid-secret-key'")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -49,7 +49,7 @@ describe Lifen::User do
|
|
49
49
|
VCR.use_cassette "users/create/existing_user" do
|
50
50
|
user.create
|
51
51
|
end
|
52
|
-
}.to raise_error(Lifen::UserAlreadyExistingError)
|
52
|
+
}.to raise_error(Lifen::UserAlreadyExistingError, "Error 403, User already existing, App Client, POST 'https://develop.lifen.fr/authentication/api/register/third_party' with params '{:emailAddress=>\"existing-user@domain.tld\", :lastName=>\"User\", :firstName=>\"Existing\"}' and bearer 'valid_application_access******'")
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -80,7 +80,7 @@ describe Lifen::User do
|
|
80
80
|
VCR.use_cassette "users/token/refresh/invalid_user_uuid" do
|
81
81
|
user.token.refresh
|
82
82
|
end
|
83
|
-
}.to raise_error(Lifen::Error)
|
83
|
+
}.to raise_error(Lifen::Error, "Error 500, Internal server error (trace ID: unknown), App Client, POST 'https://develop.lifen.fr/oauth/admin/third_party/access_token?accountUuid=invalid-user-uuid' with params '{}' and bearer 'valid_application_access******'")
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -113,7 +113,7 @@ describe Lifen::User do
|
|
113
113
|
VCR.use_cassette "users/status/refresh/invalid_token" do
|
114
114
|
user.status.refresh
|
115
115
|
end
|
116
|
-
}.to raise_error(Lifen::Error)
|
116
|
+
}.to raise_error(Lifen::Error, "Error 401, Token is not valid, User Client, GET 'https://develop.lifen.fr/central/api/chats/status' with params '{}' and bearer 'invalid_token'")
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
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.0.
|
4
|
+
version: 1.0.2
|
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-
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|