Skip to content

Commit

Permalink
Merge branch 'master' into allow-organization-id-on-create-chart
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmarcos98 authored Feb 26, 2022
2 parents c684aac + 9487ab1 commit 2e3ca30
Show file tree
Hide file tree
Showing 8 changed files with 529 additions and 441 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ jobs:
python-version: ["3.7", "3.8"]

steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v2.4.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v2.3.2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: make download-poetry

- name: Set up cache
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
- uses: actions/first-interaction@v1.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: 'Hello @${{ github.actor }}, thank you for submitting a PR! We will respond as soon as possible.'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v2.4.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v2.3.2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: make download-poetry

- name: Set up cache
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5.15.0
- uses: release-drafter/release-drafter@v5.18.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ check-safety:
$(POETRY_COMMAND_FLAG)poetry check
$(PIP_COMMAND_FLAG)poetry run pip check
$(PIP_COMMAND_FLAG)poetry run python -m pip install --upgrade pip
$(SAFETY_COMMAND_FLAG)poetry run safety check --full-report
$(BANDIT_COMMAND_FLAG)poetry run bandit -ll -r datawrapper/

.PHONY: check-style
Expand Down
12 changes: 11 additions & 1 deletion datawrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
dw.account_info()
"""
from typing import Any, Dict, Iterable, List, Union
from typing import Any, Dict, Iterable, List, Optional, Union

import json
import os
Expand Down Expand Up @@ -127,6 +127,7 @@ def create_chart(
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.
You can pass a pandas DataFrame as a `data` argument to upload data.
Expand All @@ -144,6 +145,8 @@ def create_chart(
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.
Returns
-------
Expand All @@ -160,6 +163,8 @@ def create_chart(
_data["folderId"] = folder_id
if organization_id:
_data["organizationId"] = organization_id
if metadata:
_data["metadata"] = metadata # type: ignore

new_chart_response = r.post(
url=self._CHARTS_URL, headers=_header, data=json.dumps(_data)
Expand Down Expand Up @@ -609,6 +614,7 @@ def get_charts(
search: str = "",
order: str = "DESC",
order_by: str = "createdAt",
folder_id: str = "",
limit: int = 25,
folder_id: str = "",
team_id: str = "",
Expand All @@ -627,6 +633,8 @@ 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
Expand Down Expand Up @@ -654,6 +662,8 @@ 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:
Expand Down
Loading

0 comments on commit 2e3ca30

Please sign in to comment.