Code Snippets Apex

Short texts Apex 🧑‍💻 Code snippets Apex ✍️ Reading lists Apex 👀

Week Two Homework

public with sharing class CommentingOnCodeExercise { /** * Your Assignment is to add comments describing what is being done in the methods below. * Call out the concepts you learned in your readings and in class. */ public static void cartValues() { //Declare and intalize the Integer type Variable Integer minimumCartValue = 50; Integer itemA […]

Week Two Homework

public with sharing class CommentingOnCodeExercise { /** * Your Assignment is to add comments describing what is being done in the methods below. * Call out the concepts you learned in your readings and in class. */ public static void cartValues() { //Declare and intalize the Integer type Variable Integer minimumCartValue = 50; Integer itemA […]

Welcome.cls

public with sharing class Welcome { //Welcome! I’m a comment and I’m here to tell you what this particular class file is for. The developer who created this class added //me so that future developers, like yourself, would have a quick little introduction to what this class does. //The two little slashes tell the compiler* […]

HMAC Salesforce apex

public with sharing class SecurityManagerController { public static final String MACENCRIPTION = ‘HmacSHA256’; public static final String MD5 = ‘MD5’; public String generateHMACKey(String messagePayload,String content_type,String requestType,String endpoint,String secretKey,String principal){ String salt = generateSalt(); String timestamp = generateTimeStamp(Datetime.now()); String contentMd5 = generateMD5Digest(messagePayload); String contentType = content_type; String signatureData = generateSignature(requestType,contentMD5,contentType,salt,timestamp,endpoint); Blob data = crypto.generateMac(MACENCRIPTION, Blob.valueOf(signatureData), Blob.valueOf(secretKey)); […]

A Hello World Apex HTTP Callout Example

public class DemoTriggerHandler { @future (callout=true) public static void sendTestRequest(string field1, string field2, string field3) { try{ HttpRequest request = new HttpRequest(); request.setMethod(‘POST’); request.setEndpoint(“my external api url goes here”); request.setBody(‘{“message”:”Hello World”}’); HttpResponse response = new HttpResponse(); Http http = new Http(); response = http.send(request); if (response.getStatusCode() == 200) { System.debug(‘I got a 200 OK from […]