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

Commit 8f03cd2

Browse files
Merge pull request #8 from dynata/new_features
Add `get_attributes` and `get_attribute_info`
2 parents b76c558 + c7ac1f8 commit 8f03cd2

File tree

2 files changed

+102
-1
lines changed

2 files changed

+102
-1
lines changed

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,73 @@ gw.expire_context('super-unique-ctx-id')
209209
# }
210210
```
211211

212+
##### Get Attributes
213+
```
214+
gw.get_attributes('country', 'page_number', 'page_size')
215+
216+
# {
217+
# 'data':
218+
# [
219+
# {
220+
# 'active': true,
221+
# 'parameter_id": 402
222+
# }
223+
# ]
224+
# }
225+
```
226+
227+
##### Get Attribute Info
228+
```
229+
gw.get_attribute_info('attribute-id')
230+
231+
# {
232+
# 'id': 402,
233+
# 'name': "This Parameter",
234+
# 'description': "Details of what this is",
235+
# 'display_mode: "N" (Optional),
236+
# 'parent_dependencies':
237+
# [
238+
# 'answer_ids':
239+
# [
240+
# { 12 }
241+
# ],
242+
# 'parameter_id':403
243+
# ],
244+
# 'expiration_duration': 36000 (Optional),
245+
# 'is_active': true,
246+
# 'countries':
247+
# [
248+
# { "US" }
249+
# ],
250+
# 'question': (Optional)
251+
# {
252+
# 'text': "How much wood can a woodchuck?",
253+
# 'translations':
254+
# [
255+
# {
256+
# 'locale': "BG",
257+
# 'text': "Other Language"
258+
# }
259+
# ]
260+
# }
261+
# 'answers':
262+
# [
263+
# {
264+
# 'id': 99,
265+
# 'text': "A ton",
266+
# 'countries':
267+
# [
268+
# { "US" }
269+
# ],
270+
# 'translations':
271+
# [
272+
# {
273+
# 'locale': "GB",
274+
# 'text': "Other language"
275+
# ]
276+
# }
277+
# ]
278+
# }
279+
```
280+
212281

dynata_rex/respondent_gateway.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,42 @@ def expire_context(self, context_id: str) -> None:
237237
return res if res else None
238238

239239
def get_context(self, context_id: int) -> dict:
240-
"""Get specific opportunity from SMOR
240+
"""
241+
Get specific opportunity from SMOR
241242
242243
@context_id: identifier for the context
243244
"""
244245
endpoint = f"{self.base_url}/get-context"
245246
data = {"id": context_id}
246247
return self.make_request.post(endpoint, data)
248+
249+
def get_attribute_info(self, attribute_id: int) -> dict:
250+
"""
251+
Get parameter info about a specific attribute id
252+
253+
@attribute_id: specific singular id for a parameter item
254+
"""
255+
endpoint = f"{self.base_url}/get-attribute-info"
256+
data = {"id": attribute_id}
257+
return self.make_request.post(endpoint, data)
258+
259+
def get_attributes(self,
260+
country: str,
261+
page_number: int,
262+
page_size: int) -> dict:
263+
"""
264+
Get a list of attribute id's and their statuses
265+
266+
@country: Country code for which you would like attributes
267+
268+
@page_number: What page number you are requesting (for pagination)
269+
270+
@page_size: How many id's you would like returned in each page
271+
"""
272+
endpoint = f"{self.base_url}/get-attributes"
273+
data = {
274+
"country": country,
275+
"page_number": page_number,
276+
"page_size": page_size
277+
}
278+
return self.make_request.post(endpoint, data)

0 commit comments

Comments
 (0)