caren-api 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/caren-api.gemspec +6 -2
- data/lib/caren/base.rb +1 -1
- data/lib/caren/chat_session.rb +59 -0
- data/lib/caren-api.rb +1 -0
- data/spec/chat_session_message_spec.rb +1 -1
- data/spec/chat_session_spec.rb +50 -0
- data/spec/fixtures/caren_chat_session.xml +18 -0
- data/spec/fixtures/caren_chat_sessions.xml +37 -0
- metadata +7 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/caren-api.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "caren-api"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.9.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andre Foeken"]
|
12
|
-
s.date = "2012-10-
|
12
|
+
s.date = "2012-10-05"
|
13
13
|
s.description = "You can use this gem as inspiration of the base of your connections with Caren."
|
14
14
|
s.email = "andre.foeken@nedap.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/caren/base.rb",
|
33
33
|
"lib/caren/care_provider.rb",
|
34
34
|
"lib/caren/caren.rb",
|
35
|
+
"lib/caren/chat_session.rb",
|
35
36
|
"lib/caren/chat_session_message.rb",
|
36
37
|
"lib/caren/client.rb",
|
37
38
|
"lib/caren/employee.rb",
|
@@ -54,6 +55,7 @@ Gem::Specification.new do |s|
|
|
54
55
|
"spec/care_provider_spec.rb",
|
55
56
|
"spec/caren_spec.rb",
|
56
57
|
"spec/chat_session_message_spec.rb",
|
58
|
+
"spec/chat_session_spec.rb",
|
57
59
|
"spec/client_spec.rb",
|
58
60
|
"spec/employee_spec.rb",
|
59
61
|
"spec/event_slot_container_spec.rb",
|
@@ -75,8 +77,10 @@ Gem::Specification.new do |s|
|
|
75
77
|
"spec/fixtures/caren_care_provider_validation.xml",
|
76
78
|
"spec/fixtures/caren_care_providers.xml",
|
77
79
|
"spec/fixtures/caren_care_providers_search.xml",
|
80
|
+
"spec/fixtures/caren_chat_session.xml",
|
78
81
|
"spec/fixtures/caren_chat_session_message.xml",
|
79
82
|
"spec/fixtures/caren_chat_session_messages.xml",
|
83
|
+
"spec/fixtures/caren_chat_sessions.xml",
|
80
84
|
"spec/fixtures/caren_event.xml",
|
81
85
|
"spec/fixtures/caren_events.xml",
|
82
86
|
"spec/fixtures/caren_external_message.xml",
|
data/lib/caren/base.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
class Caren::ChatSession < Caren::Base
|
2
|
+
|
3
|
+
def self.keys
|
4
|
+
[ :id, # Integer (Caren message id)
|
5
|
+
:person_name, # String (Andre Foeken)
|
6
|
+
:person_id, # Integer (Caren person id, if applicable)
|
7
|
+
:external_person_id, # String (Your person id)
|
8
|
+
:care_provider_id, # Integer (Caren CP id)
|
9
|
+
:comment, # Text
|
10
|
+
:external_id, # String (Your message id)
|
11
|
+
:billable_id, # String (Caren billable id)
|
12
|
+
:event_id, # String (Caren event id)
|
13
|
+
:starts_at, # DateTime
|
14
|
+
:ends_at, # DateTime
|
15
|
+
:duration, # DateTime
|
16
|
+
:subject_id # Integer (Caren person id)
|
17
|
+
] + super
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.all subject_id, session
|
21
|
+
from_xml session.get(self.resource_url(subject_id))
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find subject_id, id, session
|
25
|
+
from_xml session.get(self.resource_url(subject_id,id))
|
26
|
+
end
|
27
|
+
|
28
|
+
def update session
|
29
|
+
self.class.from_xml session.put self.class.resource_url(self.subject_id,self.id), self.to_xml
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.array_root
|
33
|
+
:chat_sessions
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.node_root
|
37
|
+
:chat_session
|
38
|
+
end
|
39
|
+
|
40
|
+
def as_xml
|
41
|
+
{ :starts_at => self.starts_at,
|
42
|
+
:ends_at => self.ends_at }
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.resource_location
|
46
|
+
"/api/pro/people/%i/chat_sessions"
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def resource_url subject_id, id=nil
|
52
|
+
self.class.resource_url(subject_id,id)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.resource_url subject_id, id=nil
|
56
|
+
"#{self.resource_location % subject_id}#{id}"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/lib/caren-api.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ChatSession", "converting to xml" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@chat_session_a = Caren::ChatSessionMessage.new( :starts_at => DateTime.now, :ends_at => 2.hours.from_now )
|
7
|
+
@chat_session_b = Caren::ChatSessionMessage.new( :starts_at => DateTime.now, :ends_at => 3.hours.from_now )
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be able to convert a chat session messages to valid xml" do
|
11
|
+
@chat_session_a.should convert_to_valid_caren_xml
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be able to convert an array of chat session messages to valid xml" do
|
15
|
+
[@chat_session_a,@chat_session_b].should convert_to_valid_caren_array_xml
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "ChatSession", "REST methods" do
|
21
|
+
|
22
|
+
before do
|
23
|
+
session = File.read("spec/fixtures/caren_chat_session.xml")
|
24
|
+
sessions = File.read("spec/fixtures/caren_chat_sessions.xml")
|
25
|
+
|
26
|
+
sessions_url = Caren::Api.session.url_for( Caren::ChatSession.resource_url(1) )
|
27
|
+
session_url = Caren::Api.session.url_for( Caren::ChatSession.resource_url(1,1) )
|
28
|
+
timestamp = DateTime.now.to_i
|
29
|
+
|
30
|
+
FakeWeb.register_uri(:get, sessions_url, :body => sessions, :signature => Caren::Api.session.sign(timestamp,nil,sessions), :timestamp => timestamp )
|
31
|
+
FakeWeb.register_uri(:get, session_url, :body => session, :signature => Caren::Api.session.sign(timestamp,nil,session), :timestamp => timestamp )
|
32
|
+
FakeWeb.register_uri(:put, session_url, :status => 204, :signature => Caren::Api.session.sign(timestamp), :timestamp => timestamp )
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to find all chat sessions" do
|
36
|
+
sessions = Caren::ChatSession.all 1, Caren::Api.session
|
37
|
+
sessions.should have(2).things
|
38
|
+
sessions.first.comment.should == "Test"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should be able to find one chat session" do
|
42
|
+
sessions = Caren::ChatSession.find 1, 1, Caren::Api.session
|
43
|
+
sessions.comment.should == "Test"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be able to update a chat session" do
|
47
|
+
lambda{ Caren::ChatSession.new( :starts_at => DateTime.now, :id => 1, :subject_id => 1 ).update(Caren::Api.session) }.should_not raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<chat-session>
|
3
|
+
<billable-id type="integer"></billable-id>
|
4
|
+
<care-provider-id type="integer"></care-provider-id>
|
5
|
+
<comment>Test</comment>
|
6
|
+
<created-at type="datetime"></created-at>
|
7
|
+
<duration type="integer"></duration>
|
8
|
+
<ends-at type="datetime"></ends-at>
|
9
|
+
<external-id>1</external-id>
|
10
|
+
<external-person-id></external-person-id>
|
11
|
+
<id type="integer"></id>
|
12
|
+
<person-id type="integer"></person-id>
|
13
|
+
<person-name></person-name>
|
14
|
+
<starts-at type="datetime"></starts-at>
|
15
|
+
<subject-id type="integer"></subject-id>
|
16
|
+
<updated-at type="datetime"></updated-at>
|
17
|
+
<event-id>1</event-id>
|
18
|
+
</chat-session>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<chat-sessions type="array">
|
3
|
+
<chat-session>
|
4
|
+
<billable-id type="integer"></billable-id>
|
5
|
+
<care-provider-id type="integer"></care-provider-id>
|
6
|
+
<comment>Test</comment>
|
7
|
+
<created-at type="datetime"></created-at>
|
8
|
+
<duration type="integer"></duration>
|
9
|
+
<ends-at type="datetime"></ends-at>
|
10
|
+
<external-id>1</external-id>
|
11
|
+
<external-person-id></external-person-id>
|
12
|
+
<id type="integer"></id>
|
13
|
+
<person-id type="integer"></person-id>
|
14
|
+
<person-name></person-name>
|
15
|
+
<starts-at type="datetime"></starts-at>
|
16
|
+
<subject-id type="integer"></subject-id>
|
17
|
+
<updated-at type="datetime"></updated-at>
|
18
|
+
<event-id>1</event-id>
|
19
|
+
</chat-session>
|
20
|
+
<chat-session>
|
21
|
+
<billable-id type="integer"></billable-id>
|
22
|
+
<care-provider-id type="integer"></care-provider-id>
|
23
|
+
<comment>Test</comment>
|
24
|
+
<created-at type="datetime"></created-at>
|
25
|
+
<duration type="integer"></duration>
|
26
|
+
<ends-at type="datetime"></ends-at>
|
27
|
+
<external-id>2</external-id>
|
28
|
+
<external-person-id></external-person-id>
|
29
|
+
<id type="integer"></id>
|
30
|
+
<person-id type="integer"></person-id>
|
31
|
+
<person-name></person-name>
|
32
|
+
<starts-at type="datetime"></starts-at>
|
33
|
+
<subject-id type="integer"></subject-id>
|
34
|
+
<updated-at type="datetime"></updated-at>
|
35
|
+
<event-id>1</event-id>
|
36
|
+
</chat-session>
|
37
|
+
</chat-sessions>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caren-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- lib/caren/base.rb
|
180
180
|
- lib/caren/care_provider.rb
|
181
181
|
- lib/caren/caren.rb
|
182
|
+
- lib/caren/chat_session.rb
|
182
183
|
- lib/caren/chat_session_message.rb
|
183
184
|
- lib/caren/client.rb
|
184
185
|
- lib/caren/employee.rb
|
@@ -201,6 +202,7 @@ files:
|
|
201
202
|
- spec/care_provider_spec.rb
|
202
203
|
- spec/caren_spec.rb
|
203
204
|
- spec/chat_session_message_spec.rb
|
205
|
+
- spec/chat_session_spec.rb
|
204
206
|
- spec/client_spec.rb
|
205
207
|
- spec/employee_spec.rb
|
206
208
|
- spec/event_slot_container_spec.rb
|
@@ -222,8 +224,10 @@ files:
|
|
222
224
|
- spec/fixtures/caren_care_provider_validation.xml
|
223
225
|
- spec/fixtures/caren_care_providers.xml
|
224
226
|
- spec/fixtures/caren_care_providers_search.xml
|
227
|
+
- spec/fixtures/caren_chat_session.xml
|
225
228
|
- spec/fixtures/caren_chat_session_message.xml
|
226
229
|
- spec/fixtures/caren_chat_session_messages.xml
|
230
|
+
- spec/fixtures/caren_chat_sessions.xml
|
227
231
|
- spec/fixtures/caren_event.xml
|
228
232
|
- spec/fixtures/caren_events.xml
|
229
233
|
- spec/fixtures/caren_external_message.xml
|
@@ -265,7 +269,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
265
269
|
version: '0'
|
266
270
|
segments:
|
267
271
|
- 0
|
268
|
-
hash:
|
272
|
+
hash: 3668323460698022586
|
269
273
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
274
|
none: false
|
271
275
|
requirements:
|