diff --git a/.github/assets/logos/Pennylane.png b/.github/assets/logos/Pennylane.png new file mode 100644 index 0000000000..f5a1543ff2 Binary files /dev/null and b/.github/assets/logos/Pennylane.png differ diff --git a/Pennylane/Pennylane_List_all_categories.ipynb b/Pennylane/Pennylane_List_all_categories.ipynb new file mode 100644 index 0000000000..0430c8e2a8 --- /dev/null +++ b/Pennylane/Pennylane_List_all_categories.ipynb @@ -0,0 +1,239 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1ec65662-8eb6-4a98-a16e-ffc3729252b6", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Pennylane.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "hairy-interstate", + "metadata": {}, + "source": [ + "# Pennylane - List all categories" + ] + }, + { + "cell_type": "markdown", + "id": "db03090b-015f-4b1b-8c7c-ba11f37d60b5", + "metadata": {}, + "source": [ + "**Tags:** #pennylane #list #categories #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "c54c97eb-8d4d-417c-a402-7adf5327d7fb", + "metadata": {}, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "ed962863-54e5-48e4-aa48-877adeba86fc", + "metadata": {}, + "source": [ + "**Description:** This endpoint returns a list of categories." + ] + }, + { + "cell_type": "markdown", + "id": "fdcf05b5-17d7-4c11-88ec-f722cf264a7f", + "metadata": {}, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "75da13af-72c2-44b9-8c06-ed3bfa4700ac", + "metadata": { + "execution": { + "iopub.execute_input": "2022-08-31T10:54:23.866665Z", + "iopub.status.busy": "2022-08-31T10:54:23.866431Z", + "iopub.status.idle": "2022-08-31T10:54:23.871270Z", + "shell.execute_reply": "2022-08-31T10:54:23.870705Z", + "shell.execute_reply.started": "2022-08-31T10:54:23.866641Z" + }, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b5605c12-6814-4d98-99b0-aaaa4526014f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import pandas as pd\n", + "import naas_python #to use this lib create your account on naas.ai" + ] + }, + { + "cell_type": "markdown", + "id": "1b6ad1a8-308e-4778-963c-fc21d492a1a9", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "06d385f7-6b96-4e95-8721-b02ef7c52c83", + "metadata": { + "tags": [ + "parameters" + ] + }, + "outputs": [], + "source": [ + "api_token = naas_python.secret.get(\"PENNYLANE_API_TOKEN\").value or \"YOUR_PENNYLANE_API_TOKEN\" # if you don't have a naas.ai account, add api_token as string" + ] + }, + { + "cell_type": "markdown", + "id": "e2b06c06-c20d-4d1a-a228-dca532603925", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "14cd5a2a-8e0a-45f6-a31c-f487950db30d", + "metadata": {}, + "source": [ + "### List all categories" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4a62312c-53f7-4285-b1fd-5dde2592022c", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def list_all_catgories(\n", + " api_token,\n", + " per_page=50,\n", + " sort=None,\n", + " filter=None,\n", + "):\n", + " url = \"https://app.pennylane.com/api/external/v1/categories\"\n", + " headers = {\n", + " \"Accept\": \"application/json\",\n", + " \"Authorization\": f\"Bearer {api_token}\"\n", + " }\n", + " data = []\n", + " page = 1\n", + " while True:\n", + " # Get data\n", + " res_json = []\n", + " params = {\n", + " \"page\": page,\n", + " \"per_page\": per_page,\n", + " }\n", + " res = requests.get(url, headers=headers, params=params)\n", + " res.raise_for_status()\n", + " if res.status_code == 200:\n", + " result = res.json().get(\"categories\")\n", + "\n", + " # Concat result\n", + " if len(result) > 0:\n", + " data += result\n", + " page += 1\n", + " else:\n", + " break\n", + " return data\n", + "\n", + "result = list_all_catgories(api_token)" + ] + }, + { + "cell_type": "markdown", + "id": "21da518a-e9a5-4655-87a2-52e005f31dbe", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "08861687-49bb-4c65-83a3-a483a8c4b708", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b123c08c-124a-44ac-bc44-fc72a7768434", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "df = pd.DataFrame(result)\n", + "print(\"Rows:\", len(df))\n", + "df.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "078e5821-d264-48b4-a1d1-7bfbc1c05490", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Pennylane/Pennylane_List_all_customers.ipynb b/Pennylane/Pennylane_List_all_customers.ipynb new file mode 100644 index 0000000000..bbf44625de --- /dev/null +++ b/Pennylane/Pennylane_List_all_customers.ipynb @@ -0,0 +1,238 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1ec65662-8eb6-4a98-a16e-ffc3729252b6", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Pennylane.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "hairy-interstate", + "metadata": {}, + "source": [ + "# Pennylane - List all customers" + ] + }, + { + "cell_type": "markdown", + "id": "db03090b-015f-4b1b-8c7c-ba11f37d60b5", + "metadata": {}, + "source": [ + "**Tags:** #pennylane #list #customers #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "c54c97eb-8d4d-417c-a402-7adf5327d7fb", + "metadata": {}, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "ed962863-54e5-48e4-aa48-877adeba86fc", + "metadata": {}, + "source": [ + "**Description:** This endpoint returns a list of customers corresponding to the filter provided." + ] + }, + { + "cell_type": "markdown", + "id": "fdcf05b5-17d7-4c11-88ec-f722cf264a7f", + "metadata": {}, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "75da13af-72c2-44b9-8c06-ed3bfa4700ac", + "metadata": { + "execution": { + "iopub.execute_input": "2022-08-31T10:54:23.866665Z", + "iopub.status.busy": "2022-08-31T10:54:23.866431Z", + "iopub.status.idle": "2022-08-31T10:54:23.871270Z", + "shell.execute_reply": "2022-08-31T10:54:23.870705Z", + "shell.execute_reply.started": "2022-08-31T10:54:23.866641Z" + }, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b5605c12-6814-4d98-99b0-aaaa4526014f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import pandas as pd\n", + "import naas_python #to use this lib create your account on naas.ai" + ] + }, + { + "cell_type": "markdown", + "id": "1b6ad1a8-308e-4778-963c-fc21d492a1a9", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "06d385f7-6b96-4e95-8721-b02ef7c52c83", + "metadata": { + "tags": [ + "parameters" + ] + }, + "outputs": [], + "source": [ + "api_token = naas_python.secret.get(\"PENNYLANE_API_TOKEN\").value or \"YOUR_PENNYLANE_API_TOKEN\" # if you don't have a naas.ai account, add api_token as string" + ] + }, + { + "cell_type": "markdown", + "id": "e2b06c06-c20d-4d1a-a228-dca532603925", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "14cd5a2a-8e0a-45f6-a31c-f487950db30d", + "metadata": {}, + "source": [ + "### List all customers" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4a62312c-53f7-4285-b1fd-5dde2592022c", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def list_customers(\n", + " api_token,\n", + " per_page=50,\n", + " sort=None,\n", + " filter=None,\n", + "):\n", + " url = \"https://app.pennylane.com/api/external/v1/customers\"\n", + " headers = {\n", + " \"Accept\": \"application/json\",\n", + " \"Authorization\": f\"Bearer {api_token}\"\n", + " }\n", + " data = []\n", + " page = 1\n", + " while True:\n", + " # Get data\n", + " res_json = []\n", + " params = {\n", + " \"page\": page,\n", + " \"per_page\": per_page,\n", + " }\n", + " res = requests.get(url, headers=headers, params=params)\n", + " res.raise_for_status()\n", + " if res.status_code == 200:\n", + " result = res.json().get(\"customers\")\n", + "\n", + " # Concat result\n", + " if len(result) > 0:\n", + " data += result\n", + " page += 1\n", + " else:\n", + " break\n", + " return data\n", + "\n", + "result = list_customers(api_token)\n", + "print(\"Customers:\", len(result))" + ] + }, + { + "cell_type": "markdown", + "id": "21da518a-e9a5-4655-87a2-52e005f31dbe", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "08861687-49bb-4c65-83a3-a483a8c4b708", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b123c08c-124a-44ac-bc44-fc72a7768434", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "result[0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "078e5821-d264-48b4-a1d1-7bfbc1c05490", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Pennylane/Pennylane_List_customer_invoices.ipynb b/Pennylane/Pennylane_List_customer_invoices.ipynb new file mode 100644 index 0000000000..f4e44a3cb0 --- /dev/null +++ b/Pennylane/Pennylane_List_customer_invoices.ipynb @@ -0,0 +1,229 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1ec65662-8eb6-4a98-a16e-ffc3729252b6", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Pennylane.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "hairy-interstate", + "metadata": {}, + "source": [ + "# Pennylane - List customer invoices" + ] + }, + { + "cell_type": "markdown", + "id": "db03090b-015f-4b1b-8c7c-ba11f37d60b5", + "metadata": {}, + "source": [ + "**Tags:** #pennylane #list #customers #invoices #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "c54c97eb-8d4d-417c-a402-7adf5327d7fb", + "metadata": {}, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "ed962863-54e5-48e4-aa48-877adeba86fc", + "metadata": {}, + "source": [ + "**Description:** This endpoint returns the list of customer invoices corresponding to the filter provided." + ] + }, + { + "cell_type": "markdown", + "id": "fdcf05b5-17d7-4c11-88ec-f722cf264a7f", + "metadata": {}, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "75da13af-72c2-44b9-8c06-ed3bfa4700ac", + "metadata": { + "execution": { + "iopub.execute_input": "2022-08-31T10:54:23.866665Z", + "iopub.status.busy": "2022-08-31T10:54:23.866431Z", + "iopub.status.idle": "2022-08-31T10:54:23.871270Z", + "shell.execute_reply": "2022-08-31T10:54:23.870705Z", + "shell.execute_reply.started": "2022-08-31T10:54:23.866641Z" + }, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b5605c12-6814-4d98-99b0-aaaa4526014f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import pandas as pd\n", + "import naas_python #to use this lib create your account on naas.ai" + ] + }, + { + "cell_type": "markdown", + "id": "1b6ad1a8-308e-4778-963c-fc21d492a1a9", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "06d385f7-6b96-4e95-8721-b02ef7c52c83", + "metadata": { + "tags": [ + "parameters" + ] + }, + "outputs": [], + "source": [ + "api_token = naas_python.secret.get(\"PENNYLANE_API_TOKEN\").value or \"YOUR_PENNYLANE_API_TOKEN\" # if you don't have a naas.ai account, add api_token as string" + ] + }, + { + "cell_type": "markdown", + "id": "e2b06c06-c20d-4d1a-a228-dca532603925", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "14cd5a2a-8e0a-45f6-a31c-f487950db30d", + "metadata": {}, + "source": [ + "### List customer invoices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4a62312c-53f7-4285-b1fd-5dde2592022c", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def list_customer_invoices(\n", + " api_token,\n", + " per_page=50,\n", + " sort=None,\n", + " filter=None,\n", + "):\n", + " url = \"https://app.pennylane.com/api/external/v1/customer_invoices\"\n", + " headers = {\n", + " \"Accept\": \"application/json\",\n", + " \"Authorization\": f\"Bearer {api_token}\"\n", + " }\n", + " data = []\n", + " page = 1\n", + " while True:\n", + " # Get data\n", + " res_json = []\n", + " params = {\n", + " \"page\": page,\n", + " \"per_page\": per_page,\n", + " }\n", + " res = requests.get(url, headers=headers, params=params)\n", + " res.raise_for_status()\n", + " if res.status_code == 200:\n", + " result = res.json().get(\"invoices\")\n", + "\n", + " # Concat result\n", + " if len(result) > 0:\n", + " data += result\n", + " page += 1\n", + " else:\n", + " break\n", + " return data\n", + "\n", + "result = list_customer_invoices(api_token)\n", + "print(\"Invoices:\", len(result))" + ] + }, + { + "cell_type": "markdown", + "id": "21da518a-e9a5-4655-87a2-52e005f31dbe", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "08861687-49bb-4c65-83a3-a483a8c4b708", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "64f90e2b-9159-4362-be14-e4bf3ed22b94", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "result[0]" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Pennylane/test.txt b/Pennylane/test.txt new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Pennylane/test.txt @@ -0,0 +1 @@ +