caren-api 0.7.0 → 0.8.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.
- data/VERSION +1 -1
- data/caren-api.gemspec +6 -2
- data/lib/caren/caren.rb +1 -0
- data/lib/caren/chat_session_message.rb +59 -0
- data/lib/caren-api.rb +1 -0
- data/spec/chat_session_message_spec.rb +64 -0
- data/spec/external_message_spec.rb +2 -2
- data/spec/fixtures/caren_chat_session_message.xml +13 -0
- data/spec/fixtures/caren_chat_session_messages.xml +27 -0
- metadata +7 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.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.8.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-
|
12
|
+
s.date = "2012-10-04"
|
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_message.rb",
|
35
36
|
"lib/caren/client.rb",
|
36
37
|
"lib/caren/employee.rb",
|
37
38
|
"lib/caren/error.rb",
|
@@ -52,6 +53,7 @@ Gem::Specification.new do |s|
|
|
52
53
|
"spec/.DS_Store",
|
53
54
|
"spec/care_provider_spec.rb",
|
54
55
|
"spec/caren_spec.rb",
|
56
|
+
"spec/chat_session_message_spec.rb",
|
55
57
|
"spec/client_spec.rb",
|
56
58
|
"spec/employee_spec.rb",
|
57
59
|
"spec/event_slot_container_spec.rb",
|
@@ -73,6 +75,8 @@ Gem::Specification.new do |s|
|
|
73
75
|
"spec/fixtures/caren_care_provider_validation.xml",
|
74
76
|
"spec/fixtures/caren_care_providers.xml",
|
75
77
|
"spec/fixtures/caren_care_providers_search.xml",
|
78
|
+
"spec/fixtures/caren_chat_session_message.xml",
|
79
|
+
"spec/fixtures/caren_chat_session_messages.xml",
|
76
80
|
"spec/fixtures/caren_event.xml",
|
77
81
|
"spec/fixtures/caren_events.xml",
|
78
82
|
"spec/fixtures/caren_external_message.xml",
|
data/lib/caren/caren.rb
CHANGED
@@ -120,6 +120,7 @@ module Caren
|
|
120
120
|
def self.supported_incoming_objects
|
121
121
|
{ :links => Caren::Link,
|
122
122
|
:external_messages => Caren::ExternalMessage,
|
123
|
+
:chat_session_messages => Caren::ChatSessionMessage,
|
123
124
|
:care_providers => Caren::CareProvider,
|
124
125
|
:billable_categories => Caren::Store::BillableCategory,
|
125
126
|
:billables => Caren::Store::Billable,
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class Caren::ChatSessionMessage < 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)
|
7
|
+
:external_person_id, # String (Your person id)
|
8
|
+
:care_provider_id, # Integer (Caren CP id)
|
9
|
+
:body, # Text
|
10
|
+
:external_id, # String (Your message id)
|
11
|
+
:in_reply_to_id, # Integer (Caren message id)
|
12
|
+
:in_reply_to_type, # The type of message this is a reply to. (Always ChatSessionMessage if reply is set)
|
13
|
+
:subject_id # Integer (Caren person id)
|
14
|
+
] + super
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.all subject_id, session
|
18
|
+
from_xml session.get(self.resource_url(subject_id))
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.find subject_id, id, session
|
22
|
+
from_xml session.get(self.resource_url(subject_id,id))
|
23
|
+
end
|
24
|
+
|
25
|
+
def create session
|
26
|
+
self.class.from_xml session.post self.class.resource_url(self.subject_id), self.to_xml
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.array_root
|
30
|
+
:chat_session_messages
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.node_root
|
34
|
+
:chat_session_message
|
35
|
+
end
|
36
|
+
|
37
|
+
def as_xml
|
38
|
+
{ :person_name => self.person_name,
|
39
|
+
:external_person_id => self.external_person_id,
|
40
|
+
:body => self.body,
|
41
|
+
:external_id => self.external_id,
|
42
|
+
:in_reply_to_id => self.in_reply_to_id }
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.resource_location
|
46
|
+
"/api/pro/people/%i/chat_session_messages"
|
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,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ChatSessionMessage", "converting to xml" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@chat_session_message_a = Caren::ChatSessionMessage.new( :person_name => "Andre Foeken",
|
7
|
+
:external_person_id => 1,
|
8
|
+
:body => "Test message",
|
9
|
+
:external_id => 1,
|
10
|
+
:in_reply_to_id => nil )
|
11
|
+
|
12
|
+
@chat_session_message_b = Caren::ChatSessionMessage.new( :person_name => "Ria Foeken",
|
13
|
+
:external_person_id => 2,
|
14
|
+
:body => "Test message reply",
|
15
|
+
:external_id => 2,
|
16
|
+
:in_reply_to_id => 99 )
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be able to convert a chat session messages to valid xml" do
|
20
|
+
@chat_session_message_a.should convert_to_valid_caren_xml
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be able to convert an array of chat session messages to valid xml" do
|
24
|
+
[@chat_session_message_a,@chat_session_message_b].should convert_to_valid_caren_array_xml
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "ExternalMessage", "REST methods" do
|
30
|
+
|
31
|
+
before do
|
32
|
+
message = File.read("spec/fixtures/caren_chat_session_message.xml")
|
33
|
+
messages = File.read("spec/fixtures/caren_chat_session_messages.xml")
|
34
|
+
|
35
|
+
messages_url = Caren::Api.session.url_for( Caren::ChatSessionMessage.resource_url(1) )
|
36
|
+
message_url = Caren::Api.session.url_for( Caren::ChatSessionMessage.resource_url(1,1) )
|
37
|
+
timestamp = DateTime.now.to_i
|
38
|
+
|
39
|
+
FakeWeb.register_uri(:get, messages_url, :body => messages, :signature => Caren::Api.session.sign(timestamp,nil,messages), :timestamp => timestamp )
|
40
|
+
FakeWeb.register_uri(:get, message_url, :body => message, :signature => Caren::Api.session.sign(timestamp,nil,message), :timestamp => timestamp )
|
41
|
+
FakeWeb.register_uri(:post, messages_url, :status => 201, :signature => Caren::Api.session.sign(timestamp), :timestamp => timestamp )
|
42
|
+
FakeWeb.register_uri(:delete, message_url, :signature => Caren::Api.session.sign(timestamp), :timestamp => timestamp )
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should be able to find all chat session messages" do
|
46
|
+
messages = Caren::ChatSessionMessage.all 1, Caren::Api.session
|
47
|
+
messages.should have(2).things
|
48
|
+
messages.first.body.should == "Test"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be able to find one chat session messages" do
|
52
|
+
message = Caren::ChatSessionMessage.find 1, 1, Caren::Api.session
|
53
|
+
message.body.should == "Test"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be able to create a chat session message" do
|
57
|
+
lambda{ Caren::ChatSessionMessage.new( :person_name => "Andre Foeken",
|
58
|
+
:external_person_id => 1,
|
59
|
+
:body => "Test message",
|
60
|
+
:external_id => 1,
|
61
|
+
:subject_id => 1 ).create(Caren::Api.session) }.should_not raise_error
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -16,11 +16,11 @@ describe "ExternalMessage", "converting to xml" do
|
|
16
16
|
:in_reply_to_id => 99 )
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should be able to convert
|
19
|
+
it "should be able to convert an external message to valid xml" do
|
20
20
|
@external_message_a.should convert_to_valid_caren_xml
|
21
21
|
end
|
22
22
|
|
23
|
-
it "should be able to convert an array of
|
23
|
+
it "should be able to convert an array of external messages to valid xml" do
|
24
24
|
[@external_message_a,@external_message_b].should convert_to_valid_caren_array_xml
|
25
25
|
end
|
26
26
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<chat-session-message>
|
3
|
+
<created-at type="datetime">2011-09-09T15:14:13+02:00</created-at>
|
4
|
+
<body>Test</body>
|
5
|
+
<updated-at type="datetime">2011-09-09T15:14:13+02:00</updated-at>
|
6
|
+
<in-reply-to-id type="integer" nil="true"></in-reply-to-id>
|
7
|
+
<subject-id type="integer">5</subject-id>
|
8
|
+
<id type="integer">1</id>
|
9
|
+
<in-reply-to-type nil="true"></in-reply-to-type>
|
10
|
+
<care-provider-id type="integer">1</care-provider-id>
|
11
|
+
<person-id type="integer">1</person-id>
|
12
|
+
<external-person-id nil="true"></external-person-id>
|
13
|
+
</chat-session-message>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<chat-session-messages type="array">
|
3
|
+
<chat-session-message>
|
4
|
+
<created-at type="datetime">2011-09-09T15:14:13+02:00</created-at>
|
5
|
+
<body>Test</body>
|
6
|
+
<updated-at type="datetime">2011-09-09T15:14:13+02:00</updated-at>
|
7
|
+
<in-reply-to-id type="integer" nil="true"></in-reply-to-id>
|
8
|
+
<subject-id type="integer">5</subject-id>
|
9
|
+
<id type="integer">1</id>
|
10
|
+
<in-reply-to-type nil="true"></in-reply-to-type>
|
11
|
+
<care-provider-id type="integer">1</care-provider-id>
|
12
|
+
<person-id type="integer">1</person-id>
|
13
|
+
<external-person-id nil="true"></external-person-id>
|
14
|
+
</chat-session-message>
|
15
|
+
<chat-session-message>
|
16
|
+
<created-at type="datetime">2011-09-09T15:14:13+02:00</created-at>
|
17
|
+
<body>Does it work ...</body>
|
18
|
+
<updated-at type="datetime">2011-09-09T15:14:13+02:00</updated-at>
|
19
|
+
<in-reply-to-id type="integer" nil="true"></in-reply-to-id>
|
20
|
+
<subject-id type="integer">5</subject-id>
|
21
|
+
<id type="integer">2</id>
|
22
|
+
<in-reply-to-type nil="true"></in-reply-to-type>
|
23
|
+
<care-provider-id type="integer">1</care-provider-id>
|
24
|
+
<person-id type="integer">1</person-id>
|
25
|
+
<external-person-id nil="true"></external-person-id>
|
26
|
+
</chat-session-message>
|
27
|
+
</chat-session-messages>
|
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.8.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-
|
12
|
+
date: 2012-10-04 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_message.rb
|
182
183
|
- lib/caren/client.rb
|
183
184
|
- lib/caren/employee.rb
|
184
185
|
- lib/caren/error.rb
|
@@ -199,6 +200,7 @@ files:
|
|
199
200
|
- spec/.DS_Store
|
200
201
|
- spec/care_provider_spec.rb
|
201
202
|
- spec/caren_spec.rb
|
203
|
+
- spec/chat_session_message_spec.rb
|
202
204
|
- spec/client_spec.rb
|
203
205
|
- spec/employee_spec.rb
|
204
206
|
- spec/event_slot_container_spec.rb
|
@@ -220,6 +222,8 @@ files:
|
|
220
222
|
- spec/fixtures/caren_care_provider_validation.xml
|
221
223
|
- spec/fixtures/caren_care_providers.xml
|
222
224
|
- spec/fixtures/caren_care_providers_search.xml
|
225
|
+
- spec/fixtures/caren_chat_session_message.xml
|
226
|
+
- spec/fixtures/caren_chat_session_messages.xml
|
223
227
|
- spec/fixtures/caren_event.xml
|
224
228
|
- spec/fixtures/caren_events.xml
|
225
229
|
- spec/fixtures/caren_external_message.xml
|
@@ -261,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
261
265
|
version: '0'
|
262
266
|
segments:
|
263
267
|
- 0
|
264
|
-
hash:
|
268
|
+
hash: 127445655277471062
|
265
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
270
|
none: false
|
267
271
|
requirements:
|