Dependencies:   EthernetNetIf TextLCD mbed

Revision:
0:48abe2923d34
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PachubeClient/PachubeClient.cpp	Mon Jun 20 11:21:15 2011 +0000
@@ -0,0 +1,32 @@
+#include "PachubeClient.h"
+
+PachubeClient::PachubeClient(const string& apiKey) : _client(), _csvContent("text/csv") {
+    _client.setRequestHeader("X-PachubeApiKey", apiKey);
+}
+
+PachubeClient::~PachubeClient() {
+}
+
+// put csv method to feed
+void PachubeClient::PutCsv(const string& environmentID, const string& data) {
+    _csvContent.set(data);
+    string uri = "http://api.pachube.com/v1/feeds/" + environmentID + ".csv?_method=put";
+    _result = _client.post(uri.c_str(), _csvContent, NULL);
+    _response = _client.getHTTPResponseCode();
+}
+
+// put csv method to datastream
+void PachubeClient::PutCsv(const string& environmentID, const string& datastreamID, const string& data) {
+    _csvContent.set(data);
+    string uri = "http://api.pachube.com/v1/feeds/" + environmentID + "/datastreams/" + datastreamID + ".csv?_method=put";
+    _result = _client.post(uri.c_str(), _csvContent, NULL);
+    _response = _client.getHTTPResponseCode();
+}
+
+// http result and response
+HTTPResult PachubeClient::Result() {
+    return _result;
+}
+int PachubeClient::Response() {
+    return _response;
+}
\ No newline at end of file