Dependencies:   EthernetNetIf TextLCD mbed

Committer:
Torsten
Date:
Mon Jun 20 11:21:15 2011 +0000
Revision:
0:48abe2923d34
Initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Torsten 0:48abe2923d34 1 #include "PachubeClient.h"
Torsten 0:48abe2923d34 2
Torsten 0:48abe2923d34 3 PachubeClient::PachubeClient(const string& apiKey) : _client(), _csvContent("text/csv") {
Torsten 0:48abe2923d34 4 _client.setRequestHeader("X-PachubeApiKey", apiKey);
Torsten 0:48abe2923d34 5 }
Torsten 0:48abe2923d34 6
Torsten 0:48abe2923d34 7 PachubeClient::~PachubeClient() {
Torsten 0:48abe2923d34 8 }
Torsten 0:48abe2923d34 9
Torsten 0:48abe2923d34 10 // put csv method to feed
Torsten 0:48abe2923d34 11 void PachubeClient::PutCsv(const string& environmentID, const string& data) {
Torsten 0:48abe2923d34 12 _csvContent.set(data);
Torsten 0:48abe2923d34 13 string uri = "http://api.pachube.com/v1/feeds/" + environmentID + ".csv?_method=put";
Torsten 0:48abe2923d34 14 _result = _client.post(uri.c_str(), _csvContent, NULL);
Torsten 0:48abe2923d34 15 _response = _client.getHTTPResponseCode();
Torsten 0:48abe2923d34 16 }
Torsten 0:48abe2923d34 17
Torsten 0:48abe2923d34 18 // put csv method to datastream
Torsten 0:48abe2923d34 19 void PachubeClient::PutCsv(const string& environmentID, const string& datastreamID, const string& data) {
Torsten 0:48abe2923d34 20 _csvContent.set(data);
Torsten 0:48abe2923d34 21 string uri = "http://api.pachube.com/v1/feeds/" + environmentID + "/datastreams/" + datastreamID + ".csv?_method=put";
Torsten 0:48abe2923d34 22 _result = _client.post(uri.c_str(), _csvContent, NULL);
Torsten 0:48abe2923d34 23 _response = _client.getHTTPResponseCode();
Torsten 0:48abe2923d34 24 }
Torsten 0:48abe2923d34 25
Torsten 0:48abe2923d34 26 // http result and response
Torsten 0:48abe2923d34 27 HTTPResult PachubeClient::Result() {
Torsten 0:48abe2923d34 28 return _result;
Torsten 0:48abe2923d34 29 }
Torsten 0:48abe2923d34 30 int PachubeClient::Response() {
Torsten 0:48abe2923d34 31 return _response;
Torsten 0:48abe2923d34 32 }