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

Commit 0910268

Browse files
authored
Merge pull request #26 from alma/fix/create-data-exports
Update DataExport creation params
2 parents be89569 + d721c88 commit 0910268

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

alma/endpoints/exports.py

Lines changed: 15 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,15 @@ 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+
else:
39+
try:
40+
data["custom_fields"] = ",".join(custom_fields)
41+
except TypeError as e:
42+
raise TypeError(f"Expected comma-separated string or an iterable yielding strings for custom_fields, got {type(custom_fields)}") from e
2943

3044
return self.request(self.EXPORTS_PATH).set_body(data).post().expectJson(Export)
3145

0 commit comments

Comments
 (0)