Skip to content

Commit 9834837

Browse files
authored
Merge pull request #125 from davidmarcos98/allow-organization-id-on-create-chart
Allow organization id on create chart
2 parents 2ec4feb + 8f98686 commit 9834837

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

datawrapper/__main__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def create_chart(
129129
chart_type: str = "d3-bars-stacked",
130130
data: Union[pd.DataFrame, None] = None,
131131
folder_id: str = "",
132+
organization_id: str = "",
132133
metadata: Optional[Dict[Any, Any]] = None,
133134
) -> Union[Dict[Any, Any], None, Any]:
134135
"""Creates a new Datawrapper chart, table or map.
@@ -147,6 +148,8 @@ def create_chart(
147148
A pandas DataFrame containing the data to be added, by default None
148149
folder_id : str, optional
149150
ID of folder in Datawrapper.de for the chart, table or map to be created in, by default ""
151+
organization_id : str, optional
152+
ID of the team where the chart should be created. The authenticated user must have access to this team.
150153
metadata: dict, optional
151154
A Python dictionary of properties to add.
152155
@@ -163,6 +166,8 @@ def create_chart(
163166

164167
if folder_id:
165168
_data["folderId"] = folder_id
169+
if organization_id:
170+
_data["organizationId"] = organization_id
166171
if metadata:
167172
_data["metadata"] = metadata # type: ignore
168173

@@ -636,8 +641,9 @@ def get_charts(
636641
search: str = "",
637642
order: str = "DESC",
638643
order_by: str = "createdAt",
639-
folder_id: str = "",
640644
limit: int = 25,
645+
folder_id: str = "",
646+
team_id: str = "",
641647
) -> Union[None, List[Any]]:
642648
"""Retrieves a list of charts by User
643649
@@ -653,10 +659,12 @@ def get_charts(
653659
Result order (ascending or descending), by default "DESC"
654660
order_by : str, optional
655661
Attribute to order by. One of createdAt, email, id, or name, by default "createdAt"
656-
folder_id: str, optional
657-
ID of the folder to search charts in, by default ""
658662
limit : int, optional
659663
Maximum items to fetch, by default 25
664+
folder_id : str, optional
665+
ID of folder in Datawrapper.de where to list charts, by default ""
666+
team_id : str, optional
667+
ID of the team where to list charts. The authenticated user must have access to this team, by default ""
660668
661669
Returns
662670
-------
@@ -678,10 +686,12 @@ def get_charts(
678686
_query["order"] = order
679687
if order_by:
680688
_query["orderBy"] = order_by
681-
if folder_id:
682-
_query["folderId"] = folder_id
683689
if limit:
684690
_query["limit"] = str(limit)
691+
if folder_id:
692+
_query["folderId"] = folder_id
693+
if team_id:
694+
_query["teamId"] = team_id
685695

686696
get_charts_response = r.get(url=_url, headers=_header, params=_query)
687697

0 commit comments

Comments
 (0)