lifen 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +3 -1
  3. data/README.md +11 -11
  4. data/lib/lifen.rb +7 -4
  5. data/lib/lifen/app_authenticated_client.rb +15 -27
  6. data/lib/lifen/client.rb +44 -0
  7. data/lib/lifen/configuration.rb +1 -1
  8. data/lib/lifen/error.rb +1 -0
  9. data/lib/lifen/flow.rb +41 -44
  10. data/lib/lifen/flows.rb +4 -8
  11. data/lib/lifen/status.rb +5 -3
  12. data/lib/lifen/token.rb +44 -0
  13. data/lib/lifen/user.rb +34 -23
  14. data/lib/lifen/user_authenticated_client.rb +17 -27
  15. data/lib/lifen/version.rb +1 -1
  16. data/lifen.gemspec +1 -0
  17. data/spec/cassettes/flows/attach_users/invalid_flow_uuid.yml +11 -13
  18. data/spec/cassettes/flows/attach_users/invalid_user_uuid.yml +12 -14
  19. data/spec/cassettes/flows/attach_users/valid.yml +14 -16
  20. data/spec/cassettes/flows/create.yml +13 -15
  21. data/spec/cassettes/flows/create_with_users.yml +12 -13
  22. data/spec/cassettes/flows/detach_users/valid.yml +14 -16
  23. data/spec/cassettes/flows/internal_error.yml +4 -2
  24. data/spec/cassettes/flows/internal_error_without_trace_id.yml +4 -2
  25. data/spec/cassettes/flows/invalid_token.yml +18 -14
  26. data/spec/cassettes/flows/valid_token.yml +14 -17
  27. data/spec/cassettes/messages/valid_message.yml +13 -15
  28. data/spec/cassettes/users/create/existing_user.yml +11 -11
  29. data/spec/cassettes/users/create/invalid_token.yml +16 -10
  30. data/spec/cassettes/users/create/missing_fields.yml +19 -14
  31. data/spec/cassettes/users/create/valid_attributes.yml +12 -12
  32. data/spec/cassettes/users/{refresh_unread_messages → status/refresh}/invalid_token.yml +16 -12
  33. data/spec/cassettes/users/{refresh_unread_messages → status/refresh}/valid_token.yml +10 -12
  34. data/spec/cassettes/users/token/refresh/invalid_user_uuid.yml +40 -0
  35. data/spec/cassettes/users/{refresh/invalid_user_uuid.yml → token/refresh/valid_user_uuid.yml} +16 -15
  36. data/spec/flows_spec.rb +43 -25
  37. data/spec/messages_spec.rb +10 -5
  38. data/spec/spec_helper.rb +1 -1
  39. data/spec/users_spec.rb +46 -26
  40. metadata +25 -13
  41. data/lib/lifen/authentication.rb +0 -29
  42. data/spec/cassettes/flows/detach_users/valid_again.yml +0 -57
  43. data/spec/cassettes/users/refresh/valid_user_uuid.yml +0 -54
@@ -9,10 +9,12 @@ http_interactions:
9
9
  headers:
10
10
  User-Agent:
11
11
  - Faraday v0.10.0
12
- X-Auth-Token:
13
- - valid_token
12
+ Authorization:
13
+ - Bearer valid_token
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
20
  Accept:
@@ -9,10 +9,12 @@ http_interactions:
9
9
  headers:
10
10
  User-Agent:
11
11
  - Faraday v0.10.0
12
- X-Auth-Token:
13
- - valid_token
12
+ Authorization:
13
+ - Bearer valid_token
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
20
  Accept:
@@ -4,19 +4,19 @@ http_interactions:
4
4
  method: get
5
5
  uri: https://develop.lifen.fr/central/api/chats
6
6
  body:
7
- encoding: US-ASCII
8
- string: ''
7
+ encoding: UTF-8
8
+ string: "{}"
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
12
- X-Auth-Token:
13
- - invalid-token
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer invalid_token
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
20
  response:
21
21
  status:
22
22
  code: 401
@@ -27,30 +27,34 @@ http_interactions:
27
27
  X-B3-Sampled:
28
28
  - '1'
29
29
  X-B3-Spanid:
30
- - c160889f96d914d9
30
+ - f2418d87dec85bf1
31
31
  X-B3-Traceid:
32
- - c160889f96d914d9
32
+ - f2418d87dec85bf1
33
33
  X-Content-Type-Options:
34
34
  - nosniff
35
35
  X-Xss-Protection:
36
36
  - 1; mode=block
37
37
  Cache-Control:
38
38
  - no-cache, no-store, max-age=0, must-revalidate
39
+ - no-store
39
40
  Pragma:
40
41
  - no-cache
42
+ - no-cache
41
43
  Expires:
42
44
  - '0'
45
+ Www-Authenticate:
46
+ - 'Bearer realm="oauth", error="invalid_token", error_description="Invalid access
47
+ token: invalid_token"'
43
48
  Content-Type:
44
49
  - application/json;charset=UTF-8
45
50
  Transfer-Encoding:
46
51
  - chunked
47
52
  Date:
48
- - Wed, 10 Aug 2016 07:14:48 GMT
49
- Connection:
50
- - close
53
+ - Fri, 09 Dec 2016 14:00:45 GMT
51
54
  body:
52
55
  encoding: UTF-8
53
- string: '{"timestamp":"2016-08-10T07:14:48.142+0000","status":401,"error":"Unauthorized","code":"error.401","X-B3-TraceId":"c160889f96d914d9","X-B3-SpanId":"c160889f96d914d9"}'
56
+ string: '{"error":"invalid_token","error_description":"Invalid access token:
57
+ invalid_token"}'
54
58
  http_version:
55
- recorded_at: Wed, 10 Aug 2016 07:14:48 GMT
59
+ recorded_at: Fri, 09 Dec 2016 13:58:54 GMT
56
60
  recorded_with: VCR 3.0.3
@@ -4,19 +4,19 @@ http_interactions:
4
4
  method: get
5
5
  uri: https://develop.lifen.fr/central/api/chats
6
6
  body:
7
- encoding: US-ASCII
8
- string: ''
7
+ encoding: UTF-8
8
+ string: "{}"
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
12
- X-Auth-Token:
13
- - valid_token
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer valid_token
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
20
  response:
21
21
  status:
22
22
  code: 200
@@ -27,9 +27,9 @@ http_interactions:
27
27
  X-B3-Sampled:
28
28
  - '1'
29
29
  X-B3-Spanid:
30
- - 8c37acfa6432b0c7
30
+ - f8575522955e00fa
31
31
  X-B3-Traceid:
32
- - 8c37acfa6432b0c7
32
+ - f8575522955e00fa
33
33
  X-Content-Type-Options:
34
34
  - nosniff
35
35
  X-Xss-Protection:
@@ -41,18 +41,15 @@ http_interactions:
41
41
  Expires:
42
42
  - '0'
43
43
  Content-Type:
44
- - application/hal+json;charset=UTF-8
44
+ - application/json;charset=UTF-8
45
45
  Transfer-Encoding:
46
46
  - chunked
47
47
  Date:
48
- - Wed, 10 Aug 2016 07:15:12 GMT
49
- Connection:
50
- - close
48
+ - Fri, 09 Dec 2016 14:06:09 GMT
51
49
  body:
52
50
  encoding: UTF-8
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
- de bio disponibles","type":"regular"},{"uuid":"11e5c68c-7dc2-fde8-9d33-027026ae8c87","version":0,"title":"Demande
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}}'
51
+ string: '{"_embedded":{"flows":[{"uuid":"11e6be18-7a35-d759-9177-0242ac110002","version":0,"title":"Rspec
52
+ Flow","type":"regular"}]},"_links":{"self":{"href":"https://develop.lifen.fr/central/api/chats"}},"page":{"size":20,"totalElements":1,"totalPages":1,"number":0}}'
56
53
  http_version:
57
- recorded_at: Wed, 10 Aug 2016 07:15:12 GMT
54
+ recorded_at: Fri, 09 Dec 2016 14:04:18 GMT
58
55
  recorded_with: VCR 3.0.3
@@ -2,21 +2,21 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://develop.lifen.fr/central/api/chats/11e6b870-37a5-59af-ac0e-0242ac110002/messages
5
+ uri: https://develop.lifen.fr/central/api/chats/11e6be18-7a35-d759-9177-0242ac110002/messages
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"content":"Bonjour Lifen"}'
8
+ string: '{"content":"Bonjour Lifen","type":"regular"}'
9
9
  headers:
10
10
  User-Agent:
11
11
  - Faraday v0.10.0
12
- X-Auth-Token:
13
- - valid_token
12
+ Authorization:
13
+ - Bearer valide_token
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
20
  response:
21
21
  status:
22
22
  code: 200
@@ -27,9 +27,9 @@ http_interactions:
27
27
  X-B3-Sampled:
28
28
  - '1'
29
29
  X-B3-Spanid:
30
- - a8262c0e7a907672
30
+ - a92fe22c2aff6b2
31
31
  X-B3-Traceid:
32
- - a8262c0e7a907672
32
+ - a92fe22c2aff6b2
33
33
  X-Content-Type-Options:
34
34
  - nosniff
35
35
  X-Xss-Protection:
@@ -41,17 +41,15 @@ http_interactions:
41
41
  Expires:
42
42
  - '0'
43
43
  Content-Type:
44
- - application/hal+json;charset=UTF-8
44
+ - application/json;charset=UTF-8
45
45
  Transfer-Encoding:
46
46
  - chunked
47
47
  Date:
48
- - Fri, 02 Dec 2016 09:24:25 GMT
49
- Connection:
50
- - close
48
+ - Fri, 09 Dec 2016 15:01:17 GMT
51
49
  body:
52
50
  encoding: UTF-8
53
- string: '{"uuid":"11e6b871-1e02-9662-ac0e-0242ac110002","version":0,"content":"Bonjour
54
- Lifen","sentDate":"2016-12-02T09:24:25.568Z","read":true,"type":"regular","modificationDate":"2016-12-02T09:24:25.568Z","updateable":true}'
51
+ string: '{"uuid":"11e6be20-5647-8f9b-9177-0242ac110002","version":0,"content":"Bonjour
52
+ Lifen","sentDate":"2016-12-09T15:01:17.727Z","read":true,"type":"regular","modificationDate":"2016-12-09T15:01:17.714Z","updateable":true}'
55
53
  http_version:
56
- recorded_at: Fri, 02 Dec 2016 09:23:50 GMT
54
+ recorded_at: Fri, 09 Dec 2016 14:59:27 GMT
57
55
  recorded_with: VCR 3.0.3
@@ -5,18 +5,18 @@ http_interactions:
5
5
  uri: https://develop.lifen.fr/authentication/api/register/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"emailAddress":"existing-user@domain.tld","lastName":null,"firstName":null}'
8
+ string: '{"emailAddress":"existing-user@domain.tld","lastName":"User","firstName":"Existing"}'
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
12
- Secret-Key:
13
- - valid_secret_key
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
20
  response:
21
21
  status:
22
22
  code: 403
@@ -27,9 +27,9 @@ http_interactions:
27
27
  X-B3-Sampled:
28
28
  - '1'
29
29
  X-B3-Spanid:
30
- - ac141a836a7e5444
30
+ - db693c7f15e89e58
31
31
  X-B3-Traceid:
32
- - ac141a836a7e5444
32
+ - db693c7f15e89e58
33
33
  X-Content-Type-Options:
34
34
  - nosniff
35
35
  X-Xss-Protection:
@@ -45,10 +45,10 @@ http_interactions:
45
45
  Transfer-Encoding:
46
46
  - chunked
47
47
  Date:
48
- - Wed, 07 Sep 2016 12:40:25 GMT
48
+ - Fri, 09 Dec 2016 13:39:42 GMT
49
49
  body:
50
50
  encoding: UTF-8
51
- string: '{"timestamp":"2016-09-07T12:40:25.369+0000","status":403,"error":"Forbidden","code":"email.exists.exception","X-B3-TraceId":"ac141a836a7e5444","X-B3-SpanId":"ac141a836a7e5444"}'
51
+ string: '{"timestamp":"2016-12-09T13:39:42.918+0000","status":403,"error":"Forbidden","code":"email.exists.exception","X-B3-TraceId":"db693c7f15e89e58","X-B3-SpanId":"db693c7f15e89e58"}'
52
52
  http_version:
53
- recorded_at: Wed, 07 Sep 2016 12:40:20 GMT
53
+ recorded_at: Fri, 09 Dec 2016 13:37:51 GMT
54
54
  recorded_with: VCR 3.0.3
@@ -8,15 +8,15 @@ http_interactions:
8
8
  string: '{"emailAddress":"invalid-key-email@test.tld","lastName":null,"firstName":null}'
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
12
- Secret-Key:
13
- - invalid-secret-key
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer invalid-secret-key
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
20
  response:
21
21
  status:
22
22
  code: 401
@@ -27,28 +27,34 @@ http_interactions:
27
27
  X-B3-Sampled:
28
28
  - '1'
29
29
  X-B3-Spanid:
30
- - c27725b2f8083d04
30
+ - d0655043bd3b7d47
31
31
  X-B3-Traceid:
32
- - c27725b2f8083d04
32
+ - d0655043bd3b7d47
33
33
  X-Content-Type-Options:
34
34
  - nosniff
35
35
  X-Xss-Protection:
36
36
  - 1; mode=block
37
37
  Cache-Control:
38
38
  - no-cache, no-store, max-age=0, must-revalidate
39
+ - no-store
39
40
  Pragma:
40
41
  - no-cache
42
+ - no-cache
41
43
  Expires:
42
44
  - '0'
45
+ Www-Authenticate:
46
+ - 'Bearer realm="oauth", error="invalid_token", error_description="Invalid access
47
+ token: invalid-secret-key"'
43
48
  Content-Type:
44
49
  - application/json;charset=UTF-8
45
50
  Transfer-Encoding:
46
51
  - chunked
47
52
  Date:
48
- - Wed, 07 Sep 2016 12:35:11 GMT
53
+ - Fri, 09 Dec 2016 09:48:23 GMT
49
54
  body:
50
55
  encoding: UTF-8
51
- string: '{"timestamp":"2016-09-07T12:35:11.807+0000","status":401,"error":"Unauthorized","code":"authentication.failed","X-B3-TraceId":"c27725b2f8083d04","X-B3-SpanId":"c27725b2f8083d04"}'
56
+ string: '{"error":"invalid_token","error_description":"Invalid access token:
57
+ invalid-secret-key"}'
52
58
  http_version:
53
- recorded_at: Wed, 07 Sep 2016 12:35:07 GMT
59
+ recorded_at: Fri, 09 Dec 2016 09:46:32 GMT
54
60
  recorded_with: VCR 3.0.3
@@ -5,51 +5,56 @@ http_interactions:
5
5
  uri: https://develop.lifen.fr/authentication/api/register/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"emailAddress":null,"lastName":null,"firstName":null}'
8
+ string: '{"emailAddress":null,"lastName":null,"firstName":"Marc"}'
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
12
- Secret-Key:
13
- - valid_secret_key
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
20
  response:
21
21
  status:
22
- code: 400
23
- message: Bad Request
22
+ code: 401
23
+ message: Unauthorized
24
24
  headers:
25
25
  Server:
26
26
  - Apache-Coyote/1.1
27
27
  X-B3-Sampled:
28
28
  - '1'
29
29
  X-B3-Spanid:
30
- - ecbe4a68ac59ff06
30
+ - 5f594a52a125cb57
31
31
  X-B3-Traceid:
32
- - ecbe4a68ac59ff06
32
+ - 5f594a52a125cb57
33
33
  X-Content-Type-Options:
34
34
  - nosniff
35
35
  X-Xss-Protection:
36
36
  - 1; mode=block
37
37
  Cache-Control:
38
38
  - no-cache, no-store, max-age=0, must-revalidate
39
+ - no-store
39
40
  Pragma:
40
41
  - no-cache
42
+ - no-cache
41
43
  Expires:
42
44
  - '0'
45
+ Www-Authenticate:
46
+ - 'Bearer realm="oauth", error="invalid_token", error_description="Invalid access
47
+ token: valid_application_access_token"'
43
48
  Content-Type:
44
49
  - application/json;charset=UTF-8
45
50
  Transfer-Encoding:
46
51
  - chunked
47
52
  Date:
48
- - Wed, 07 Sep 2016 12:35:11 GMT
53
+ - Fri, 09 Dec 2016 09:48:27 GMT
49
54
  body:
50
55
  encoding: UTF-8
51
- string: '{"timestamp":"2016-09-07T12:35:11.438+0000","status":400,"error":"Bad
52
- Request","code":"error.badrequest","X-B3-TraceId":"ecbe4a68ac59ff06","X-B3-SpanId":"ecbe4a68ac59ff06"}'
56
+ string: '{"error":"invalid_token","error_description":"Invalid access token:
57
+ valid_application_access_token"}'
53
58
  http_version:
54
- recorded_at: Wed, 07 Sep 2016 12:35:07 GMT
59
+ recorded_at: Fri, 09 Dec 2016 09:46:36 GMT
55
60
  recorded_with: VCR 3.0.3
@@ -5,18 +5,18 @@ http_interactions:
5
5
  uri: https://develop.lifen.fr/authentication/api/register/third_party
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"emailAddress":"valid-email-spec@domain.tld","lastName":null,"firstName":null}'
8
+ string: '{"emailAddress":"valid-email-spec@domain.tld","lastName":"User","firstName":"Valid"}'
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
12
- Secret-Key:
13
- - valid_secret_key
11
+ - Faraday v0.10.0
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept:
17
+ - application/json
16
18
  Accept-Encoding:
17
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
- Accept:
19
- - "*/*"
20
20
  response:
21
21
  status:
22
22
  code: 201
@@ -27,9 +27,9 @@ http_interactions:
27
27
  X-B3-Sampled:
28
28
  - '1'
29
29
  X-B3-Spanid:
30
- - 2041de101045e2fa
30
+ - cfda70747616828e
31
31
  X-B3-Traceid:
32
- - 2041de101045e2fa
32
+ - cfda70747616828e
33
33
  X-Content-Type-Options:
34
34
  - nosniff
35
35
  X-Xss-Protection:
@@ -41,14 +41,14 @@ http_interactions:
41
41
  Expires:
42
42
  - '0'
43
43
  Content-Type:
44
- - application/hal+json;charset=UTF-8
44
+ - application/json;charset=UTF-8
45
45
  Transfer-Encoding:
46
46
  - chunked
47
47
  Date:
48
- - Wed, 07 Sep 2016 12:35:12 GMT
48
+ - Fri, 09 Dec 2016 16:47:48 GMT
49
49
  body:
50
50
  encoding: UTF-8
51
- string: '{"token":"O6LaDhXwEt2XrvIJhb2inJx6DQd4zQ6x82okJw2hMGd1HRmlY6qI7ab3yPS6lA/KtkULoMpCninK3gwpCdKpuodR94s6e9naRV1f1g92z7ejemfJdtAN3fWVdd+Obqq0E9cJ3fc3SE3RmoXmhkXJ+ghzj9+i6FQHCb+vscNUdXxJwddp7z0Raoh8abKwJH8glfabZCBbYPkGdp11FshXDx+ssG4caPRy","accountUuid":"valid_uuid"}'
51
+ string: '{"accountUuid":"11e6be2f-3766-246f-9a9f-0242ac110002"}'
52
52
  http_version:
53
- recorded_at: Wed, 07 Sep 2016 12:35:08 GMT
53
+ recorded_at: Fri, 09 Dec 2016 16:45:57 GMT
54
54
  recorded_with: VCR 3.0.3