Skip to content

Commit

Permalink
Merge pull request #126 from Sphereon-Opensource/feature/DPP-22
Browse files Browse the repository at this point in the history
feat: added contact test data
  • Loading branch information
nklomp authored Sep 15, 2023
2 parents c541b23 + 51861fd commit 4de2a64
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
47 changes: 46 additions & 1 deletion packages/contact-manager-rest-api/__tests__/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -14,4 +15,48 @@ const agent = createAgent<IRequiredPlugins>({
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
2 changes: 1 addition & 1 deletion packages/contact-manager-rest-api/src/api-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4de2a64

Please sign in to comment.