1. Send a Presentation
To send a presentation to another profile, use the sendPresentation
method. This method accepts a profileId
, a vp
object, and an optional encrypt
parameter.
Copy const profileId = 'janesmith' ;
const vp = your_presentation;
const encrypt = true ;
await learnCard . invoke .sendPresentation (profileId , vp , encrypt);
Send a Presentation This endpoint sends a presentation to a user based on their profileId
POST ../api /presentation/send/{profileId}
Copy const response = await fetch ( '../api/presentation/send/{profileId}' , {
method : 'POST' ,
headers : {
"Authorization" : "Bearer <token>" ,
"Content-Type" : "application/json"
} ,
body : JSON .stringify ({
"presentation" : {
"@context" : [
"text"
] ,
"type" : "text" ,
"proof" : {
"type" : "text" ,
"created" : "text" ,
"proofPurpose" : "text" ,
"verificationMethod" : "text"
}
}
}) ,
});
const data = await response .json ();
2. Accept a Presentation
To accept a presentation, use the acceptPresentation
method. This method accepts a uri
parameter.
Copy const uri = 'your_presentation_uri' ;
await learnCard . invoke .acceptPresentation (uri);
Accept a Presentation This endpoint accepts a presentation
POST ../api /presentation/accept/{uri}
Copy const response = await fetch ( '../api/presentation/accept/{uri}' , {
method : 'POST' ,
headers : {
"Authorization" : "Bearer <token>"
} ,
});
const data = await response .json ();
3. Get Received Presentations
To retrieve all received presentations, use the getReceivedPresentations
method. This method accepts an optional from
parameter.
Copy const from = 'johnsmith' ;
await learnCard . invoke .getReceivedPresentations (from);
Get received presentations This endpoint returns the current user's received presentations
GET ../api /presentation/received
Copy const response = await fetch ( '../api/presentation/received' , {
method : 'GET' ,
headers : {
"Authorization" : "Bearer <token>"
} ,
});
const data = await response .json ();
Copy [
{
"uri" : "text" ,
"to" : "text" ,
"from" : "text" ,
"sent" : "2024-09-14T17:40:59.936Z" ,
"received" : "2024-09-14T17:40:59.936Z"
}
]
4. Get Sent Presentations
To retrieve all sent presentations, use the getSentPresentations
method. This method accepts an optional to
parameter.
Copy const to = 'janesmith' ;
await learnCard . invoke .getSentPresentations (to);
Get sent presentations This endpoint returns the current user's sent presentations
GET ../api /presentation/sent
Copy const response = await fetch ( '../api/presentation/sent' , {
method : 'GET' ,
headers : {
"Authorization" : "Bearer <token>"
} ,
});
const data = await response .json ();
Copy [
{
"uri" : "text" ,
"to" : "text" ,
"from" : "text" ,
"sent" : "2024-09-14T17:40:59.936Z" ,
"received" : "2024-09-14T17:40:59.936Z"
}
]
5. Get Incoming Presentations
To retrieve all incoming presentations, use the getIncomingPresentations
method. This method accepts an optional from
parameter.
Copy const from = 'johnsmith' ;
await learnCard . invoke .getIncomingPresentations (from);
Get incoming presentations This endpoint returns the current user's incoming presentations
GET ../api /presentation/incoming
Copy const response = await fetch ( '../api/presentation/incoming' , {
method : 'GET' ,
headers : {
"Authorization" : "Bearer <token>"
} ,
});
const data = await response .json ();
Copy [
{
"uri" : "text" ,
"to" : "text" ,
"from" : "text" ,
"sent" : "2024-09-14T17:40:59.936Z" ,
"received" : "2024-09-14T17:40:59.936Z"
}
]
6. Delete a Presentation
To delete a presentation, use the deletePresentation
method. This method accepts a uri
parameter.
Copy const uri = 'your_presentation_uri' ;
await learnCard . invoke .deletePresentation (uri);
Delete a presentation This endpoint deletes a presentation
DELETE ../api /presentation/{uri}
Copy const response = await fetch ( '../api/presentation/{uri}' , {
method : 'DELETE' ,
headers : {
"Authorization" : "Bearer <token>"
} ,
});
const data = await response .json ();