Lead Status POST

The logic to submit HTTP POST requests to the BankingBridge API lead-status endpoint is initiated through a trigger that resides on the Lead BB_LeadTrigger.trigger. This trigger runs logic within the BB_LeadTriggerHandler.class which utilizes a standardized trigger handling class BB_TriggerHandler.class as part of a Salesforce best practice.

The trigger handler class executes logic After Lead Insert and After Lead Update.

The following pseudocode describes the logic used on lead insert and update to execute an HTTP POST request to the BankingBridge API lead-status endpoint:

  • On lead insert: If the API Key custom setting is not blank and the Brand ID custom setting is not blank, and the Lead Email is not blank, and the Lead Status is not blank, execute a POST to the lead-status endpoint.
  • On lead update: If the API Key custom setting is not blank and the Brand ID custom setting is not blank, and the Lead Email is not blank, and the Lead Status is not blank, and the Lead Status has changed, execute a POST to the lead-status endpoint.

A POST request to the BankingBridge API lead-status endpoint is initiated by passing the lead to the BB_BankingBridgeAPI.class which executes the sendLeadData() method asynchronously.

The sendLeadData() method serializes the Lead into a JSON object defined in the BankingBridge API Reference. The serialization method also removes NULL values replacing them with blanks, and translates Salesforce Lead Status into BankingBridge API static values using the following logic:

  • Default BankingBridge Lead Status = “applied”
  • If Salesforce Lead Status contains text “Approved”, BankingBridge Lead Status = “approved”
  • If Salesforce Lead Status contains text “Locked”, BankingBridge Lead Status = “locked”
  • If Salesforce Lead Status contains text “Closed” or isConverted, Banking Bridge Lead Status = “closed”

Next the method executes a POST to the endpoint defined within the BB_BankingBridgeAPI_CONSTANTS.class including both the API Key and the Brand ID.

ENDPOINT_LEAD_STATUS = 'https://api.bankingbridge.com/lead-status';

The response status from the post is captured in the BB_Last_API_Sync_Status\_\_c custom field located on the lead.