lifen 0.1.5 → 0.2.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/lifen.rb +1 -0
- data/lib/lifen/message.rb +34 -0
- data/lib/lifen/version.rb +1 -1
- data/spec/cassettes/messages/valid_message.yml +57 -0
- data/spec/messages_spec.rb +30 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e020ba55f8060ba2aee6a8f5a8d11be901ca23ce
|
4
|
+
data.tar.gz: e70f400e649576ce7db7df4d15e9f58d15fd58ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9adf3bec7ffd0a1047356ed1a046ea2e2203c6ed7bd810cf0a4e23b2cc3957acd039d9d1a941d8b34c08175d1d34a5f712ade496af6ad139e7b60186caccfb82
|
7
|
+
data.tar.gz: 6d841f1e80fe39ab291a3496f339b764783910c0b9eb368721efb80869dce74c104dc182699f54b8da23a76c9af90e8310da925603f810a05c77b7073743a1c5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,6 +35,7 @@ Lifen can be configured (ideally inside an initializer) like so:
|
|
35
35
|
user = Lifen::User.new(email: "email@domain.tld", first_name: "Jean", last_name: "Dupont")
|
36
36
|
user.create!
|
37
37
|
user.refresh_token
|
38
|
+
user.refresh_unread_messages
|
38
39
|
|
39
40
|
### Managing flows
|
40
41
|
|
@@ -46,6 +47,11 @@ Lifen can be configured (ideally inside an initializer) like so:
|
|
46
47
|
flow.attach_users!(user)
|
47
48
|
flow.detach_users!(user)
|
48
49
|
|
50
|
+
### Managing messages
|
51
|
+
|
52
|
+
message = Lifen::Message.new(flow: flow, content: "Hello World !")
|
53
|
+
message.create
|
54
|
+
|
49
55
|
## Contributing
|
50
56
|
|
51
57
|
1. Fork it
|
data/lib/lifen.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Lifen
|
2
|
+
class Message < Base
|
3
|
+
|
4
|
+
attribute :uuid, String
|
5
|
+
attribute :content, String
|
6
|
+
attribute :type, String, default: "regular"
|
7
|
+
attribute :flow, Lifen::Flow
|
8
|
+
attribute :sent_at, DateTime
|
9
|
+
|
10
|
+
|
11
|
+
def create
|
12
|
+
json = client.post("central/api/chats/#{flow.uuid}/messages", {content: content, type: type})
|
13
|
+
|
14
|
+
json["sent_at"] = json["sentDate"]
|
15
|
+
|
16
|
+
message = self.class.new(json)
|
17
|
+
|
18
|
+
self.flow = flow
|
19
|
+
self.uuid = message.uuid
|
20
|
+
self.content = message.content
|
21
|
+
self.type = message.type
|
22
|
+
self.sent_at = message.sent_at
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def client
|
30
|
+
@client ||= flow.user.client
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/lifen/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://develop.lifen.fr/central/api/chats/11e6b870-37a5-59af-ac0e-0242ac110002/messages
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"content":"Bonjour Lifen"}'
|
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: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Apache-Coyote/1.1
|
27
|
+
X-B3-Sampled:
|
28
|
+
- '1'
|
29
|
+
X-B3-Spanid:
|
30
|
+
- a8262c0e7a907672
|
31
|
+
X-B3-Traceid:
|
32
|
+
- a8262c0e7a907672
|
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
|
+
- Fri, 02 Dec 2016 09:24:25 GMT
|
49
|
+
Connection:
|
50
|
+
- close
|
51
|
+
body:
|
52
|
+
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}'
|
55
|
+
http_version:
|
56
|
+
recorded_at: Fri, 02 Dec 2016 09:23:50 GMT
|
57
|
+
recorded_with: VCR 3.0.3
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lifen::Message do
|
4
|
+
|
5
|
+
let(:user) { Lifen::User.new(token: "valid_token") }
|
6
|
+
let(:flow) { Lifen::Flow.new(user: user, uuid: "11e6b870-37a5-59af-ac0e-0242ac110002") }
|
7
|
+
let(:message) { Lifen::Message.new(flow: flow, content: "Bonjour Lifen") }
|
8
|
+
|
9
|
+
describe "create" do
|
10
|
+
|
11
|
+
context "valid message" do
|
12
|
+
|
13
|
+
it 'has valid attributes' do
|
14
|
+
|
15
|
+
VCR.use_cassette "messages/valid_message" do
|
16
|
+
message.create
|
17
|
+
end
|
18
|
+
|
19
|
+
expect(message.uuid).to eq("11e6b871-1e02-9662-ac0e-0242ac110002")
|
20
|
+
expect(message.type).to eq("regular")
|
21
|
+
expect(message.flow).to eq(flow)
|
22
|
+
expect(message.sent_at.to_date).to eq Date.new(2016, 12, 2)
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
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.
|
4
|
+
version: 0.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-
|
11
|
+
date: 2016-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -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/message.rb
|
149
150
|
- lib/lifen/status.rb
|
150
151
|
- lib/lifen/user.rb
|
151
152
|
- lib/lifen/user_authenticated_client.rb
|
@@ -161,6 +162,7 @@ files:
|
|
161
162
|
- spec/cassettes/flows/internal_error_without_trace_id.yml
|
162
163
|
- spec/cassettes/flows/invalid_token.yml
|
163
164
|
- spec/cassettes/flows/valid_token.yml
|
165
|
+
- spec/cassettes/messages/valid_message.yml
|
164
166
|
- spec/cassettes/users/create/existing_user.yml
|
165
167
|
- spec/cassettes/users/create/invalid_token.yml
|
166
168
|
- spec/cassettes/users/create/missing_fields.yml
|
@@ -170,6 +172,7 @@ files:
|
|
170
172
|
- spec/cassettes/users/refresh_unread_messages/invalid_token.yml
|
171
173
|
- spec/cassettes/users/refresh_unread_messages/valid_token.yml
|
172
174
|
- spec/flows_spec.rb
|
175
|
+
- spec/messages_spec.rb
|
173
176
|
- spec/spec_helper.rb
|
174
177
|
- spec/users_spec.rb
|
175
178
|
homepage: https://github.com/honestica/lifen
|
@@ -207,6 +210,7 @@ test_files:
|
|
207
210
|
- spec/cassettes/flows/internal_error_without_trace_id.yml
|
208
211
|
- spec/cassettes/flows/invalid_token.yml
|
209
212
|
- spec/cassettes/flows/valid_token.yml
|
213
|
+
- spec/cassettes/messages/valid_message.yml
|
210
214
|
- spec/cassettes/users/create/existing_user.yml
|
211
215
|
- spec/cassettes/users/create/invalid_token.yml
|
212
216
|
- spec/cassettes/users/create/missing_fields.yml
|
@@ -216,5 +220,6 @@ test_files:
|
|
216
220
|
- spec/cassettes/users/refresh_unread_messages/invalid_token.yml
|
217
221
|
- spec/cassettes/users/refresh_unread_messages/valid_token.yml
|
218
222
|
- spec/flows_spec.rb
|
223
|
+
- spec/messages_spec.rb
|
219
224
|
- spec/spec_helper.rb
|
220
225
|
- spec/users_spec.rb
|