diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e9465..b8a5641 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Added `getRedirectURIs` endpoint - Added `getDataStreamSummary` endpoint +- Added `applicationData` parameter to `study.setInvitation` endpoint ### Fixed diff --git a/src/endpoints/study/index.ts b/src/endpoints/study/index.ts index 2177133..7887ddd 100644 --- a/src/endpoints/study/index.ts +++ b/src/endpoints/study/index.ts @@ -164,14 +164,23 @@ class Study extends Endpoint { studyId, title, description, + applicationData, }: { studyId: string; title: string; description: string; + applicationData?: { + studyId: string; + [key: string]: string; + } | null; }) { const setInvitation = new StudyServiceRequest.SetInvitation( new UUID(studyId), - new StudyInvitation(title, description), + new StudyInvitation( + title, + description, + applicationData ? JSON.stringify(applicationData) : null, + ), ); const request = serialize({ request: setInvitation, diff --git a/src/test/endpoints/study/study.test.ts b/src/test/endpoints/study/study.test.ts index c221c81..6ccbaba 100644 --- a/src/test/endpoints/study/study.test.ts +++ b/src/test/endpoints/study/study.test.ts @@ -124,6 +124,31 @@ describe("Study", () => { expect(retrievedStudy.invitation.description).toBe("This is an invitation"); }); + it("should be able to set invitation with application data", async () => { + await testClient.study.setInvitation({ + studyId: study.studyId.stringRepresentation, + title: "Invitation", + description: "This is an invitation", + applicationData: { + studyId: study.studyId.stringRepresentation, + key2: "value2", + }, + }); + + const retrievedStudy = await testClient.study.getDetails({ + studyId: study.studyId.stringRepresentation, + }); + + expect(retrievedStudy).toBeInstanceOf(StudyDetails); + expect(retrievedStudy.invitation.name).toBe("Invitation"); + expect(retrievedStudy.invitation.description).toBe("This is an invitation"); + const applicationData = JSON.parse( + retrievedStudy.invitation.applicationData, + ); + expect(applicationData.studyId).toEqual(study.studyId.stringRepresentation); + expect(applicationData.key2).toEqual("value2"); + }); + it("setting invitation for a study that does not exist should throw an error", async () => { try { await testClient.study.setInvitation({