Skip to content

Commit 82ede53

Browse files
committed
Another dump of a lot of changes before additional refactoring
1 parent c07b68e commit 82ede53

25 files changed

+2753
-604
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
/**
2+
* @description This class extends `AbstractCaseRoot` to include additional fields that are
3+
* shared by both “parameter” classes and “result” classes. By placing these mid-level fields and
4+
* methods here, we minimize duplication for any classes that share these common fields
5+
*
6+
* This multi-layer inheritance approach ensures DRY (Don’t Repeat Yourself) design,
7+
* grouping fields and logic where they’re truly shared, while keeping code for unique
8+
* fields separated in the subclasses that require them.
9+
*
10+
* @author Kenneth Soerensen <[email protected]>, Nav
11+
* @since 0.1.0, February 2025
12+
* @group Public 360 Integration
13+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
14+
* @example
15+
* public class CaseResult extends AbstractCaseParamAndResultBase {
16+
*
17+
* public static CaseResult fromJson(String jsonString) {
18+
* Map<String, Object> rawMap = (Map<String, Object>) JSON.deserializeUntyped(
19+
* jsonString
20+
* );
21+
*
22+
* CaseResult instance = new CaseResult();
23+
* instance.parseParamAndResultFields(rawMap);
24+
*
25+
* // Parse additional fields unique to this class.
26+
* return instance;
27+
* }
28+
*
29+
* public override String toJson() {
30+
* JsonHelper jsonHelper = new JsonHelper();
31+
* jsonHelper.writeStartObject();
32+
* super.writeParamAndResultFields(jsonHelper);
33+
*
34+
* // Write additional fields unique to this class.
35+
* jsonHelper.writeEndObject();
36+
*
37+
* return jsonHelper.getAsString();
38+
* }
39+
* }
40+
*/
41+
@SuppressWarnings('PMD.FieldNamingConventions, PMD.TooManyFields')
42+
public abstract class AbstractCaseParamAndResultBase extends AbstractCaseRoot {
43+
/**
44+
* @description The `AccessGroup` field of the create case parameter data type.
45+
* See Public 360 API documentation for details.
46+
*
47+
* @author Kenneth Soerensen <[email protected]>, Nav
48+
* @since 0.1.0, February 2025
49+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
50+
*/
51+
public String AccessGroup;
52+
/**
53+
* @description The `Contacts` field of the create case parameter data type.
54+
* See Public 360 API documentation for details.
55+
*
56+
* @author Kenneth Soerensen <[email protected]>, Nav
57+
* @since 0.1.0, February 2025
58+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
59+
*/
60+
public List<ContactParameter> Contacts;
61+
/**
62+
* @description The `eArchiveXMLFragment` field of the create case parameter data type.
63+
* See Public 360 API documentation for details.
64+
*
65+
* @author Kenneth Soerensen <[email protected]>, Nav
66+
* @since 0.1.0, February 2025
67+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
68+
*/
69+
public String eArchiveXMLFragment;
70+
/**
71+
* @description The `Keywords` field of the create case parameter data type.
72+
* See Public 360 API documentation for details.
73+
*
74+
* @author Kenneth Soerensen <[email protected]>, Nav
75+
* @since 0.1.0, February 2025
76+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
77+
*/
78+
public List<String> Keywords;
79+
/**
80+
* @description The `Notes` field of the create case parameter data type.
81+
* See Public 360 API documentation for details.
82+
*
83+
* @author Kenneth Soerensen <[email protected]>, Nav
84+
* @since 0.1.0, February 2025
85+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
86+
*/
87+
public String Notes;
88+
/**
89+
* @description The `Paragraph` field of the create case parameter data type.
90+
* See Public 360 API documentation for details.
91+
*
92+
* @author Kenneth Soerensen <[email protected]>, Nav
93+
* @since 0.1.0, February 2025
94+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
95+
*/
96+
public String Paragraph;
97+
/**
98+
* @description The `ReferringCases` field of the create case parameter data type.
99+
* See Public 360 API documentation for details.
100+
*
101+
* @author Kenneth Soerensen <[email protected]>, Nav
102+
* @since 0.1.0, January 2025
103+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
104+
*/
105+
public List<String> ReferringCases;
106+
/**
107+
* @description The `Remarks` field of the create case parameter data type.
108+
* See Public 360 API documentation for details.
109+
*
110+
* @author Kenneth Soerensen <[email protected]>, Nav
111+
* @since 0.1.0, January 2025
112+
* @see RemarkParameter
113+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
114+
*/
115+
public List<RemarkParameter> Remarks;
116+
/**
117+
* @description The `Status` field of the create case parameter data type.
118+
* See Public 360 API documentation for details.
119+
*
120+
* @author Kenneth Soerensen <[email protected]>, Nav
121+
* @since 0.1.0, February 2025
122+
* @see [Public 360 SIF API Documentation](https://help.360online.com/ReleaseInformation/SIF%20APIs%20-%20Documentation.pdf)
123+
*/
124+
public String Status;
125+
126+
/**
127+
* @description Abstract Constructor for the `AbstractCaseParamAndResultBase` class.
128+
* This constructor is protected to prevent instantiation of the abstract class.
129+
*
130+
* @author Kenneth Soerensen <[email protected]>, Nav
131+
* @since 0.1.0, February 2025
132+
*/
133+
@SuppressWarnings('PMD.EmptyStatementBlock')
134+
@TestVisible
135+
protected AbstractCaseParamAndResultBase() {
136+
super();
137+
}
138+
139+
/**
140+
* @description This method is used to deserialize the common fields of the object from a map.
141+
*
142+
* @author Kenneth Soerensen <[email protected]>, Nav
143+
* @since 0.1.0, February 2025
144+
* @param rawMap The map to deserialize.
145+
*/
146+
@TestVisible
147+
protected void parseParamAndResultFields(Map<String, Object> rawMap) {
148+
if (rawMap == null) {
149+
throw new AbstractCaseParamAndResultBaseException(
150+
'Map cannot be null: The parseParamAndResultFields() method requires a non-null map.'
151+
);
152+
}
153+
154+
super.parseUniversalFields(rawMap);
155+
156+
this.AccessGroup = (String) rawMap.get('AccessGroup');
157+
this.Contacts = new List<ContactParameter>();
158+
List<Object> rawContacts = (List<Object>) rawMap.get('Contacts') ??
159+
new List<Object>();
160+
for (Object rawContact : rawContacts) {
161+
this.Contacts.add(
162+
ContactParameter.fromMap((Map<String, Object>) rawContact)
163+
);
164+
}
165+
this.eArchiveXMLFragment = (String) rawMap.get('eArchiveXMLFragment');
166+
this.Keywords = new List<String>();
167+
List<Object> rawKeywords = (List<Object>) rawMap.get('Keywords') ??
168+
new List<Object>();
169+
for (Object rawKeyword : rawKeywords) {
170+
this.Keywords.add((String) rawKeyword);
171+
}
172+
this.Notes = (String) rawMap.get('Notes');
173+
this.Paragraph = (String) rawMap.get('Paragraph');
174+
this.ReferringCases = new List<String>();
175+
List<Object> rawReferringCases = (List<Object>) rawMap.get(
176+
'ReferringCases'
177+
) ?? new List<Object>();
178+
for (Object rawReferringCase : rawReferringCases) {
179+
this.ReferringCases.add((String) rawReferringCase);
180+
}
181+
this.Remarks = new List<RemarkParameter>();
182+
List<Object> rawRemarks = (List<Object>) rawMap.get('Remarks') ??
183+
new List<Object>();
184+
for (Object rawRemark : rawRemarks) {
185+
this.Remarks.add(
186+
RemarkParameter.fromMap((Map<String, Object>) rawRemark)
187+
);
188+
}
189+
this.Status = (String) rawMap.get('Status');
190+
}
191+
192+
/**
193+
* @description This method is used to serialize the common fields of the object into a JSON
194+
* string.
195+
*
196+
* @author Kenneth Soerensen <[email protected]>, Nav
197+
* @since 0.1.0, February 2025
198+
* @param jsonHelper The `JsonHelper` instance to use for serialization.
199+
* @see JsonHelper
200+
*/
201+
@TestVisible
202+
protected void writeParamAndResultFields(JsonHelper jsonHelper) {
203+
super.writeUniversalFields(jsonHelper);
204+
205+
jsonHelper.writeStringFieldIfNotNull('AccessGroup', this.AccessGroup);
206+
jsonHelper.writeNestedObjectList('Contacts', this.Contacts);
207+
jsonHelper.writeStringFieldIfNotNull(
208+
'eArchiveXMLFragment',
209+
this.eArchiveXMLFragment
210+
);
211+
jsonHelper.writeStringListIfNotEmpty('Keywords', this.Keywords);
212+
jsonHelper.writeStringFieldIfNotNull('Notes', this.Notes);
213+
jsonHelper.writeStringFieldIfNotNull('Paragraph', this.Paragraph);
214+
jsonHelper.writeStringListIfNotEmpty(
215+
'ReferringCases',
216+
this.ReferringCases
217+
);
218+
jsonHelper.writeNestedObjectList('Remarks', this.Remarks);
219+
jsonHelper.writeStringFieldIfNotNull('Status', this.Status);
220+
}
221+
222+
/**
223+
* @description This method is used to serialize the object into a JSON string.
224+
* Abstract method forcing children to define how to build final JSON
225+
*
226+
* @author Kenneth Soerensen <[email protected]>, Nav
227+
* @since 0.1.0, February 2025
228+
* @return `String` JSON representation of the object.
229+
* @see IJsonSerializable
230+
*/
231+
public override abstract String toJson();
232+
233+
/**
234+
* @description Custom exception class for the `AbstractCaseParamAndResultBase` class.
235+
*
236+
* @author Kenneth Soerensen <[email protected]>, Nav
237+
* @since 0.1.0, February 2025
238+
* @group Public 360 Integration
239+
*/
240+
public class AbstractCaseParamAndResultBaseException extends Exception {
241+
}
242+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>62.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>

0 commit comments

Comments
 (0)