-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add from record method to cred preview #428
feat: add from record method to cred preview #428
Conversation
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Codecov Report
@@ Coverage Diff @@
## main #428 +/- ##
==========================================
- Coverage 86.24% 85.61% -0.64%
==========================================
Files 249 249
Lines 5264 5346 +82
Branches 784 798 +14
==========================================
+ Hits 4540 4577 +37
- Misses 724 769 +45
Continue to review full report at Codecov.
|
Once test passes, I will merge. |
@@ -53,7 +48,7 @@ export async function e2eTest({ | |||
issuerConnectionId: senderRecipientConnection.id, | |||
credentialTemplate: { | |||
credentialDefinitionId: definition.id, | |||
preview: previewFromAttributes({ | |||
preview: CredentialPreview.fromRecord({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this improvement. I would consider calling it fromJSON
to prevent confusion with other framework's records, that's what I would expect as a consumer at least.
To me, the best API would be just passing JSON objects, but this is definitely step forward 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with fromJSON
is that it clashes with toJSON
.
Currently, toJSON
transforms the class instance to the JSON representation. If we have a fromJSON
method, I'd expect it to be the exact opposite of toJSON
. Which it is not.
The reason I didn't change the constructor is because the fromRecord
method removes the option to set a mime-type. Most time we just use text/plain, but it should be possible to set it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not set on fromRecord
, so if you have suggestions I'm happy to create a new PR
Signed-off-by: Timo Glastra <timo@animo.id>
Two api improvements
signatureType
parameter anymore (just add bloat to the API)fromRecord
method to credential preview to be able to create a preview from json object. this makes it a lot simpler:Before
After