Skip to content

Commit 6af70b2

Browse files
committed
Adding IJsonSerializable and fromMap method
1 parent 344e90f commit 6af70b2

File tree

2 files changed

+388
-54
lines changed

2 files changed

+388
-54
lines changed

src/integration/public360/main/classes/DataTypes/UnregisteredContactsParameter.cls

+43-5
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,26 @@
2020
* UnregisteredContactsParameter deserializedUnregisteredContacts = UnregisteredContactsParameter.fromJson(json);
2121
*/
2222
@SuppressWarnings('PMD.FieldNamingConventions')
23-
public class UnregisteredContactsParameter {
23+
public class UnregisteredContactsParameter implements IJsonSerializable {
2424
/**
25-
* @description Error messages for the `UnregisteredContactsParameter` class and the `ContactName` field.
25+
* @description Error messages for the `UnregisteredContactsParameter` class and the
26+
* `ContactName` field.
2627
*
2728
* @author Kenneth Soerensen <[email protected]>, Nav
2829
* @since 0.1.0, January 2025
2930
*/
3031
public static final String CONTACT_NAME_BLANK_ERROR_MESSAGE = 'The ContactName field is mandatory.';
3132
/**
32-
* @description Error messages for the `UnregisteredContactsParameter` class and the `Role` field.
33+
* @description Error messages for the `UnregisteredContactsParameter` class and the `Role`
34+
* field.
3335
*
3436
* @author Kenneth Soerensen <[email protected]>, Nav
3537
* @since 0.1.0, January 2025
3638
*/
3739
public static final String ROLE_BLANK_ERROR_MESSAGE = 'The Role field is mandatory.';
3840
/**
39-
* @description Error messages for the `UnregisteredContactsParameter` class and the `ContactName` and `Role` fields.
41+
* @description Error messages for the `UnregisteredContactsParameter` class and the
42+
* `ContactName` and `Role` fields.
4043
*
4144
* @author Kenneth Soerensen <[email protected]>, Nav
4245
* @since 0.1.0, January 2025
@@ -457,12 +460,47 @@ public class UnregisteredContactsParameter {
457460
);
458461
}
459462

463+
/**
464+
* @description Deserializes a map into an `UnregisteredContactsParameter` object instance.
465+
*
466+
* @author Kenneth Soerensen <[email protected]>, Nav
467+
* @since 0.1.0, January 2025
468+
* @param mapData The map to deserialize.
469+
* @return `UnregisteredContactsParameter` The deserialized object instance from the map.
470+
*/
471+
public static UnregisteredContactsParameter fromMap(
472+
Map<String, Object> mapData
473+
) {
474+
UnregisteredContactsParameter unregisteredContacts = new UnregisteredContactsParameter();
475+
unregisteredContacts.Role = (String) mapData.get('Role');
476+
unregisteredContacts.IsUnofficial = (Boolean) mapData.get(
477+
'IsUnofficial'
478+
);
479+
unregisteredContacts.ContactName = (String) mapData.get('ContactName');
480+
unregisteredContacts.ContactCompanyName = (String) mapData.get(
481+
'ContactCompanyName'
482+
);
483+
unregisteredContacts.ReferenceNumber = (String) mapData.get(
484+
'ReferenceNumber'
485+
);
486+
unregisteredContacts.Address = (String) mapData.get('Address');
487+
unregisteredContacts.Country = (String) mapData.get('Country');
488+
unregisteredContacts.MobilePhone = (String) mapData.get('MobilePhone');
489+
unregisteredContacts.Phone = (String) mapData.get('Phone');
490+
unregisteredContacts.Email = (String) mapData.get('Email');
491+
unregisteredContacts.State = (String) mapData.get('State');
492+
unregisteredContacts.ZipCode = (String) mapData.get('ZipCode');
493+
unregisteredContacts.ZipPlace = (String) mapData.get('ZipPlace');
494+
495+
return unregisteredContacts;
496+
}
497+
460498
/**
461499
* @description Validates the object to ensuring it has the mandatory fields set.
462500
*
463501
* @author Kenneth Soerensen <[email protected]>, Nav
464502
* @since 0.1.0, January 2025
465-
* @exception ContactParameterException
503+
* @exception UnregisteredContactsParameterException
466504
*/
467505
@TestVisible
468506
private void validate() {

0 commit comments

Comments
 (0)