Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SalesforceCaseGenerator by
Revision 1:5c876ee72cf0, committed 2014-08-27
- Comitter:
- ansond
- Date:
- Wed Aug 27 05:39:58 2014 +0000
- Parent:
- 0:5953127f7c19
- Child:
- 2:670837d3e248
- Commit message:
- updated - using heroku service to map to https reqs for SF
Changed in this revision
| SalesForceCaseGenerator.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SalesForceCaseGenerator.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SalesForceCaseGenerator.cpp Sat Aug 23 20:17:12 2014 +0000
+++ b/SalesForceCaseGenerator.cpp Wed Aug 27 05:39:58 2014 +0000
@@ -23,35 +23,39 @@
// constructor
SalesForceCaseGenerator::SalesForceCaseGenerator(Logger *logger) {
this->m_logger = logger;
- this->m_connected = this->m_https.connect(MY_SF_HOST);
}
// destructor
SalesForceCaseGenerator::~SalesForceCaseGenerator() {
- if (this->m_connected == true) this->m_https.disconnect();
- this->m_connected = false;
}
// create a case through APEX
bool SalesForceCaseGenerator::createCase(char *subject,char *description) {
bool success = false;
- // proceed only if connected
- if (this->m_connected == true) {
- HTTPHeader hdr;
- char buffer[BUFFER_LENGTH+1];
- memset(buffer,0,BUFFER_LENGTH+1);
- int n = this->m_https.get(MY_APEX_CASE_RESOURCE, &hdr, buffer, BUFFER_LENGTH);
- if(n > 0 && hdr.getStatus() == HTTP_OK) {
- success = this->contains(buffer,"status","ok");
- if (success)
- this->m_logger->log("Case generated successfully");
- else
- this->m_logger->log("Case generation FAILED: %s",buffer);
- }
- else {
- this->m_logger->log("Failed to send get request");
- }
+ // data buffer and result buffer
+ char data[BUFFER_LENGTH+1];
+ char result[BUFFER_LENGTH+1];
+ memset(data,0,BUFFER_LENGTH+1);
+ memset(result,0,BUFFER_LENGTH+1);
+
+ // create the case
+ sprintf(data,"{ \"subject\":\"%s\", \"description\":\"%s\" }", subject, description);
+
+ // Create the inbound and outbound buffers
+ HTTPText http_data(data,strlen(data)+1);
+ HTTPText http_result(result,BUFFER_LENGTH);
+
+ // POST the case and check the response
+ if (this->m_http.post(DF_CASE_GEN_URL,http_data,&http_result) == 0) {
+ success = this->contains(result,"status","ok");
+ if (success)
+ this->m_logger->log("Case generated successfully");
+ else
+ this->m_logger->log("Case generation FAILED: %s",data);
+ }
+ else {
+ this->m_logger->log("Failed to send get request");
}
// return our status
--- a/SalesForceCaseGenerator.h Sat Aug 23 20:17:12 2014 +0000
+++ b/SalesForceCaseGenerator.h Wed Aug 27 05:39:58 2014 +0000
@@ -19,14 +19,13 @@
#ifndef _SALESFORCE_CASE_GENERATOR_H_
#define _SALESFORCE_CASE_GENERATOR_H_
- #include "HTTPSClient.h"
+ #include "HTTPClient.h"
#include "Logger.h"
class SalesForceCaseGenerator {
private:
- HTTPSClient m_https;
+ HTTPClient m_http;
Logger *m_logger;
- bool m_connected;
public:
SalesForceCaseGenerator(Logger *logger);
