From 52b4df28b38d3f7c455af0d03bb294c553586993 Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Sat, 26 Aug 2023 17:43:57 +0200 Subject: [PATCH 1/4] feat(HubSpot): Add Create company --- HubSpot/HubSpot_Create_company.ipynb | 252 +++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 HubSpot/HubSpot_Create_company.ipynb diff --git a/HubSpot/HubSpot_Create_company.ipynb b/HubSpot/HubSpot_Create_company.ipynb new file mode 100644 index 0000000000..19e16dfc74 --- /dev/null +++ b/HubSpot/HubSpot_Create_company.ipynb @@ -0,0 +1,252 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "b772e713-6a71-48e5-8b7c-a9280660420e", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas\"" + ] + }, + { + "cell_type": "markdown", + "id": "3fd8a8ca-257a-4cc3-9e03-253c5aecc714", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# HubSpot - Create company" + ] + }, + { + "cell_type": "markdown", + "id": "c64b5065-c0f4-4dc4-a121-74d2096b9820", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #hubspot #company #create #crm #business #management" + ] + }, + { + "cell_type": "markdown", + "id": "60064cb2-52d5-4e3e-903c-ecd67802f7ab", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel)" + ] + }, + { + "cell_type": "markdown", + "id": "b49aabbb-fda5-4ec3-9803-35750bbc072c", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2023-08-26 (Created: 2023-08-26)" + ] + }, + { + "cell_type": "markdown", + "id": "cd8fa6b1-932e-4aaa-9b86-d23c88f7d3d8", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Description:** This notebook will show how to create a company in HubSpot and how it is useful for organizations." + ] + }, + { + "cell_type": "markdown", + "id": "4d15d2e0-2150-48d9-a3fa-191fa1281045", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n- [HubSpot API Documentation](https://developers.hubspot.com/docs/overview)\n- [HubSpot API Reference](https://developers.hubspot.com/docs/reference)" + ] + }, + { + "cell_type": "markdown", + "id": "841c9cb1-770e-401a-85c7-650629ad4bba", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "30622949-e9f6-4a56-939f-f4081b2c1df0", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "497d7edf-1a3d-4f70-8bb0-0c841274820e", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "import requests\nimport json", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "524ce4db-0aee-43bf-bf72-d5125edd5a08", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n- **api_key**: API key to access HubSpot API. [How to get an API key](https://knowledge.hubspot.com/articles/kcs_article/integrations/how-do-i-get-my-hubspot-api-key)\n- **company_name**: Name of the company to be created" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8735a84c-91eb-4c60-b427-53ad34fa3b02", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "api_key = \"\"\ncompany_name = \"My Company\"", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "2dad33a7-3026-4e4e-a297-cfd51a40e90d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "29afce7c-7211-4179-b35d-7485f03506bf", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Create company" + ] + }, + { + "cell_type": "markdown", + "id": "ec344680-b35b-4e4d-8f9a-d7668f94c5fb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "This function will create a company in HubSpot using the API." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "73929d4f-42ee-43c4-a3b8-f51a3e2ca108", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "def create_company(api_key, company_name):\n url = \"https://api.hubapi.com/companies/v2/companies\"\n headers = {\"Content-Type\": \"application/json\", \"Authorization\": \"Bearer \" + api_key}\n data = {\"properties\": [{\"name\": \"name\", \"value\": company_name}]}\n response = requests.post(url, headers=headers, data=json.dumps(data))\n return response.json()", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "e7234f74-eaf9-41c9-af6e-9306d9e1566d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "c9944cfe-45d0-4207-a8ea-dfc61f63d4bb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6bc1eace-ab86-4bd5-8eee-7cbaadaf3d52", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "create_company(api_key, company_name)", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "7fb84e3c-64d2-4198-93b9-22e0805ba311", + "metadata": { + "papermill": {}, + "tags": [] + }, + "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" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file From ff62be6ef22874ab1620b9eaf315d7c4d72a9646 Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Mon, 25 Sep 2023 10:35:23 +0200 Subject: [PATCH 2/4] feat: push new templates --- HubSpot/HubSpot_Create_company.ipynb | 53 ++++-- HubSpot/HubSpot_Delete_company.ipynb | 267 +++++++++++++++++++++++++++ HubSpot/HubSpot_Update_company.ipynb | 261 ++++++++++++++++++++++++++ 3 files changed, 568 insertions(+), 13 deletions(-) create mode 100644 HubSpot/HubSpot_Delete_company.ipynb create mode 100644 HubSpot/HubSpot_Update_company.ipynb diff --git a/HubSpot/HubSpot_Create_company.ipynb b/HubSpot/HubSpot_Create_company.ipynb index 19e16dfc74..c49b185d92 100644 --- a/HubSpot/HubSpot_Create_company.ipynb +++ b/HubSpot/HubSpot_Create_company.ipynb @@ -52,7 +52,7 @@ "tags": [] }, "source": [ - "**Last update:** 2023-08-26 (Created: 2023-08-26)" + "**Last update:** 2023-09-25 (Created: 2023-09-25)" ] }, { @@ -74,7 +74,8 @@ "tags": [] }, "source": [ - "**References:**\n- [HubSpot API Documentation](https://developers.hubspot.com/docs/overview)\n- [HubSpot API Reference](https://developers.hubspot.com/docs/reference)" + "**References:**\n", + "- [HubSpot CRM API - Companies](https://developers.hubspot.com/docs/api/crm/companies)" ] }, { @@ -107,8 +108,11 @@ "papermill": {}, "tags": [] }, - "source": "import requests\nimport json", - "outputs": [] + "outputs": [], + "source": [ + "from naas_drivers import hubspot\n", + "import naas" + ] }, { "cell_type": "markdown", @@ -118,7 +122,14 @@ "tags": [] }, "source": [ - "### Setup variables\n- **api_key**: API key to access HubSpot API. [How to get an API key](https://knowledge.hubspot.com/articles/kcs_article/integrations/how-do-i-get-my-hubspot-api-key)\n- **company_name**: Name of the company to be created" + "### Setup variables\n", + "**Mandatory**\n", + "\n", + "[Get your HubSpot Access token](https://knowledge.hubspot.com/articles/kcs_article/integrations/how-do-i-get-my-hubspot-api-key)\n", + "- `hs_access_token`: This variable stores an access token used for accessing the HubSpot API.\n", + "\n", + "**Optional**\n", + "- `properties`: This variable holds a dictionary that contains key-value pairs for creating a new company in HubSpot. You have the flexibility to include any custom properties, using their respective internal HubSpot names. To list company properties, you can use this template: \"HubSpot_List_company_properties.ipynb\" stored in https://github.com/jupyter-naas/awesome-notebooks." ] }, { @@ -129,8 +140,19 @@ "papermill": {}, "tags": [] }, - "source": "api_key = \"\"\ncompany_name = \"My Company\"", - "outputs": [] + "outputs": [], + "source": [ + "hs_access_token = naas.secret.get(\"HS_ACCESS_TOKEN\") or \"YOUR_HS_ACCESS_TOKEN\"\n", + "properties = {\n", + " \"name\": \"HubSpot\", \n", + " \"domain\": \"hubspot.com\",\n", + " \"city\": \"Cambridge\",\n", + " \"industry\": \"Technology\",\n", + " \"phone\": \"555-555-555\",\n", + " \"state\": \"Massachusetts\",\n", + " \"lifecyclestage\": \"51439524\"\n", + "}" + ] }, { "cell_type": "markdown", @@ -162,7 +184,7 @@ "tags": [] }, "source": [ - "This function will create a company in HubSpot using the API." + "This method will allow you to add any compnay properties available in your HubSpot." ] }, { @@ -173,8 +195,11 @@ "papermill": {}, "tags": [] }, - "source": "def create_company(api_key, company_name):\n url = \"https://api.hubapi.com/companies/v2/companies\"\n headers = {\"Content-Type\": \"application/json\", \"Authorization\": \"Bearer \" + api_key}\n data = {\"properties\": [{\"name\": \"name\", \"value\": company_name}]}\n response = requests.post(url, headers=headers, data=json.dumps(data))\n return response.json()", - "outputs": [] + "outputs": [], + "source": [ + "hs_properties = {\"properties\": properties}\n", + "obj = hubspot.connect(hs_access_token).companies.send(hs_properties)" + ] }, { "cell_type": "markdown", @@ -206,8 +231,10 @@ "papermill": {}, "tags": [] }, - "source": "create_company(api_key, company_name)", - "outputs": [] + "outputs": [], + "source": [ + "obj" + ] }, { "cell_type": "markdown", @@ -249,4 +276,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/HubSpot/HubSpot_Delete_company.ipynb b/HubSpot/HubSpot_Delete_company.ipynb new file mode 100644 index 0000000000..a4f65dc907 --- /dev/null +++ b/HubSpot/HubSpot_Delete_company.ipynb @@ -0,0 +1,267 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "expressed-daisy", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas\"" + ] + }, + { + "cell_type": "markdown", + "id": "prospective-parker", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# HubSpot - Delete a company\n", + "

Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "accessory-burke", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #hubspot #crm #sales #company #naas_drivers #snippet #delete" + ] + }, + { + "cell_type": "markdown", + "id": "6caf958a-6ed9-4ae5-8555-c17676566d8d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "4ecd37b0-d515-4c84-b3ab-c1ab4c5149d4", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2023-09-25 (Created: 2023-09-25)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook demonstrates how to delete a given company in HubSpot using its HubSpot ID." + ] + }, + { + "cell_type": "markdown", + "id": "42dbddd2-fd20-45b4-a0e6-7fa6e78d367b", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n", + "- [HubSpot CRM API - Companies](https://developers.hubspot.com/docs/api/crm/companies)" + ] + }, + { + "cell_type": "markdown", + "id": "625a155e-110f-41c9-9ecd-dd5d5e78556d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "ebea7cbc-254b-4d88-bed0-8051d4a58856", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "f34eed5c-38ec-4589-91f6-1e091507d9b9", + "metadata": { + "execution": { + "iopub.execute_input": "2023-09-25T08:27:43.441763Z", + "iopub.status.busy": "2023-09-25T08:27:43.441376Z", + "iopub.status.idle": "2023-09-25T08:27:57.633315Z", + "shell.execute_reply": "2023-09-25T08:27:57.632549Z", + "shell.execute_reply.started": "2023-09-25T08:27:43.441667Z" + }, + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "from naas_drivers import hubspot\n", + "import naas" + ] + }, + { + "cell_type": "markdown", + "id": "4408903b-084e-4a84-8945-9fa9b56b5b06", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "**Mandatory**\n", + "\n", + "[Get your HubSpot Access token](https://knowledge.hubspot.com/articles/kcs_article/integrations/how-do-i-get-my-hubspot-api-key)\n", + "- `hs_access_token`: This variable stores an access token used for accessing the HubSpot API.\n", + "- `hubspot_id`: This variable stores the HubSpot company ID" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6ab9199f-b054-459b-8bf0-bb23e941de67", + "metadata": { + "execution": { + "iopub.execute_input": "2023-09-25T08:27:57.637625Z", + "iopub.status.busy": "2023-09-25T08:27:57.637363Z", + "iopub.status.idle": "2023-09-25T08:28:01.747070Z", + "shell.execute_reply": "2023-09-25T08:28:01.746476Z", + "shell.execute_reply.started": "2023-09-25T08:27:57.637594Z" + }, + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "# Mandatory\n", + "hs_access_token = naas.secret.get(\"HS_ACCESS_TOKEN\") or \"YOUR_HS_ACCESS_TOKEN\"\n", + "hubspot_id = \"715201\"" + ] + }, + { + "cell_type": "markdown", + "id": "3899ae6e-1e2b-4309-b87d-b9969feddef1", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "1e734f5f-8b99-40a7-81d9-4d3a653d4e25", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Delete a company" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "355d61fe-19cf-496a-9453-3ca41bcf1bc7", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "obj = hubspot.connect(hs_access_token).companies.delete(hubspot_id)" + ] + }, + { + "cell_type": "markdown", + "id": "a5f649e9-2cff-4706-8fec-fdd9b7b8f882", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "f0a8524d-8580-407b-93f8-a5613dff4cf5", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "336db21f-0533-47d2-8258-ad460c822e81", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "obj" + ] + } + ], + "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" + }, + "naas": { + "notebook_id": "758eceb0755d55869262781c0fdbf0ae8897488501d0c5a019bb29f299889448", + "notebook_path": "HubSpot/HubSpot_Delete_contact.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/HubSpot/HubSpot_Update_company.ipynb b/HubSpot/HubSpot_Update_company.ipynb new file mode 100644 index 0000000000..0d92f1982a --- /dev/null +++ b/HubSpot/HubSpot_Update_company.ipynb @@ -0,0 +1,261 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "african-pavilion", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas\"" + ] + }, + { + "cell_type": "markdown", + "id": "frequent-pittsburgh", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# HubSpot - Update a company using custom properties\n", + "

Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "genuine-poland", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #hubspot #crm #sales #company #naas_drivers #snippet #update #patch" + ] + }, + { + "cell_type": "markdown", + "id": "1ca9ae0b-0121-49dd-ab85-246f17d69448", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "19d62035-3dc4-435d-b968-b773157ca7aa", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2023-09-25 (Created: 2023-09-25)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook demonstrates how to update a given company in HubSpot using HubSpot default or custom properties." + ] + }, + { + "cell_type": "markdown", + "id": "0674efd4-cc2f-4795-aa85-f2f0461a5ed1", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n", + "- [HubSpot CRM API - Companies](https://developers.hubspot.com/docs/api/crm/companies)" + ] + }, + { + "cell_type": "markdown", + "id": "decreased-discovery", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "outer-mechanism", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "obvious-surgery", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "from naas_drivers import hubspot\n", + "import naas" + ] + }, + { + "cell_type": "markdown", + "id": "bcf071a5-f2a8-4952-803b-d1abce07ca7d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "[Get your HubSpot Access token](https://knowledge.hubspot.com/articles/kcs_article/integrations/how-do-i-get-my-hubspot-api-key)\n", + "- `hs_access_token`: This variable stores an access token used for accessing the HubSpot API.\n", + "- `hubspot_id`: This variable stores the HubSpot company ID\n", + "- `properties`: This variable holds a dictionary that contains key-value pairs to update a company in HubSpot. You have the flexibility to include any custom properties, using their respective internal HubSpot names. To list company properties, you can use this template: \"HubSpot_List_company_properties.ipynb\" stored in https://github.com/jupyter-naas/awesome-notebooks." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5a2f148d-7443-4ba0-9c3d-261a67003423", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "hs_access_token = naas.secret.get(\"HS_ACCESS_TOKEN\") or \"YOUR_HS_ACCESS_TOKEN\"\n", + "hubspot_id = \"715201\"\n", + "properties = {\n", + " \"name\": \"HubSpot\", \n", + " \"domain\": \"hubspot.com\",\n", + " \"city\": \"Cambridge\",\n", + " \"industry\": \"Technology\",\n", + " \"phone\": \"555-555-555\",\n", + " \"state\": \"Massachusetts\",\n", + " \"lifecyclestage\": \"51439524\"\n", + "} " + ] + }, + { + "cell_type": "markdown", + "id": "minor-white", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "fiscal-directive", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Update company" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "phantom-people", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "hs_properties = {\"properties\": properties}\n", + "obj = hubspot.connect(hs_access_token).companies.patch(hs_properties)" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-target", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "4d39601c-e21c-4a3f-a0a4-f60b9354d490", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "38410b82-6f46-48d4-8cd1-533f5a83f7fc", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "obj" + ] + } + ], + "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" + }, + "naas": { + "notebook_id": "1a66fd4eb09d5f34d95b8451ca85989c9743a9060a6540d11d2c19a559a516bb", + "notebook_path": "HubSpot/HubSpot_Update_contact_using_custom_properties.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 6fe030a5d330b5671e6e99b0afbe321efbbc14d7 Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Mon, 25 Sep 2023 14:34:17 +0200 Subject: [PATCH 3/4] feat: create, retrive, update, delete a company from hubspot templates --- HubSpot/HubSpot_Get_company.ipynb | 265 ++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 HubSpot/HubSpot_Get_company.ipynb diff --git a/HubSpot/HubSpot_Get_company.ipynb b/HubSpot/HubSpot_Get_company.ipynb new file mode 100644 index 0000000000..c083dc2284 --- /dev/null +++ b/HubSpot/HubSpot_Get_company.ipynb @@ -0,0 +1,265 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "african-pavilion", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas\"" + ] + }, + { + "cell_type": "markdown", + "id": "frequent-pittsburgh", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# HubSpot - Get a company\n", + "

Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "genuine-poland", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #hubspot #crm #sales #company #naas_drivers #snippet #get" + ] + }, + { + "cell_type": "markdown", + "id": "1ca9ae0b-0121-49dd-ab85-246f17d69448", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "19d62035-3dc4-435d-b968-b773157ca7aa", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2023-09-25 (Created: 2023-09-25)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook demonstrates how to get a given company in using its hubspot ID." + ] + }, + { + "cell_type": "markdown", + "id": "0674efd4-cc2f-4795-aa85-f2f0461a5ed1", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n", + "- [HubSpot CRM API - Companies](https://developers.hubspot.com/docs/api/crm/companies)" + ] + }, + { + "cell_type": "markdown", + "id": "decreased-discovery", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "outer-mechanism", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "obvious-surgery", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "from naas_drivers import hubspot\n", + "import naas" + ] + }, + { + "cell_type": "markdown", + "id": "bcf071a5-f2a8-4952-803b-d1abce07ca7d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "**Mandatory**\n", + "- `hs_access_token`: This variable stores an access token used for accessing the HubSpot API. [Get your HubSpot Access token](https://knowledge.hubspot.com/articles/kcs_article/integrations/how-do-i-get-my-hubspot-api-key)\n", + "- `hubspot_id`: This variable stores the HubSpot company ID\n", + "\n", + "**Optional**\n", + "- `properties`: List of properties (hubspot internal names) you want to get from a company. By default, you will get: name, domain, createdate, lastmodifieddate, hs_object_id. To list of contact properties, you can use this template: \"HubSpot/HubSpot_List_contact_properties.ipynb\" stored in https://github.com/jupyter-naas/awesome-notebooks" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5a2f148d-7443-4ba0-9c3d-261a67003423", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "# Mandatory\n", + "hs_access_token = naas.secret.get(\"HS_ACCESS_TOKEN\") or \"YOUR_HS_ACCESS_TOKEN\"\n", + "hubspot_id = \"179121906\"\n", + "\n", + "# Optional\n", + "properties = []" + ] + }, + { + "cell_type": "markdown", + "id": "minor-white", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "fiscal-directive", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Get a company" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "phantom-people", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "obj = hubspot.connect(hs_access_token).companies.get(hubspot_id, properties)" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-target", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "4d39601c-e21c-4a3f-a0a4-f60b9354d490", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "38410b82-6f46-48d4-8cd1-533f5a83f7fc", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "obj" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9f31c2d2-ee78-48b2-bc80-b3c10f74da16", + "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" + }, + "naas": { + "notebook_id": "1a66fd4eb09d5f34d95b8451ca85989c9743a9060a6540d11d2c19a559a516bb", + "notebook_path": "HubSpot/HubSpot_Update_contact_using_custom_properties.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 45db0ff6610afbb519fdf6aed60ba68e839c496e Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Mon, 25 Sep 2023 14:35:23 +0200 Subject: [PATCH 4/4] feat: final test ok --- HubSpot/HubSpot_Create_company.ipynb | 2 -- HubSpot/HubSpot_Delete_company.ipynb | 28 +++++++++++----------------- HubSpot/HubSpot_Update_company.ipynb | 20 +++++++++++--------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/HubSpot/HubSpot_Create_company.ipynb b/HubSpot/HubSpot_Create_company.ipynb index c49b185d92..a6d4797293 100644 --- a/HubSpot/HubSpot_Create_company.ipynb +++ b/HubSpot/HubSpot_Create_company.ipynb @@ -147,10 +147,8 @@ " \"name\": \"HubSpot\", \n", " \"domain\": \"hubspot.com\",\n", " \"city\": \"Cambridge\",\n", - " \"industry\": \"Technology\",\n", " \"phone\": \"555-555-555\",\n", " \"state\": \"Massachusetts\",\n", - " \"lifecyclestage\": \"51439524\"\n", "}" ] }, diff --git a/HubSpot/HubSpot_Delete_company.ipynb b/HubSpot/HubSpot_Delete_company.ipynb index a4f65dc907..d2fb8864cf 100644 --- a/HubSpot/HubSpot_Delete_company.ipynb +++ b/HubSpot/HubSpot_Delete_company.ipynb @@ -105,16 +105,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "f34eed5c-38ec-4589-91f6-1e091507d9b9", "metadata": { - "execution": { - "iopub.execute_input": "2023-09-25T08:27:43.441763Z", - "iopub.status.busy": "2023-09-25T08:27:43.441376Z", - "iopub.status.idle": "2023-09-25T08:27:57.633315Z", - "shell.execute_reply": "2023-09-25T08:27:57.632549Z", - "shell.execute_reply.started": "2023-09-25T08:27:43.441667Z" - }, "papermill": {}, "tags": [] }, @@ -142,16 +135,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "6ab9199f-b054-459b-8bf0-bb23e941de67", "metadata": { - "execution": { - "iopub.execute_input": "2023-09-25T08:27:57.637625Z", - "iopub.status.busy": "2023-09-25T08:27:57.637363Z", - "iopub.status.idle": "2023-09-25T08:28:01.747070Z", - "shell.execute_reply": "2023-09-25T08:28:01.746476Z", - "shell.execute_reply.started": "2023-09-25T08:27:57.637594Z" - }, "papermill": {}, "tags": [] }, @@ -159,7 +145,7 @@ "source": [ "# Mandatory\n", "hs_access_token = naas.secret.get(\"HS_ACCESS_TOKEN\") or \"YOUR_HS_ACCESS_TOKEN\"\n", - "hubspot_id = \"715201\"" + "hubspot_id = \"17450148694\"" ] }, { @@ -231,6 +217,14 @@ "source": [ "obj" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "38adb765-f897-45d8-a937-52555f116183", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/HubSpot/HubSpot_Update_company.ipynb b/HubSpot/HubSpot_Update_company.ipynb index 0d92f1982a..835fa45a38 100644 --- a/HubSpot/HubSpot_Update_company.ipynb +++ b/HubSpot/HubSpot_Update_company.ipynb @@ -143,15 +143,9 @@ "outputs": [], "source": [ "hs_access_token = naas.secret.get(\"HS_ACCESS_TOKEN\") or \"YOUR_HS_ACCESS_TOKEN\"\n", - "hubspot_id = \"715201\"\n", + "hubspot_id = \"17450148694\"\n", "properties = {\n", - " \"name\": \"HubSpot\", \n", - " \"domain\": \"hubspot.com\",\n", - " \"city\": \"Cambridge\",\n", - " \"industry\": \"Technology\",\n", - " \"phone\": \"555-555-555\",\n", - " \"state\": \"Massachusetts\",\n", - " \"lifecyclestage\": \"51439524\"\n", + " \"name\": \"HubSpot (test)\",\n", "} " ] }, @@ -188,7 +182,7 @@ "outputs": [], "source": [ "hs_properties = {\"properties\": properties}\n", - "obj = hubspot.connect(hs_access_token).companies.patch(hs_properties)" + "obj = hubspot.connect(hs_access_token).companies.patch(hubspot_id, hs_properties)" ] }, { @@ -225,6 +219,14 @@ "source": [ "obj" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9f31c2d2-ee78-48b2-bc80-b3c10f74da16", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {