This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:application controller="sObjectDetailController" extends="force:slds"> | |
<aura:attribute name="objName" type="String" default='Account'/> | |
<aura:attribute name="sObjects" type="sObject[]"/> | |
<aura:attribute name="fieldNames" type="String[]" default='["Id","Name","Owner.Name"]'/> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
<div class="slds-m-around_small"> | |
<div class="slds-page-header"> | |
<div class="slds-media"> | |
<div class="slds-media__body"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit : function(component, event, helper) { | |
var action = component.get("c.fetchMapData"); | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
if (state === "SUCCESS") { | |
var custs = []; | |
var conts = response.getReturnValue(); | |
for(var key in conts){ | |
custs.push({value:conts[key], key:key}); //Here we are creating the list to show on UI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:application controller="MapIterationController" extends="force:slds"> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/> | |
<aura:attribute name="oppAccountList" type="List" /> | |
<div class="slds-m-around_small"> | |
<div class="slds-page-header"> | |
<div class="slds-media"> | |
<div class="slds-media__body"> | |
<div class="slds-box slds-theme_shade"> | |
<p> <h1>Map Iteration in Lightning Component</h1></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MapIterationController { | |
@AuraEnabled | |
public static Map < String, String > fetchMapData() { | |
Map < String, String > mapOppAccount = new Map < String, String >(); | |
for(Opportunity opp : [SELECT ID, Account.Name, Name FROm Opportunity LIMIT 5]) | |
mapOppAccount.put(opp.Name, opp.Account.Name); | |
return mapOppAccount; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpRequest req = new HttpRequest(); | |
req.setMethod('POST'); | |
req.setEndpoint('https://api.einstein.ai/v2/language/datasets/upload'); | |
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); | |
req.setHeader('Cache-Control', 'no-cache'); | |
// Compose the form | |
string form64 = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpRequest req = new HttpRequest(); | |
req.setMethod('POST'); | |
req.setEndpoint('https://api.einstein.ai/v2/vision/predict'); | |
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); | |
req.setHeader('Cache-Control', 'no-cache'); | |
// Compose the form | |
string form64 = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpRequest req = new HttpRequest(); | |
req.setMethod('GET'); | |
req.setEndpoint('https://api.einstein.ai/v2/vision/train/<MODEL ID>'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); | |
req.setTimeout(60*1000); | |
Http h = new Http(); | |
String resp; | |
HttpResponse res = h.send(req); | |
resp = res.getBody(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpRequest req = new HttpRequest(); | |
req.setMethod('POST'); | |
req.setEndpoint('https://api.einstein.ai/v2/vision/train'); | |
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); | |
req.setHeader('Cache-Control', 'no-cache'); | |
// Compose the form | |
string form64 = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpRequest req = new HttpRequest(); | |
req.setMethod('POST'); | |
req.setEndpoint('https://api.einstein.ai/v2/vision/datasets/upload'); | |
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"'); | |
req.setHeader('Authorization', 'Bearer <TOKEN>'); //replace token with your access token | |
req.setHeader('Cache-Control', 'no-cache'); | |
string form64 = ''; | |
form64 += HttpFormBuilder.WriteBoundary(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getAccessToken() { | |
// Ignore the File upload part and "jwt.pkcs" if you used a Salesforce certificate to sign up | |
// for an Einstein Platform account | |
ContentVersion base64Content = [SELECT Title, VersionData FROM ContentVersion where Title='einstein_platform' OR Title='predictive_services' ORDER BY Title LIMIT 1]; | |
String keyContents = base64Content.VersionData.tostring(); | |
keyContents = keyContents.replace('-----BEGIN RSA PRIVATE KEY-----', ''); | |
keyContents = keyContents.replace('-----END RSA PRIVATE KEY-----', ''); | |
keyContents = keyContents.replace('\n', ''); | |
// Get a new token |