Doug Anson / SalesforceCaseGenerator-df2014

Fork of SalesforceCaseGenerator by Doug Anson

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Wed Sep 24 18:52:45 2014 +0000
Parent:
11:57f6f0f286c0
Child:
13:1e06a3a4740d
Commit message:
updates for temp and lat/long inclusion into case

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	Sun Sep 21 07:28:37 2014 +0000
+++ b/SalesForceCaseGenerator.cpp	Wed Sep 24 18:52:45 2014 +0000
@@ -31,26 +31,33 @@
  }
  
  // create a case through APEX
- bool SalesForceCaseGenerator::createCase(char *subject,char *description) {
+ bool SalesForceCaseGenerator::createCase(char *subject,char *description,char *condition,int temperature,char *latitude,char *longitude) {
      bool success = false;
      
      // data buffer and result buffer
-     char data[MAX_BUFFER_LENGTH+1];
      char result[MAX_BUFFER_LENGTH+1];
-     memset(data,0,MAX_BUFFER_LENGTH+1);
      memset(result,0,MAX_BUFFER_LENGTH+1);
      
      // set addl header information
      char headers[] = "User-Agent: curl/7.33.0\nAccept: */*\n" ;
         
-     // build the new SF case
-     sprintf(data,"{\"subject\":\"%s\",\"description\":\"%s\"}",subject,description);
-    
+     // build the new Salesforce.com report 
+     MbedJSONValue report;
+     report["subject"]       = subject;
+     report["description"]   = description;
+     report["condition"]     = condition;
+     report["temperature"]   = temperature;
+     report["latitude"]      = latitude;
+     report["longitude"]     = longitude;
+        
      // covert to the HTTP data types
+     char data[MAX_BUFFER_LENGTH+1];
+     memset(data,0,MAX_BUFFER_LENGTH+1);
+     strcpy(data,report.serialize().c_str());
+     this->m_logger->log("Case JSON: %s",data);
      HTTPJson new_case(data,strlen(data)+1);
      HTTPText http_result(result,MAX_BUFFER_LENGTH);
         
-     //this->m_http.basicAuth("<username>", "<password>");
      this->m_http->setHeader(headers) ;
      this->m_http->setSSLversion(1) ; /* TLSv1.0 */
           
@@ -68,7 +75,7 @@
             this->m_logger->log("Case generation FAILED: %s",result);
      }
      else {
-        this->m_logger->log("Failed to post case (%d)",ret);
+        this->m_logger->log("Failed to post case (%d) (%s)",ret,result);
      }
      
      // return our status
--- a/SalesForceCaseGenerator.h	Sun Sep 21 07:28:37 2014 +0000
+++ b/SalesForceCaseGenerator.h	Wed Sep 24 18:52:45 2014 +0000
@@ -32,7 +32,7 @@
         virtual ~SalesForceCaseGenerator();
         
         // create a case (via APEX)
-        bool createCase(char *subject, char *description);
+        bool createCase(char *subject, char *description, char *condition, int temperature, char *latitude, char *longitude);
     
     protected: