Skip to content

Commit 8e26b37

Browse files
authored
✨ Implement "export_survey_link" in module Surveys (#296)
1 parent 01b33c9 commit 8e26b37

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

redcap/methods/surveys.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,58 @@
1111
class Surveys(Base):
1212
"""Responsible for all API methods under 'Surveys' in the API Playground"""
1313

14+
def export_survey_link(
15+
self,
16+
instrument: str,
17+
record: str,
18+
event: Optional[str] = None,
19+
repeat_instance: int = 1,
20+
):
21+
"""
22+
Export one survey link
23+
24+
Note:
25+
The passed instrument must be set up as a survey instrument.
26+
27+
Args:
28+
instrument:
29+
Name of instrument as seen in the Data Dictionary (metadata).
30+
record:
31+
Name of the record
32+
event:
33+
Unique event name, only used in longitudinal projects
34+
repeat_instance:
35+
only for projects with repeating instruments/events)
36+
The repeat instance number of the repeating event (if longitudinal)
37+
or the repeating instrument (if classic or longitudinal).
38+
Default value is '1'.
39+
40+
Returns:
41+
Str:
42+
URL of survey link requested
43+
44+
Examples:
45+
>>> proj.export_survey_link(instrument="form_1", record="5", event="event_1_arm_1")
46+
https://redcap.mytld.com/surveys/?s=6B2zFAEWPVSrXnnx
47+
"""
48+
payload = self._initialize_payload(
49+
content="surveyLink"
50+
)
51+
payload["instrument"] = instrument
52+
payload["record"] = record
53+
if event:
54+
payload["event"] = event
55+
payload["repeat_instance"] = repeat_instance
56+
57+
return_type = "str"
58+
response = cast(Union[Json, str], self._call_api(payload, return_type))
59+
60+
return self._return_data(
61+
response=response,
62+
content="surveyLink",
63+
format_type=return_type,
64+
)
65+
1466
def export_survey_participant_list(
1567
self,
1668
instrument: str,

0 commit comments

Comments
 (0)