entityFrame function

Map<String, dynamic> entityFrame(
  1. List<MapEntry<String, dynamic>> fields,
  2. HypiMeta hypi,
  3. String entityType,
  4. String entitySubType,
  5. String entityGroupId,
  6. String appInstanceId, {
  7. Map<String, dynamic>? target,
})

Implementation

Map<String, dynamic> entityFrame(
    List<MapEntry<String, dynamic>> fields,
    HypiMeta hypi,
    String entityType,
    String entitySubType,
    String entityGroupId,
    String appInstanceId,
    {Map<String, dynamic>? target}) {
  target = target ?? {};
  target.addAll({
    'fields': fields
        .map((e) => {
              'name': e.key,
              //The value is a Hypi JSON type so must be written as such in all cases
              'value': json.encode(e.value),
              'hypi': {'id': 'fld.${e.key}.${hypi.id}'}
            })
        .toList(),
    'hypi': hypi.toJSON,
    'rootEntityID': appInstanceId,
    'entityType': entityType,
    'entitySubType': entitySubType,
    'entityGroupId': entityGroupId,
  });
  return target;
}