Skip to content

Commit

Permalink
add agg result proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-lyon committed Oct 9, 2024
1 parent a8a8899 commit ee053b3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
31 changes: 31 additions & 0 deletions force-app/main/default/classes/proxies/AggregateResultProxy.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public with sharing class AggregateResultProxy {
private Map<String, Object> valuesByAlias = new Map<String, Object>();

private AggregateResultProxy() {
}

public static AggregateResultProxy fromAggregateResult(AggregateResult item) {
String itemJson = JSON.serialize(item);
AggregateResultProxy proxy = new AggregateResultProxy();
proxy.valuesByAlias = (Map<String, Object>) JSON.deserializeUntyped(
itemJson
);
return proxy;
}

public static AggregateResultProxy fromMap(Map<String, Object> pairs) {
AggregateResultProxy proxy = new AggregateResultProxy();
proxy.valuesByAlias = new Map<String, Object>(pairs);
return proxy;
}

public static AggregateResultProxy fromPair(String key, Object value) {
AggregateResultProxy proxy = new AggregateResultProxy();
proxy.valuesByAlias = new Map<String, Object>{ key => value };
return proxy;
}

public Map<String, Object> getValuesByAlias() {
return this.valuesByAlias;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<status>Active</status>
</ApexClass>

0 comments on commit ee053b3

Please sign in to comment.