fromEntityPlus static method

Future<PolicyPresentationModel?> fromEntityPlus(
  1. String documentID,
  2. PolicyPresentationEntity? entity, {
  3. String? appId,
})

Implementation

static Future<PolicyPresentationModel?> fromEntityPlus(
    String documentID, PolicyPresentationEntity? entity,
    {String? appId}) async {
  if (entity == null) return null;

  AppPolicyModel? policiesHolder;
  if (entity.policiesId != null) {
    try {
      policiesHolder =
          await appPolicyRepository(appId: appId)!.get(entity.policiesId);
    } on Exception catch (e) {
      print('Error whilst trying to initialise policies');
      print('Error whilst retrieving appPolicy with id ${entity.policiesId}');
      print('Exception: $e');
    }
  }

  return PolicyPresentationModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    description: entity.description,
    policies: policiesHolder,
    conditions: await StorageConditionsModel.fromEntityPlus(entity.conditions,
        appId: appId),
  );
}