caren-api 0.4.12 → 0.4.13

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 CHANGED
@@ -1 +1 @@
1
- 0.4.12
1
+ 0.4.13
data/caren-api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{caren-api}
8
- s.version = "0.4.12"
8
+ s.version = "0.4.13"
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 = %q{2011-11-16}
12
+ s.date = %q{2011-11-17}
13
13
  s.description = %q{You can use this gem as inspiration of the base of your connections with Caren.}
14
14
  s.email = %q{andre.foeken@nedap.com}
15
15
  s.extra_rdoc_files = [
data/lib/caren/base.rb CHANGED
@@ -65,7 +65,7 @@ class Caren::Base
65
65
 
66
66
  # The absolute (constructed url) to the resource.
67
67
  def self.resource_url id=nil
68
- "#{self.resource_location}#{id}"
68
+ [self.resource_location,id].compact.join("/")
69
69
  end
70
70
 
71
71
  def self.search_url key, value
@@ -73,7 +73,7 @@ class Caren::CareProvider < Caren::Base
73
73
  end
74
74
 
75
75
  def self.resource_location
76
- "/api/pro/care_providers/"
76
+ "/api/pro/care_providers"
77
77
  end
78
78
 
79
79
  def self.array_root
data/lib/caren/caren.rb CHANGED
@@ -59,7 +59,7 @@ module Caren
59
59
  def put path, xml
60
60
  begin
61
61
  timestamp = DateTime.now.to_i
62
- response = RestClient.put url_for(path), xml, :content_type => :xml, :accept => :xml, :timestamp => timestamp, :signature => sign(timestamp,xml)
62
+ response = RestClient.put url_for(path), xml, :content_type => :xml, :accept => :xml, :timestamp => timestamp, :signature => sign(timestamp,path,xml)
63
63
  return check_signature(response)
64
64
  rescue RestClient::Exception => e
65
65
  handle_error(e.response)
@@ -69,7 +69,7 @@ module Caren
69
69
  def post path, xml
70
70
  begin
71
71
  timestamp = DateTime.now.to_i
72
- response = RestClient.post url_for(path), xml, :content_type => :xml, :accept => :xml, :timestamp => timestamp, :signature => sign(timestamp,xml)
72
+ response = RestClient.post url_for(path), xml, :content_type => :xml, :accept => :xml, :timestamp => timestamp, :signature => sign(timestamp,path,xml)
73
73
  return check_signature(response)
74
74
  rescue RestClient::Exception => e
75
75
  handle_error(e.response)
@@ -79,7 +79,7 @@ module Caren
79
79
  def delete path
80
80
  begin
81
81
  timestamp = DateTime.now.to_i
82
- response = RestClient.delete url_for(path), :content_type => :xml, :accept => :xml, :timestamp => timestamp, :signature => sign(timestamp)
82
+ response = RestClient.delete url_for(path), :content_type => :xml, :accept => :xml, :timestamp => timestamp, :signature => sign(timestamp,path)
83
83
  return check_signature(response)
84
84
  rescue RestClient::Exception => e
85
85
  handle_error(e.response)
@@ -89,7 +89,7 @@ module Caren
89
89
  def get path
90
90
  begin
91
91
  timestamp = DateTime.now.to_i
92
- response = RestClient.get url_for(path), :content_type => :xml, :accept => :xml, :timestamp => timestamp, :signature => sign(timestamp)
92
+ response = RestClient.get url_for(path), :content_type => :xml, :accept => :xml, :timestamp => timestamp, :signature => sign(timestamp,path)
93
93
  return check_signature(response)
94
94
  rescue RestClient::Exception => e
95
95
  handle_error(e.response)
@@ -147,11 +147,11 @@ module Caren
147
147
  end
148
148
  end
149
149
 
150
-
151
150
  # Sign your string and timestamp using private key
152
151
  # Timestamp is UNIX timestamp seconds since 1970
153
- def sign timestamp, string=nil, private_key=self.private_key
154
- encrypted_digest = private_key.sign( "sha1", string.to_s + timestamp.to_s )
152
+ def sign timestamp, path, string=nil, private_key=self.private_key
153
+ path = URI.parse(path).path
154
+ encrypted_digest = private_key.sign( "sha1", path.to_s + string.to_s + timestamp.to_s )
155
155
  signature = CGI.escape(Base64.encode64(encrypted_digest))
156
156
  return signature
157
157
  end
@@ -47,7 +47,7 @@ class Caren::ExternalMessage < Caren::Base
47
47
  end
48
48
 
49
49
  def self.resource_location
50
- "/api/pro/people/%i/external_messages/"
50
+ "/api/pro/people/%i/external_messages"
51
51
  end
52
52
 
53
53
  private
data/lib/caren/link.rb CHANGED
@@ -43,7 +43,7 @@ class Caren::Link < Caren::Base
43
43
  end
44
44
 
45
45
  def self.resource_location
46
- "/api/pro/links/"
46
+ "/api/pro/links"
47
47
  end
48
48
 
49
49
  end
data/lib/caren/product.rb CHANGED
@@ -77,7 +77,7 @@ class Caren::Product < Caren::Base
77
77
  end
78
78
 
79
79
  def self.resource_location
80
- "/api/pro/store/products/"
80
+ "/api/pro/store/products"
81
81
  end
82
82
 
83
83
  end
@@ -30,7 +30,7 @@ class Caren::ProductCategory < Caren::Base
30
30
  end
31
31
 
32
32
  def self.resource_location
33
- "/api/pro/store/product_categories/"
33
+ "/api/pro/store/product_categories"
34
34
  end
35
35
 
36
36
  end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 12
8
+ - 13
9
9
  segments_generated: true
10
- version: 0.4.12
10
+ version: 0.4.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andre Foeken
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-16 00:00:00 +01:00
18
+ date: 2011-11-17 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency