OfferCredential constructor

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

Implementation

OfferCredential(
    {String? id,
    this.replacementId,
    this.goalCode,
    this.comment,
    this.credentialPreview,
    this.detail,
    this.credentialManifest,
    this.fulfillment,
    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(
          type: DidcommMessages.offerCredential.value,
          id: id ?? Uuid().v4(),
          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 (comment != null) body['comment'] = comment;
  if (goalCode != null) body['goal_code'] = goalCode;
  if (replacementId != null) body['replacement_id'] = replacementId;
  if (credentialPreview != null) {
    body['credential_preview'] = credentialPreview!.toJson();
  }
  if (detail != null) {
    attachments = [];
    for (var a in detail!) {
      attachments!.add(Attachment(
          data: AttachmentData(json: a.toJson()),
          id: Uuid().v4(),
          format: AttachmentFormat.ldProofVcDetail.value,
          mediaType: 'application/json'));
    }
  }
  if (credentialManifest != null) {
    attachments ??= [];
    attachments!.add(Attachment(
        data: AttachmentData(json: credentialManifest!.toJson()),
        id: Uuid().v4(),
        format: AttachmentFormat.credentialManifest.value,
        mediaType: 'application/json'));
  }

  if (fulfillment != null) {
    attachments ??= [];
    attachments!.add(Attachment(
        data: AttachmentData(json: fulfillment!.toJson()),
        id: Uuid().v4(),
        format: AttachmentFormat.credentialFulfillment.value,
        mediaType: 'application/json'));
  }
}