Skip to content
This repository was archived by the owner on Dec 8, 2023. It is now read-only.

Commit 7d0e0ff

Browse files
authored
Update DataExport creation params
Adds `include_child_accounts` and `custom_fields` params to the DataExport creation endpoint
1 parent be89569 commit 7d0e0ff

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

alma/endpoints/exports.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ def create(
1515
payout_id: str = None,
1616
start: datetime = None,
1717
end: datetime = None,
18+
include_child_accounts = False,
19+
custom_fields = None,
1820
):
1921
""" Create a new export"""
20-
data = {"type": export_type.value}
22+
data = {
23+
"type": export_type.value,
24+
"include_child_accounts": include_child_accounts,
25+
}
2126
if payout_id:
2227
data["payout"] = payout_id
2328

@@ -26,6 +31,14 @@ def create(
2631

2732
if end:
2833
data["end"] = int(end.timestamp())
34+
35+
if custom_fields:
36+
if isinstance(custom_fields, str):
37+
data["custom_fields"] = custom_fields
38+
elif type(custom_fields) in (list, tuple, set):
39+
data["custom_fields"] = ",".join(custom_fields)
40+
else:
41+
raise TypeError(f"Expected comma-separated string or a list/tuple/set of strings for custom_fields, got {type(custom_fields)}")
2942

3043
return self.request(self.EXPORTS_PATH).set_body(data).post().expectJson(Export)
3144

0 commit comments

Comments
 (0)