Skip to content

Commit

Permalink
feat(Assistant v2): Add xSystem property to MessageContextSkill model
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatino10 committed Jan 15, 2020
1 parent ab7cb55 commit 9f53194
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions force-app/main/default/classes/IBMAssistantV2Models.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@ public class IBMAssistantV2Models {
*/
public class MessageContextSkill extends IBMWatsonGenericModel {
private IBMWatsonMapModel userDefined;
private IBMWatsonMapModel xSystem;

/**
* This constructor is strictly for internal serialization/deserialization purposes
Expand All @@ -1403,9 +1404,22 @@ public class IBMAssistantV2Models {
public IBMWatsonMapModel getUserDefined() {
return userDefined;
}

/**
* Gets the xSystem.
*
* For internal use only.
*
* @return the xSystem
*/
@AuraEnabled
public IBMWatsonMapModel getXSystem() {
return xSystem;
}

private MessageContextSkill(MessageContextSkillBuilder builder) {
this.userDefined = builder.userDefined;
this.xSystem = builder.xSystem;
}

/**
Expand All @@ -1424,7 +1438,8 @@ public class IBMAssistantV2Models {

// replace any names that are different between the API and SDK
Map<String, String> propertyNameMapping = new Map<String, String> {
'user_defined' => 'userDefined'
'user_defined' => 'userDefined',
'system' => 'xSystem'
};
jsonString = IBMWatsonJSONUtil.replaceKeyNamesInString(jsonString, propertyNameMapping);
jsonMap = IBMWatsonJSONUtil.replaceKeyNamesInMap(jsonMap, propertyNameMapping);
Expand All @@ -1437,6 +1452,11 @@ public class IBMAssistantV2Models {
IBMWatsonMapModel newUserDefined = (IBMWatsonMapModel) new IBMWatsonMapModel().deserialize(JSON.serialize(userDefinedMap, true), userDefinedMap, IBMWatsonMapModel.class);
retBuilder.userDefined(newUserDefined);

// calling custom deserializer for xSystem
Map<String, Object> xSystemMap = (Map<String, Object>) jsonMap.get('xSystem');
IBMWatsonMapModel newXSystem = (IBMWatsonMapModel) new IBMWatsonMapModel().deserialize(JSON.serialize(xSystemMap, true), xSystemMap, IBMWatsonMapModel.class);
retBuilder.xSystem(newXSystem);

return retBuilder.build();
}

Expand All @@ -1449,7 +1469,8 @@ public class IBMAssistantV2Models {

// replace any names that are different between the SDK and API
Map<String, String> propertyNameMapping = new Map<String, String> {
'userDefined' => 'user_defined'
'userDefined' => 'user_defined',
'xSystem' => 'system'
};
jsonMap = IBMWatsonJSONUtil.replaceKeyNamesInMap(jsonMap, propertyNameMapping);

Expand All @@ -1463,6 +1484,16 @@ public class IBMAssistantV2Models {
jsonMap.put(userDefinedKey, JSON.deserializeUntyped(userDefinedJsonString));
}

// performing custom serialization for xSystem
if (xSystem != null) {
String xSystemJsonString = JSON.serialize(xSystem.replacePropertyNames(), true);
String xSystemKey = 'xSystem';
if (propertyNameMapping.containsKey(xSystemKey)) {
xSystemKey = propertyNameMapping.get(xSystemKey);
}
jsonMap.put(xSystemKey, JSON.deserializeUntyped(xSystemJsonString));
}

return jsonMap;
}
}
Expand All @@ -1472,9 +1503,11 @@ public class IBMAssistantV2Models {
*/
public class MessageContextSkillBuilder {
private IBMWatsonMapModel userDefined;
private IBMWatsonMapModel xSystem;

private MessageContextSkillBuilder(MessageContextSkill messageContextSkill) {
this.userDefined = messageContextSkill.userDefined;
this.xSystem = messageContextSkill.xSystem;
}

/**
Expand Down Expand Up @@ -1502,6 +1535,17 @@ public class IBMAssistantV2Models {
this.userDefined = userDefined;
return this;
}

/**
* Set the xSystem.
*
* @param xSystem the xSystem
* @return the MessageContextSkill builder
*/
public MessageContextSkillBuilder xSystem(IBMWatsonMapModel xSystem) {
this.xSystem = xSystem;
return this;
}
}

/**
Expand Down

0 comments on commit 9f53194

Please sign in to comment.