Skip to content
Snippets Groups Projects
Commit 3a4db75c authored by Zdravko Iliev's avatar Zdravko Iliev
Browse files

feat: add new endpoint for getting connection by out of band id

parent 64356120
No related branches found
No related tags found
1 merge request!58feat: add new endpoint for getting connection by out of band id
Pipeline #68590 waiting for manual action
......@@ -123,6 +123,36 @@
}
}
},
"/api/v1/connections/oob/{id}": {
"get": {
"operationId": "RestController_getConnectionByOobId",
"parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ConnectionRecordDto"
}
}
}
}
}
}
}
},
"/api/v1/schemas": {
"post": {
"operationId": "RestController_createSchema",
......
# OCM ENGINE - AGENT
# OCM ENGINE - AGENT
Agent service is a wrapper around @ocm-engine/askar library.
......
......@@ -66,6 +66,11 @@ export class RestController {
return this.agentService.deleteConnectionById(id);
}
@Get("/connections/oob/:id")
async getConnectionByOobId(@Param("id") id: string) {
return this.agentService.getConnectionByOobId(id);
}
@Post("/schemas")
async createSchema(@Body() schemaDto: CreateSchemaRequestDto) {
return this.agentService.createSchema(schemaDto);
......
......@@ -111,6 +111,28 @@ export class AgentService {
return connectionArray;
}
getConnectionByOobId = async (oobId: string) => {
const connectionRecords =
await this.askar.agent.connections.findAllByOutOfBandId(oobId);
const connectionArray = connectionRecords.map((singleConnectionRes) => {
const connectionResponse = new ConnectionRecordDto();
connectionResponse.id = singleConnectionRes.id;
connectionResponse.state = singleConnectionRes.state;
connectionResponse.connectionName = singleConnectionRes.theirLabel;
connectionResponse.alias = singleConnectionRes.alias;
connectionResponse.did = singleConnectionRes.did;
connectionResponse.invitationDid = singleConnectionRes.invitationDid;
connectionResponse.outOfBandId = singleConnectionRes.outOfBandId;
connectionResponse.createdAt = singleConnectionRes.createdAt;
connectionResponse.imageUrl = singleConnectionRes.imageUrl;
return connectionResponse;
});
return connectionArray;
};
getConnectionById = async (id: string): Promise<ConnectionRecordDto> => {
const agentResponse = await this.askar.agent.connections.findById(id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment