lifen 0.1.3 → 0.1.4

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: 5852ac6e37a18f038b087c4ac3e51a5eb63aea3c
4
- data.tar.gz: 5c3910329b4582556088afc4ae9f2ccf6c2f540c
3
+ metadata.gz: 07a14dd0813fe91d0fe86a3347dbc0553ca2d3ce
4
+ data.tar.gz: 4e539ba5ae948f39d3998c15cb3c17a3fa426da2
5
5
  SHA512:
6
- metadata.gz: 2f5b3e52d69b86a2d03d01f8b5a34cfd3dc7b1d881b3b7ca13ee85555dc65be6b8311c2b6f72c3b875df9fd0dbe246cd94dcfaad56676699c165d3e0228d15a5
7
- data.tar.gz: ede4a35d12d16f7cb7c903d411d767c0a8d4909f01a97d166c99e662527181a03a8126e939d88cf9aa2070dc37eb645d29a65e52ba24769c15c3bfc2281661c8
6
+ metadata.gz: 5429ce6b274cdb3a2499947d4db75f36d8942c2902eb3843c2ae41d55d7b00b1f9e2e2b5d35aaf2a69e21c02eb26d716fa00257cd9cbae3984d613b20d6d956a
7
+ data.tar.gz: c27b76e4551ddd3a7f5f459988013157493475cf4aac94498b516c93b5e2f338bb7326d96fef208a01426eca2448d9a82aef4bf340dad8471466989b15ac1f29
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.3.2
data/Gemfile.lock CHANGED
@@ -1,14 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lifen (0.1.3)
5
- faraday (~> 0.9)
6
- virtus (~> 1.0)
4
+ lifen (0.1.4)
5
+ faraday (>= 0.9)
6
+ virtus (>= 1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.4.0)
11
+ addressable (2.5.0)
12
+ public_suffix (~> 2.0, >= 2.0.2)
12
13
  awesome_print (1.7.0)
13
14
  axiom-types (0.1.1)
14
15
  descendants_tracker (~> 0.0.4)
@@ -22,17 +23,18 @@ GEM
22
23
  thread_safe (~> 0.3, >= 0.3.1)
23
24
  diff-lcs (1.2.5)
24
25
  equalizer (0.0.11)
25
- faraday (0.9.2)
26
+ faraday (0.10.0)
26
27
  multipart-post (>= 1.2, < 3)
27
28
  hashdiff (0.3.0)
28
29
  ice_nine (0.11.2)
29
30
  multipart-post (2.0.0)
31
+ public_suffix (2.0.4)
30
32
  rake (10.5.0)
31
33
  rspec (3.5.0)
32
34
  rspec-core (~> 3.5.0)
33
35
  rspec-expectations (~> 3.5.0)
34
36
  rspec-mocks (~> 3.5.0)
35
- rspec-core (3.5.2)
37
+ rspec-core (3.5.4)
36
38
  rspec-support (~> 3.5.0)
37
39
  rspec-expectations (3.5.0)
38
40
  diff-lcs (>= 1.2.0, < 2.0)
data/lib/lifen.rb CHANGED
@@ -15,5 +15,6 @@ module Lifen
15
15
  require 'lifen/flow'
16
16
  require 'lifen/flows'
17
17
  require 'lifen/authentication'
18
+ require 'lifen/status'
18
19
 
19
20
  end
@@ -0,0 +1,21 @@
1
+ module Lifen
2
+ class Status < Base
3
+
4
+ attribute :user, Lifen::User
5
+
6
+ attribute :unread, Integer
7
+
8
+ def refresh
9
+ json = client.get("central/api/chats/status")
10
+
11
+ self.unread = json["unread"]
12
+ end
13
+
14
+ private
15
+
16
+ def client
17
+ @client ||= user.client
18
+ end
19
+
20
+ end
21
+ end
data/lib/lifen/user.rb CHANGED
@@ -7,6 +7,7 @@ module Lifen
7
7
  attribute :email, String
8
8
  attribute :last_name, String
9
9
  attribute :first_name, String
10
+ attribute :unread_messages, Integer, default: 0
10
11
 
11
12
  def flows
12
13
  Lifen::Flows.new(self).all
@@ -31,6 +32,15 @@ module Lifen
31
32
  self
32
33
  end
33
34
 
35
+ def refresh_unread_messages
36
+ status = Lifen::Status.new(user: self)
37
+ status.refresh
38
+
39
+ self.unread_messages = status.unread
40
+
41
+ self
42
+ end
43
+
34
44
  def client
35
45
  UserAuthenticatedClient.new(token)
36
46
  end
data/lib/lifen/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lifen
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lifen.gemspec CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "webmock", '~> 1.24'
25
25
  spec.add_development_dependency "awesome_print"
26
26
 
27
- spec.add_runtime_dependency "virtus", '~> 1.0'
28
- spec.add_runtime_dependency "faraday", '~> 0.9'
27
+ spec.add_runtime_dependency "virtus", '>= 1.0'
28
+ spec.add_runtime_dependency "faraday", '>= 0.9'
29
29
  end
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://develop.lifen.fr/central/api/chats/status
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ X-Auth-Token:
13
+ - invalid_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: 401
23
+ message: Unauthorized
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - 2b0ef6c798cd0830
31
+ X-B3-Traceid:
32
+ - 2b0ef6c798cd0830
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
+ - Tue, 22 Nov 2016 14:27:24 GMT
49
+ Connection:
50
+ - close
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"timestamp":"2016-11-22T14:27:24.255+0000","status":401,"error":"Unauthorized","code":"error.401","X-B3-TraceId":"2b0ef6c798cd0830","X-B3-SpanId":"2b0ef6c798cd0830"}'
54
+ http_version:
55
+ recorded_at: Tue, 22 Nov 2016 14:26:56 GMT
56
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://develop.lifen.fr/central/api/chats/status
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
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: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-B3-Sampled:
28
+ - '1'
29
+ X-B3-Spanid:
30
+ - b26c426aabc12b98
31
+ X-B3-Traceid:
32
+ - b26c426aabc12b98
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
+ - Tue, 22 Nov 2016 14:27:24 GMT
49
+ Connection:
50
+ - close
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"unread":2}'
54
+ http_version:
55
+ recorded_at: Tue, 22 Nov 2016 14:26:56 GMT
56
+ recorded_with: VCR 3.0.3
data/spec/users_spec.rb CHANGED
@@ -98,4 +98,34 @@ describe Lifen::User do
98
98
  end
99
99
 
100
100
  end
101
+
102
+ describe ':refresh_unread_messages' do
103
+
104
+ context 'invalid token' do
105
+
106
+ let(:user) { Lifen::User.new(token: "invalid_token") }
107
+
108
+ it 'raises an error' do
109
+ expect{
110
+ VCR.use_cassette "users/refresh_unread_messages/invalid_token" do
111
+ user.refresh_unread_messages
112
+ end
113
+ }.to raise_error(Lifen::Error)
114
+ end
115
+ end
116
+
117
+ context 'valid token' do
118
+
119
+ let(:user) { Lifen::User.new(token: "valid_token") }
120
+
121
+ it 'raises an error' do
122
+ VCR.use_cassette "users/refresh_unread_messages/valid_token" do
123
+ user.refresh_unread_messages
124
+ end
125
+
126
+ expect(user.unread_messages).to eq 2
127
+ end
128
+ end
129
+
130
+ end
101
131
  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.3
4
+ version: 0.1.4
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-02 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,28 +98,28 @@ dependencies:
98
98
  name: virtus
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: faraday
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0.9'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.9'
125
125
  description: Lifen API ruby client
@@ -146,6 +146,7 @@ files:
146
146
  - lib/lifen/error.rb
147
147
  - lib/lifen/flow.rb
148
148
  - lib/lifen/flows.rb
149
+ - lib/lifen/status.rb
149
150
  - lib/lifen/user.rb
150
151
  - lib/lifen/user_authenticated_client.rb
151
152
  - lib/lifen/version.rb
@@ -164,6 +165,8 @@ files:
164
165
  - spec/cassettes/users/create/valid_attributes.yml
165
166
  - spec/cassettes/users/refresh/invalid_user_uuid.yml
166
167
  - spec/cassettes/users/refresh/valid_user_uuid.yml
168
+ - spec/cassettes/users/refresh_unread_messages/invalid_token.yml
169
+ - spec/cassettes/users/refresh_unread_messages/valid_token.yml
167
170
  - spec/flows_spec.rb
168
171
  - spec/spec_helper.rb
169
172
  - spec/users_spec.rb
@@ -187,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
190
  version: '0'
188
191
  requirements: []
189
192
  rubyforge_project:
190
- rubygems_version: 2.5.1
193
+ rubygems_version: 2.5.2
191
194
  signing_key:
192
195
  specification_version: 4
193
196
  summary: Lifen JSON API ruby client
@@ -206,6 +209,8 @@ test_files:
206
209
  - spec/cassettes/users/create/valid_attributes.yml
207
210
  - spec/cassettes/users/refresh/invalid_user_uuid.yml
208
211
  - spec/cassettes/users/refresh/valid_user_uuid.yml
212
+ - spec/cassettes/users/refresh_unread_messages/invalid_token.yml
213
+ - spec/cassettes/users/refresh_unread_messages/valid_token.yml
209
214
  - spec/flows_spec.rb
210
215
  - spec/spec_helper.rb
211
216
  - spec/users_spec.rb