diff --git a/packages/contact-manager-rest-api/__tests__/agent.ts b/packages/contact-manager-rest-api/__tests__/agent.ts index 0c73f11b1..8dda2689a 100644 --- a/packages/contact-manager-rest-api/__tests__/agent.ts +++ b/packages/contact-manager-rest-api/__tests__/agent.ts @@ -3,8 +3,9 @@ import { DataStore, DataStoreORM } from '@veramo/data-store' import { IRequiredPlugins } from '../src' import { DB_CONNECTION_NAME, sqliteConfig } from './database' import { ContactManager } from '@sphereon/ssi-sdk.contact-manager' -import { ContactStore } from '@sphereon/ssi-sdk.data-store' +import { ContactStore, PartyTypeEnum } from '@sphereon/ssi-sdk.data-store' import { DataSources } from '@sphereon/ssi-sdk.agent-config' +import { v4 } from 'uuid' const dbConnection = DataSources.singleInstance() .addConfig(DB_CONNECTION_NAME, sqliteConfig) @@ -14,4 +15,48 @@ const agent = createAgent({ plugins: [new DataStore(dbConnection), new DataStoreORM(dbConnection), new ContactManager({ store: new ContactStore(dbConnection) })], }) +agent.cmAddContactType({ + name: "people", + type: PartyTypeEnum.NATURAL_PERSON, + tenantId: v4() +}).then(ct=> { + agent.cmAddContact({ + firstName: "Abraham", + middleName: "Gerrit Jan", + lastName: "ten Cate", + displayName: "Bram ten Cate", + contactType: ct, + uri: "example.com" + }) + agent.cmAddContact({ + firstName: "Kraak", + middleName: "en", + lastName: "Smaak", + displayName: "Kraak en Smaak", + contactType: ct, + uri: "example.com" + }) +}).catch(e => { + console.log(e) +}) +agent.cmAddContactType({ + name: "orgzanizations", + type: PartyTypeEnum.ORGANIZATION, + tenantId: v4() +}).then(ct=> { + agent.cmAddContact({ + legalName: "Sphereon International", + displayName: "Sphereon B.V.", + contactType: ct, + uri: "sphereon.com" + }) + agent.cmAddContact({ + legalName: "Kamer van verkoophandel", + displayName: "Kamer van koophandel", + contactType: ct, + uri: "kvk.nl" + }) +}).catch(e=> { + console.log(e) +}) export default agent diff --git a/packages/contact-manager-rest-api/src/api-functions.ts b/packages/contact-manager-rest-api/src/api-functions.ts index 101990845..1da07992a 100644 --- a/packages/contact-manager-rest-api/src/api-functions.ts +++ b/packages/contact-manager-rest-api/src/api-functions.ts @@ -29,7 +29,7 @@ export function partyReadEndpoint(router: Router, context: IRequiredContext, opt const path = opts?.path ?? '/parties' router.get(`${path}/:partyId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => { try { - const partyId = request.params.contactId + const partyId = request.params.partyId const party = await context.agent.cmGetContact({ contactId: partyId }) response.statusCode = 200 return response.send(party)