Presentation constructor

Presentation({
  1. String? id,
  2. required List<VerifiablePresentation> verifiablePresentation,
  3. String? goalCode,
  4. String? comment,
  5. String? replyUrl,
  6. List<String>? replyTo,
  7. String? parentThreadId,
  8. String? threadId,
  9. String? from,
  10. List<String>? to,
  11. DateTime? createdTime,
  12. DateTime? expiresTime,
  13. bool pleaseAck = false,
  14. FromPriorJWT? fromPrior,
  15. Map<String, dynamic>? additionalHeaders,
  16. WebRedirect? webRedirect,
  17. ReturnRouteValue? returnRoute,
  18. DidcommMessageTyp? typ,
})

Implementation

Presentation(
    {String? id,
    required this.verifiablePresentation,
    this.goalCode,
    this.comment,
    String? replyUrl,
    List<String>? replyTo,
    String? parentThreadId,
    String? threadId,
    String? from,
    List<String>? to,
    DateTime? createdTime,
    DateTime? expiresTime,
    bool pleaseAck = false,
    FromPriorJWT? fromPrior,
    Map<String, dynamic>? additionalHeaders,
    WebRedirect? webRedirect,
    ReturnRouteValue? returnRoute,
    DidcommMessageTyp? typ})
    : super(
          id: id ?? Uuid().v4(),
          type: DidcommMessages.presentation.value,
          body: {},
          replyUrl: replyUrl,
          replyTo: replyTo,
          threadId: threadId,
          parentThreadId: parentThreadId,
          from: from,
          to: to,
          createdTime: createdTime,
          expiresTime: expiresTime,
          pleaseAck: pleaseAck,
          fromPrior: fromPrior,
          additionalHeaders: additionalHeaders,
          webRedirect: webRedirect,
          returnRoute: returnRoute,
          typ: typ) {
  if (goalCode != null) body['goal_code'] = goalCode;
  if (comment != null) body['comment'] = comment;
  attachments = [];
  for (var d in verifiablePresentation) {
    if (d.presentationSubmission == null) {
      throw Exception(
          'The verifiable Presentation used here must contain a presentation submission');
    }
    var attachment = Attachment(
        data: AttachmentData(json: d.toJson()),
        id: Uuid().v4(),
        format: AttachmentFormat.presentationSubmission2.value,
        mediaType: 'application/json');
    attachments!.add(attachment);
  }
}