Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit 9ccdabf

Browse files
add ability to include custom parameters on respondent gateawy url creation
1 parent 5a15ce6 commit 9ccdabf

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,32 @@ signed_link = gateway.create_respondent_url(url,
6363
'male',
6464
'90210',
6565
'very-unique-respondent-id',
66+
6667
ttl=60)
6768
# https://respondent.fake.rex.dynata.com/start?ctx=XXXX&language=en&birth_date=1990-01-01&gender=male&postal_code=90210&respondent_id=very-unique-respondent-id&access_key=rex_access_key&expiration=2021-11-29T15:35:12.993Z&signature=4353e8c4ca8f8fb75530214ac78139b55ca3f090438c639476b8584afe1396e6
6869
```
6970

71+
### Add additional query parameters to a link that will be present on return from survey
72+
```
73+
url = 'https://respondent.fake.rex.dynata.com/start?ctx=XXXX&language=en'
74+
75+
custom_params = {
76+
'custom_parameter': 'custom_value',
77+
'another_custom_parameter': 'another_custom_value'
78+
}
79+
80+
signed_link = gateway.create_respondent_url(url,
81+
'1990-01-01',
82+
'male',
83+
'90210',
84+
'very-unique-respondent-id',
85+
additional_params=custom_params,
86+
ttl=60)
87+
88+
# https://respondent.fake.rex.dynata.com/start?ctx=XXXX&language=en&custom_parameter=custom_value&another_custom_parameter=another_custom_value&birth_date=1990-01-01&gender=male&postal_code=90210&respondent_id=very-unique-respondent-id&access_key=rex_access_key&expiration=2021-12-02T13:48:55.759Z&signature=cf443326b73fb8af14c590e18d79a970fc3f73327c2d140c324ee1ce3020d064
89+
```
90+
91+
7092
### Sign an inbound /start link with your credentials
7193
```
7294
url = 'https://respondent.fake.rex.dynata.com/start?ctx=XXXX&language=en'

dynata_rex/respondent_gateway.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def create_respondent_url(self,
5656
gender: str,
5757
postal_code: str,
5858
respondent_id: str,
59+
additional_params: dict = None,
5960
ttl: Union[int, None] = None,
6061
url_quoting: bool = False) -> str:
6162
"""
@@ -67,9 +68,16 @@ def create_respondent_url(self,
6768
@gender: 'male' / 'female'
6869
@postal: postal code as string
6970
@respondent_id : unique identifier for the respondent
71+
72+
@additional_params: additional parameters that will be included
73+
on the return back from the survey
74+
@ttl: time to live for signature in seconds
75+
@url_quoting: whether to URL quote the returned URL
7076
"""
7177
parsed = urlparse(url)
7278
base_params = dict(parse_qsl(parsed.query))
79+
if additional_params:
80+
base_params = dict(base_params, **additional_params)
7381
required_params = {
7482
'birth_date': birth_date,
7583
'gender': gender,

0 commit comments

Comments
 (0)