Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Added `getRedirectURIs` endpoint
- Added `getDataStreamSummary` endpoint
- Added `applicationData` parameter to `study.setInvitation` endpoint

### Fixed

Expand Down
11 changes: 10 additions & 1 deletion src/endpoints/study/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 25 additions & 0 deletions src/test/endpoints/study/study.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down