Skip to content

Commit

Permalink
Merge pull request #125 from davidmarcos98/allow-organization-id-on-c…
Browse files Browse the repository at this point in the history
…reate-chart

Allow organization id on create chart
  • Loading branch information
chekos authored Jun 7, 2023
2 parents 2ec4feb + 8f98686 commit 9834837
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions datawrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def create_chart(
chart_type: str = "d3-bars-stacked",
data: Union[pd.DataFrame, None] = None,
folder_id: str = "",
organization_id: str = "",
metadata: Optional[Dict[Any, Any]] = None,
) -> Union[Dict[Any, Any], None, Any]:
"""Creates a new Datawrapper chart, table or map.
Expand All @@ -147,6 +148,8 @@ def create_chart(
A pandas DataFrame containing the data to be added, by default None
folder_id : str, optional
ID of folder in Datawrapper.de for the chart, table or map to be created in, by default ""
organization_id : str, optional
ID of the team where the chart should be created. The authenticated user must have access to this team.
metadata: dict, optional
A Python dictionary of properties to add.
Expand All @@ -163,6 +166,8 @@ def create_chart(

if folder_id:
_data["folderId"] = folder_id
if organization_id:
_data["organizationId"] = organization_id
if metadata:
_data["metadata"] = metadata # type: ignore

Expand Down Expand Up @@ -636,8 +641,9 @@ def get_charts(
search: str = "",
order: str = "DESC",
order_by: str = "createdAt",
folder_id: str = "",
limit: int = 25,
folder_id: str = "",
team_id: str = "",
) -> Union[None, List[Any]]:
"""Retrieves a list of charts by User
Expand All @@ -653,10 +659,12 @@ def get_charts(
Result order (ascending or descending), by default "DESC"
order_by : str, optional
Attribute to order by. One of createdAt, email, id, or name, by default "createdAt"
folder_id: str, optional
ID of the folder to search charts in, by default ""
limit : int, optional
Maximum items to fetch, by default 25
folder_id : str, optional
ID of folder in Datawrapper.de where to list charts, by default ""
team_id : str, optional
ID of the team where to list charts. The authenticated user must have access to this team, by default ""
Returns
-------
Expand All @@ -678,10 +686,12 @@ def get_charts(
_query["order"] = order
if order_by:
_query["orderBy"] = order_by
if folder_id:
_query["folderId"] = folder_id
if limit:
_query["limit"] = str(limit)
if folder_id:
_query["folderId"] = folder_id
if team_id:
_query["teamId"] = team_id

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

Expand Down

0 comments on commit 9834837

Please sign in to comment.