caren-api 0.4.19 → 0.4.20
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 +9 -10
- data/lib/caren/base.rb +1 -0
- data/lib/caren/caren.rb +5 -5
- data/lib/caren-api.rb +1 -1
- data/spec/care_provider_spec.rb +3 -3
- data/spec/caren_spec.rb +1 -1
- data/spec/external_message_spec.rb +2 -2
- data/spec/link_spec.rb +3 -3
- data/spec/product_category_spec.rb +3 -3
- data/spec/product_spec.rb +4 -4
- metadata +70 -60
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.20
|
data/caren-api.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.4.
|
7
|
+
s.name = "caren-api"
|
8
|
+
s.version = "0.4.20"
|
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 =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2012-01-23"
|
13
|
+
s.description = "You can use this gem as inspiration of the base of your connections with Caren."
|
14
|
+
s.email = "andre.foeken@nedap.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
17
|
"README.rdoc"
|
@@ -71,17 +71,16 @@ Gem::Specification.new do |s|
|
|
71
71
|
"spec/spec.opts",
|
72
72
|
"spec/spec_helper.rb"
|
73
73
|
]
|
74
|
-
s.homepage =
|
74
|
+
s.homepage = "http://github.com/foeken/caren-api"
|
75
75
|
s.licenses = ["MIT"]
|
76
76
|
s.require_paths = ["lib"]
|
77
|
-
s.rubygems_version =
|
78
|
-
s.summary =
|
77
|
+
s.rubygems_version = "1.8.15"
|
78
|
+
s.summary = "Reference implementation of Caren CareProvider API"
|
79
79
|
|
80
80
|
if s.respond_to? :specification_version then
|
81
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
82
81
|
s.specification_version = 3
|
83
82
|
|
84
|
-
if Gem::Version.new(Gem::
|
83
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
85
84
|
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
86
85
|
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
87
86
|
s.add_runtime_dependency(%q<builder>, [">= 0"])
|
data/lib/caren/base.rb
CHANGED
@@ -42,6 +42,7 @@ class Caren::Base
|
|
42
42
|
|
43
43
|
# Convert a XML string to a single object or an array of objects
|
44
44
|
def self.from_xml xml
|
45
|
+
return nil if xml == ''
|
45
46
|
hash = xml.is_a?(Hash) ? xml : Hash.from_xml(xml)
|
46
47
|
raise Caren::Exceptions::InvalidXmlResponse unless hash
|
47
48
|
if hash.has_key?(self.array_root.to_s)
|
data/lib/caren/caren.rb
CHANGED
@@ -166,8 +166,8 @@ module Caren
|
|
166
166
|
|
167
167
|
# Sign your string and timestamp using private key
|
168
168
|
# Timestamp is UNIX timestamp seconds since 1970
|
169
|
-
def sign timestamp, path, string=nil, private_key=self.private_key
|
170
|
-
path = URI.parse(path).path
|
169
|
+
def sign timestamp, path=nil, string=nil, private_key=self.private_key
|
170
|
+
path = URI.parse(path).path if path
|
171
171
|
encrypted_digest = private_key.sign( "sha1", path.to_s + string.to_s + timestamp.to_s )
|
172
172
|
signature = CGI.escape(Base64.encode64(encrypted_digest))
|
173
173
|
return signature
|
@@ -175,15 +175,15 @@ module Caren
|
|
175
175
|
|
176
176
|
# Check the signature of the response from rest-client
|
177
177
|
def check_signature response
|
178
|
-
return response if self.verify_signature( response.headers[:signature], response.headers[:timestamp], response )
|
178
|
+
return response if self.verify_signature( response.headers[:signature], response.headers[:timestamp], nil, response )
|
179
179
|
raise Caren::Exceptions::SignatureMismatch.new
|
180
180
|
end
|
181
181
|
|
182
182
|
# Verify the signature using the caren public key
|
183
|
-
def verify_signature signature, timestamp, string=nil, public_key=self.caren_public_key
|
183
|
+
def verify_signature signature, timestamp, path, string=nil, public_key=self.caren_public_key
|
184
184
|
return false unless public_key
|
185
185
|
signature = Base64.decode64(CGI.unescape(signature.to_s))
|
186
|
-
public_key.verify( "sha1", signature, string.to_s + timestamp.to_s )
|
186
|
+
public_key.verify( "sha1", signature, path.to_s + string.to_s + timestamp.to_s )
|
187
187
|
end
|
188
188
|
|
189
189
|
def create_photo_signature url_shortcut, external_or_caren_id, private_key=self.private_key
|
data/lib/caren-api.rb
CHANGED
data/spec/care_provider_spec.rb
CHANGED
@@ -81,9 +81,9 @@ describe "CareProvider", "REST methods" do
|
|
81
81
|
timestamp = DateTime.now.to_i
|
82
82
|
|
83
83
|
FakeWeb.register_uri(:put, care_provider_url, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp) )
|
84
|
-
FakeWeb.register_uri(:get, care_provider_url, :body => care_provider, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,care_provider) )
|
85
|
-
FakeWeb.register_uri(:get, care_providers_url, :body => care_providers, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,care_providers) )
|
86
|
-
FakeWeb.register_uri(:get, search_url, :body => care_providers_search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,care_providers_search) )
|
84
|
+
FakeWeb.register_uri(:get, care_provider_url, :body => care_provider, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,care_provider) )
|
85
|
+
FakeWeb.register_uri(:get, care_providers_url, :body => care_providers, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,care_providers) )
|
86
|
+
FakeWeb.register_uri(:get, search_url, :body => care_providers_search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,care_providers_search) )
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should be able to update a care provider" do
|
data/spec/caren_spec.rb
CHANGED
@@ -74,7 +74,7 @@ describe "Caren", "signature checks" do
|
|
74
74
|
it "should be able to handle incoming xml from caren" do
|
75
75
|
incoming = File.read "spec/fixtures/incoming.xml"
|
76
76
|
timestamp = DateTime.now.to_i
|
77
|
-
results = Caren::Api.session.incoming(incoming, Caren::Api.session.sign(timestamp, incoming), timestamp )
|
77
|
+
results = Caren::Api.session.incoming(incoming, Caren::Api.session.sign(timestamp, nil, incoming), timestamp )
|
78
78
|
results.should have(4).things
|
79
79
|
external_messages = results.select{ |x| x.is_a?(Caren::ExternalMessage) }
|
80
80
|
external_messages.first.id.should == 1
|
@@ -36,8 +36,8 @@ describe "ExternalMessage", "REST methods" do
|
|
36
36
|
message_url = Caren::Api.session.url_for( Caren::ExternalMessage.resource_url(1,1) )
|
37
37
|
timestamp = DateTime.now.to_i
|
38
38
|
|
39
|
-
FakeWeb.register_uri(:get, messages_url, :body => messages, :signature => Caren::Api.session.sign(timestamp,messages), :timestamp => timestamp )
|
40
|
-
FakeWeb.register_uri(:get, message_url, :body => message, :signature => Caren::Api.session.sign(timestamp,message), :timestamp => timestamp )
|
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
41
|
FakeWeb.register_uri(:post, messages_url, :status => 201, :signature => Caren::Api.session.sign(timestamp), :timestamp => timestamp )
|
42
42
|
FakeWeb.register_uri(:delete, message_url, :signature => Caren::Api.session.sign(timestamp), :timestamp => timestamp )
|
43
43
|
end
|
data/spec/link_spec.rb
CHANGED
@@ -30,9 +30,9 @@ describe "Link", "REST methods" do
|
|
30
30
|
|
31
31
|
timestamp = DateTime.now.to_i
|
32
32
|
|
33
|
-
FakeWeb.register_uri(:get, link_url, :body => link, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,link) )
|
34
|
-
FakeWeb.register_uri(:get, links_url, :body => links, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,links) )
|
35
|
-
FakeWeb.register_uri(:get, search_url, :body => search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,search) )
|
33
|
+
FakeWeb.register_uri(:get, link_url, :body => link, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,link) )
|
34
|
+
FakeWeb.register_uri(:get, links_url, :body => links, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,links) )
|
35
|
+
FakeWeb.register_uri(:get, search_url, :body => search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,search) )
|
36
36
|
FakeWeb.register_uri(:post, links_url, :status => 201, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp) )
|
37
37
|
end
|
38
38
|
|
@@ -30,9 +30,9 @@ describe "ProductCategory", "REST methods" do
|
|
30
30
|
|
31
31
|
timestamp = DateTime.now.to_i
|
32
32
|
|
33
|
-
FakeWeb.register_uri(:get, product_categories_url, :body => product_categories, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,product_categories) )
|
34
|
-
FakeWeb.register_uri(:get, product_category_url, :body => product_category, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,product_category) )
|
35
|
-
FakeWeb.register_uri(:get, search_url, :body => product_categories_search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,product_categories_search) )
|
33
|
+
FakeWeb.register_uri(:get, product_categories_url, :body => product_categories, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,product_categories) )
|
34
|
+
FakeWeb.register_uri(:get, product_category_url, :body => product_category, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,product_category) )
|
35
|
+
FakeWeb.register_uri(:get, search_url, :body => product_categories_search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,product_categories_search) )
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should be able to search for a specific product category" do
|
data/spec/product_spec.rb
CHANGED
@@ -29,12 +29,12 @@ describe "Product", "REST methods" do
|
|
29
29
|
search_url = Caren::Api.session.url_for( "#{Caren::Product.resource_url}?key=name&value=bedpan" )
|
30
30
|
|
31
31
|
timestamp = DateTime.now.to_i
|
32
|
-
|
32
|
+
|
33
33
|
FakeWeb.register_uri(:post, products_url, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp) )
|
34
34
|
FakeWeb.register_uri(:put, product_url, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp) )
|
35
|
-
FakeWeb.register_uri(:get, products_url, :body => products, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,products) )
|
36
|
-
FakeWeb.register_uri(:get, product_url, :body => product, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,product) )
|
37
|
-
FakeWeb.register_uri(:get, search_url, :body => product_search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,product_search) )
|
35
|
+
FakeWeb.register_uri(:get, products_url, :body => products, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,products) )
|
36
|
+
FakeWeb.register_uri(:get, product_url, :body => product, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,product) )
|
37
|
+
FakeWeb.register_uri(:get, search_url, :body => product_search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,product_search) )
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should be able to update a product" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caren-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 39
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 4
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.4.19
|
9
|
+
- 20
|
10
|
+
version: 0.4.20
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andre Foeken
|
@@ -15,141 +15,150 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-01-23 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
|
24
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
25
23
|
requirements:
|
26
24
|
- - ">="
|
27
25
|
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
28
27
|
segments:
|
29
28
|
- 0
|
30
|
-
segments_generated: true
|
31
29
|
version: "0"
|
32
|
-
|
30
|
+
version_requirements: *id001
|
31
|
+
name: i18n
|
33
32
|
prerelease: false
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
33
|
type: :runtime
|
36
|
-
|
37
|
-
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
38
37
|
requirements:
|
39
38
|
- - ">="
|
40
39
|
- !ruby/object:Gem::Version
|
40
|
+
hash: 3
|
41
41
|
segments:
|
42
42
|
- 0
|
43
|
-
segments_generated: true
|
44
43
|
version: "0"
|
45
|
-
|
44
|
+
version_requirements: *id002
|
45
|
+
name: activesupport
|
46
46
|
prerelease: false
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
47
|
type: :runtime
|
49
|
-
|
50
|
-
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
54
55
|
segments:
|
55
56
|
- 0
|
56
|
-
segments_generated: true
|
57
57
|
version: "0"
|
58
|
-
|
58
|
+
version_requirements: *id003
|
59
|
+
name: builder
|
59
60
|
prerelease: false
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
61
|
type: :runtime
|
62
|
-
|
63
|
-
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
64
65
|
requirements:
|
65
66
|
- - "="
|
66
67
|
- !ruby/object:Gem::Version
|
68
|
+
hash: 1
|
67
69
|
segments:
|
68
70
|
- 1
|
69
71
|
- 6
|
70
72
|
- 7
|
71
|
-
segments_generated: true
|
72
73
|
version: 1.6.7
|
73
|
-
|
74
|
+
version_requirements: *id004
|
75
|
+
name: rest-client
|
74
76
|
prerelease: false
|
77
|
+
type: :runtime
|
75
78
|
- !ruby/object:Gem::Dependency
|
76
|
-
|
77
|
-
|
78
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
79
81
|
requirements:
|
80
82
|
- - ">="
|
81
83
|
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
82
85
|
segments:
|
83
86
|
- 0
|
84
|
-
segments_generated: true
|
85
87
|
version: "0"
|
86
|
-
|
88
|
+
version_requirements: *id005
|
89
|
+
name: bundler
|
87
90
|
prerelease: false
|
88
|
-
- !ruby/object:Gem::Dependency
|
89
91
|
type: :development
|
90
|
-
|
91
|
-
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
92
95
|
requirements:
|
93
96
|
- - ">="
|
94
97
|
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
95
99
|
segments:
|
96
100
|
- 0
|
97
|
-
segments_generated: true
|
98
101
|
version: "0"
|
99
|
-
|
102
|
+
version_requirements: *id006
|
103
|
+
name: rcov
|
100
104
|
prerelease: false
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
105
|
type: :development
|
103
|
-
|
104
|
-
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
105
109
|
requirements:
|
106
110
|
- - ">="
|
107
111
|
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
108
113
|
segments:
|
109
114
|
- 0
|
110
|
-
segments_generated: true
|
111
115
|
version: "0"
|
112
|
-
|
116
|
+
version_requirements: *id007
|
117
|
+
name: capybara
|
113
118
|
prerelease: false
|
114
|
-
- !ruby/object:Gem::Dependency
|
115
119
|
type: :development
|
116
|
-
|
117
|
-
|
120
|
+
- !ruby/object:Gem::Dependency
|
121
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
118
123
|
requirements:
|
119
124
|
- - ">="
|
120
125
|
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
121
127
|
segments:
|
122
128
|
- 0
|
123
|
-
segments_generated: true
|
124
129
|
version: "0"
|
125
|
-
|
130
|
+
version_requirements: *id008
|
131
|
+
name: rspec
|
126
132
|
prerelease: false
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
133
|
type: :development
|
129
|
-
|
130
|
-
|
134
|
+
- !ruby/object:Gem::Dependency
|
135
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
131
137
|
requirements:
|
132
138
|
- - ">="
|
133
139
|
- !ruby/object:Gem::Version
|
140
|
+
hash: 3
|
134
141
|
segments:
|
135
142
|
- 0
|
136
|
-
segments_generated: true
|
137
143
|
version: "0"
|
138
|
-
|
144
|
+
version_requirements: *id009
|
145
|
+
name: fakeweb
|
139
146
|
prerelease: false
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
147
|
type: :development
|
142
|
-
|
143
|
-
|
148
|
+
- !ruby/object:Gem::Dependency
|
149
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
144
151
|
requirements:
|
145
152
|
- - ">="
|
146
153
|
- !ruby/object:Gem::Version
|
154
|
+
hash: 3
|
147
155
|
segments:
|
148
156
|
- 0
|
149
|
-
segments_generated: true
|
150
157
|
version: "0"
|
151
|
-
|
158
|
+
version_requirements: *id010
|
159
|
+
name: jeweler
|
152
160
|
prerelease: false
|
161
|
+
type: :development
|
153
162
|
description: You can use this gem as inspiration of the base of your connections with Caren.
|
154
163
|
email: andre.foeken@nedap.com
|
155
164
|
executables: []
|
@@ -213,7 +222,6 @@ files:
|
|
213
222
|
- spec/product_spec.rb
|
214
223
|
- spec/spec.opts
|
215
224
|
- spec/spec_helper.rb
|
216
|
-
has_rdoc: true
|
217
225
|
homepage: http://github.com/foeken/caren-api
|
218
226
|
licenses:
|
219
227
|
- MIT
|
@@ -223,25 +231,27 @@ rdoc_options: []
|
|
223
231
|
require_paths:
|
224
232
|
- lib
|
225
233
|
required_ruby_version: !ruby/object:Gem::Requirement
|
234
|
+
none: false
|
226
235
|
requirements:
|
227
236
|
- - ">="
|
228
237
|
- !ruby/object:Gem::Version
|
238
|
+
hash: 3
|
229
239
|
segments:
|
230
240
|
- 0
|
231
|
-
segments_generated: true
|
232
241
|
version: "0"
|
233
242
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
|
+
none: false
|
234
244
|
requirements:
|
235
245
|
- - ">="
|
236
246
|
- !ruby/object:Gem::Version
|
247
|
+
hash: 3
|
237
248
|
segments:
|
238
249
|
- 0
|
239
|
-
segments_generated: true
|
240
250
|
version: "0"
|
241
251
|
requirements: []
|
242
252
|
|
243
253
|
rubyforge_project:
|
244
|
-
rubygems_version: 1.
|
254
|
+
rubygems_version: 1.8.15
|
245
255
|
signing_key:
|
246
256
|
specification_version: 3
|
247
257
|
summary: Reference implementation of Caren CareProvider API
|