Skip to content

Instantly share code, notes, and snippets.

View emoran's full-sized avatar
:octocat:
Developing

Edgar Moran emoran

:octocat:
Developing
View GitHub Profile
@emoran
emoran / oauth2schemeAPI
Last active July 18, 2024 23:23
oauth2schemeAPI
#%RAML 1.0
title: cool-system-api
securitySchemes:
oauth_2_0:
description: Mulesoft OAUTH 2
describedBy:
headers:
Authorization:
type: string
@emoran
emoran / readKafka.dwl
Created June 27, 2024 18:05
Read Kafka record in DataWeave 2.0
%dw 2.0
output application/json
---
read(payload.^raw,"application/json")
@emoran
emoran / munitReadFile
Created September 25, 2023 20:38
MUnit : Payload value from resources folder
output application/java --- readUrl('classpath://sample_data/gsheet_date.json')
@emoran
emoran / flattenScatterGather.dw
Created September 22, 2023 19:16
Flatten payload after Scatter Gather DW 2.0
%dw 2.0
output application/java
---
flatten(valuesOf(payload) map ((item, index) -> item.*payload))
public class RestServiceConsumerDW {
public static void consume(){
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://techcrunch.com/wp-json/wp/v2/posts?per_page=2&context=embed');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if(response.getStatusCode() == 200) {
@emoran
emoran / anagramGrouped.apex
Created October 23, 2022 16:27
Group Anagram words in Salesforce Apex.
List<String> listWords = new List<String>{'bored','robed','cat','act','tac','eme'};
Map<String,List<String>> mapWords = new Map<String,List<String>>();
for(String word: listWords){
List<String> splittedWord = word.split('');
splittedWord.sort();
String wordNew = '';
for(String newWord:splittedWord){
@emoran
emoran / getTopManager
Created October 17, 2022 17:24
get Top Manager in Salesforce Apex.
public Employee__c getTopManager(String employeeId){
Boolean topLevel = false;
Employee__c top_employee = new Employee__c();
while(!topLevel){
Employee__c employee = [Select Id,Name,Manager__c from Employee__c where Id =:employeeId limit 1];
@emoran
emoran / simple_Trigger_Handler.cls
Created March 20, 2022 23:21
trigger Handler basic for salesforce
public class SObject {
public static void run(){
switch on Trigger.operationType {
when BEFORE_INSERT {
//Perform Before Insert logic'
System.debug('BEFORE INSERT FIRED');'
} when BEFORE_UPDATE {
//perform Before Update logic
} when BEFORE_DELETE {
//perform Before Delete logic
@emoran
emoran / CheckRecursive.cls
Created March 14, 2022 18:35
Check recursive apex in Salesforce.
public Class CheckRecursive {
private static boolean run = true;
public static boolean runOnce(){
if (run) {
run = false;
return true;
}
else{
@emoran
emoran / AccountApprovalClone.page
Created March 11, 2022 15:15
Approval History Clone for Salesforce Account. Allows to show the Approval History for an Object.
<apex:page standardController="Account" extensions="AccountApprovalCloneExtension" >
<apex:pageBlock title="Approval History Clone">
<table class="list" border="0" cellspacing="0">
<tbody>
<tr class="headerRow">
<th class="actionColumn" scope="col">Action</th>
<th scope="col" class=" zen-deemphasize">Date</th>
<th scope="col" class=" zen-deemphasize">Status</th>
<!--<th scope="col" class=" zen-deemphasize">Assigned To</th>-->