Skip to content

Commit

Permalink
added check for upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin-Mamoru committed May 2, 2024
1 parent 9e5c583 commit 68d96f8
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ballerina/http;
import ballerinax/salesforce;
import ballerinax/salesforce.soap;
import ballerina/log;
import ballerina/jwt;
import ballerina/io;

Expand Down Expand Up @@ -73,20 +72,33 @@ service / on new http:Listener(9092) {
if owner is error {
return owner;
}

soap:Client soapClient = check new(config);
string sampleQuery = string `SELECT Id FROM Lead WHERE Email = '${payload.email ?: ""}'`;

string sampleQuery = string `SELECT AccountID FROM Contact WHERE Email = '${payload.email ?: ""}'`;
stream<record {}, error?> queryResults = check baseClient->query(sampleQuery);

int nLines = 0;
string recordId;
check from record {} rd in queryResults
do {
recordId = check rd.toJson().Id;
recordId = check rd.toJson().AccountId;
nLines += 1;
};

if (nLines == 0) {
if (nLines != 0) {
return http:CREATED;
}

sampleQuery = string `SELECT Id FROM Lead WHERE Email = '${payload.email ?: ""}'`;
queryResults = check baseClient->query(sampleQuery);

int nLines2 = 0;
check from record {} rd in queryResults
do {
recordId = check rd.toJson().Id;
nLines2 += 1;
};

if (nLines2 == 0) {
return http:NOT_FOUND;
}

Expand Down

0 comments on commit 68d96f8

Please sign in to comment.