caren-api 0.4.13 → 0.4.14
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 +1 -1
- data/lib/caren/caren.rb +22 -5
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.14
|
data/caren-api.gemspec
CHANGED
data/lib/caren/caren.rb
CHANGED
@@ -26,7 +26,8 @@ module Caren
|
|
26
26
|
attr_accessor :session
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
# The user_agent is an optional identifier
|
30
|
+
attr_accessor :url, :caren_public_key, :private_key, :user_agent
|
30
31
|
|
31
32
|
# Initialize new API session. Specify your private key to sign outgoing messages and your care provider url.
|
32
33
|
# Optionally you can pass the caren public key used to verify incoming requests.
|
@@ -59,7 +60,11 @@ module Caren
|
|
59
60
|
def put path, xml
|
60
61
|
begin
|
61
62
|
timestamp = DateTime.now.to_i
|
62
|
-
response = RestClient.put url_for(path), xml, :content_type => :xml,
|
63
|
+
response = RestClient.put url_for(path), xml, :content_type => :xml,
|
64
|
+
:accept => :xml,
|
65
|
+
:timestamp => timestamp,
|
66
|
+
:signature => sign(timestamp,path,xml),
|
67
|
+
:user_agent => user_agent
|
63
68
|
return check_signature(response)
|
64
69
|
rescue RestClient::Exception => e
|
65
70
|
handle_error(e.response)
|
@@ -69,7 +74,11 @@ module Caren
|
|
69
74
|
def post path, xml
|
70
75
|
begin
|
71
76
|
timestamp = DateTime.now.to_i
|
72
|
-
response = RestClient.post url_for(path), xml, :content_type => :xml,
|
77
|
+
response = RestClient.post url_for(path), xml, :content_type => :xml,
|
78
|
+
:accept => :xml,
|
79
|
+
:timestamp => timestamp,
|
80
|
+
:signature => sign(timestamp,path,xml),
|
81
|
+
:user_agent => user_agent
|
73
82
|
return check_signature(response)
|
74
83
|
rescue RestClient::Exception => e
|
75
84
|
handle_error(e.response)
|
@@ -79,7 +88,11 @@ module Caren
|
|
79
88
|
def delete path
|
80
89
|
begin
|
81
90
|
timestamp = DateTime.now.to_i
|
82
|
-
response = RestClient.delete url_for(path), :content_type => :xml,
|
91
|
+
response = RestClient.delete url_for(path), :content_type => :xml,
|
92
|
+
:accept => :xml,
|
93
|
+
:timestamp => timestamp,
|
94
|
+
:signature => sign(timestamp,path),
|
95
|
+
:user_agent => user_agent
|
83
96
|
return check_signature(response)
|
84
97
|
rescue RestClient::Exception => e
|
85
98
|
handle_error(e.response)
|
@@ -89,7 +102,11 @@ module Caren
|
|
89
102
|
def get path
|
90
103
|
begin
|
91
104
|
timestamp = DateTime.now.to_i
|
92
|
-
response = RestClient.get url_for(path), :content_type => :xml,
|
105
|
+
response = RestClient.get url_for(path), :content_type => :xml,
|
106
|
+
:accept => :xml,
|
107
|
+
:timestamp => timestamp,
|
108
|
+
:signature => sign(timestamp,path),
|
109
|
+
:user_agent => user_agent
|
93
110
|
return check_signature(response)
|
94
111
|
rescue RestClient::Exception => e
|
95
112
|
handle_error(e.response)
|