IssueCredential constructor

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

Implementation

IssueCredential(
    {String? id,
    this.goalCode,
    this.comment,
    this.replacementId,
    this.credentials,
    this.credentialFulfillment,
    super.replyUrl,
    super.replyTo,
    super.parentThreadId,
    super.threadId,
    super.from,
    List<String>? super.to,
    super.createdTime,
    super.expiresTime,
    super.pleaseAck,
    super.fromPrior,
    super.additionalHeaders,
    super.webRedirect,
    super.returnRoute,
    super.typ})
    : super(
          type: DidcommMessages.issueCredential,
          id: id ?? Uuid().v4(),
          body: {}) {
  if (comment != null) body['comment'] = comment;
  if (goalCode != null) body['goal_code'] = goalCode;
  if (replacementId != null) body['replacement_id'] = replacementId;
  if (credentials != null) {
    attachments = [];
    for (var a in credentials!) {
      attachments!.add(Attachment(
          data: AttachmentData(json: a.toJson()),
          id: Uuid().v4(),
          format: AttachmentFormat.ldProofVc,
          mediaType: 'application/json'));
    }
  }
  if (credentialFulfillment != null) {
    attachments ??= [];
    attachments!.add(Attachment(
        data: AttachmentData(json: credentialFulfillment!.toJson()),
        id: Uuid().v4(),
        format: AttachmentFormat.credentialFulfillment,
        mediaType: 'application/json'));
  }
}