encodeKey static method
Implementation
static dynamic encodeKey(
{required TransactionMetadata key,
required MetadataSchemaConfig config}) {
switch (key.type) {
case TransactionMetadataType.metadataText:
return key.toJsonSchema(config: config);
case TransactionMetadataType.metadataBytes:
if (config.jsonSchema != MetadataJsonSchema.noConversions) {
return key.toJsonSchema(config: config);
}
break;
case TransactionMetadataType.metadataInt:
if (config.jsonSchema != MetadataJsonSchema.noConversions) {
return key.toJsonSchema(config: config).toString();
}
break;
case TransactionMetadataType.metadataList:
case TransactionMetadataType.metadataMap:
return key.toJsonSchema(config: config);
}
throw ADAPluginException(
'Key type not allowed in JSON under specified schema.',
details: {'Key': key, 'type': key.type});
}