Skip to content

Commit

Permalink
feat: pipedrive templates
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentLvr committed Jan 2, 2024
1 parent 7050fc1 commit 37022f9
Show file tree
Hide file tree
Showing 14 changed files with 3,150 additions and 323 deletions.
278 changes: 278 additions & 0 deletions Pipedrive/Pipedrive_Add_a_deal.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "71c0bc07-d10e-4777-9d07-f8069593b9dc",
"metadata": {
"papermill": {},
"tags": [
"naas"
]
},
"source": [
"<img width=\"8%\" alt=\"Pipedrive.png\" src=\"https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/Pipedrive.png\" style=\"border-radius: 15%\">"
]
},
{
"cell_type": "markdown",
"id": "c2297c6c-1c56-44f5-ab1b-4f358315ae4d",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"# Pipedrive - Add a deal"
]
},
{
"cell_type": "markdown",
"id": "1528c23e-d4b5-4dae-aedd-3e0c3de7a07e",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Tags:** #pipedrive #deal #add #snippet #api #v1 #python"
]
},
{
"cell_type": "markdown",
"id": "0f5b4999-cf8f-429b-a3b5-60abd6f0b4cb",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)"
]
},
{
"cell_type": "markdown",
"id": "b50cf866-b0f5-45c1-9ea2-4c63d5622675",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Last update:** 2023-12-28 (Created: 2023-12-28)"
]
},
{
"cell_type": "markdown",
"id": "da21ae20-d8f3-41ae-b6e4-1d16e8bca2d0",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Description:** This notebook adds a new deal. Note that you can supply additional custom fields along with the request that are not described here. These custom fields are different for each Pipedrive account and can be recognized by long hashes as keys. To determine which custom fields exists, fetch the dealFields and look for key values. For more information, see the tutorial for adding a deal."
]
},
{
"cell_type": "markdown",
"id": "6a0004b2-eb12-4dc2-b721-6b482cab7439",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**References:**\n",
"- [Pipedrive API v1 Documentation](https://developers.pipedrive.com/docs/api/v1/Deals#addDeal)\n",
"- [Pipedrive API Authentication](https://developers.pipedrive.com/docs/api/authentication)\n",
"- [Get your Pipedrive API token](https://developers.pipedrive.com/docs/api/authentication)."
]
},
{
"cell_type": "markdown",
"id": "906e7461-ec7c-4efe-952b-79a2fcdf2b94",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Input"
]
},
{
"cell_type": "markdown",
"id": "699c6ed8-1d1c-4712-b64c-34ed8b385130",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "771e3ddd-f295-4b44-a7d5-0873ee5be72a",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"import requests\n",
"import naas"
]
},
{
"cell_type": "markdown",
"id": "0ab0d130-cbec-438c-a188-8a0cb295da4e",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Setup variables\n",
"- `api_token`: API token used to authenticate the request.\n",
"- `name`: Name of the deal to add."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d6ffb591-6b88-43f6-95b7-a93de4040366",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"api_token = naas.secret.get(\"PIPEDRIVE_API_KEY\") or \"YOUR_API_TOKEN\"\n",
"data = {\n",
" \"title\": \"Test\",\n",
" \"value\": 0,\n",
" \"user_id\": 13470003,\n",
" \"person_id\": 100838,\n",
" \"org_id\": 3363,\n",
" \"pipeline_id\": 14,\n",
" \"stage_id\": 95,\n",
" \"status\": \"open\",\n",
" \"probability\": 10,\n",
"}"
]
},
{
"cell_type": "markdown",
"id": "61a6835b-4526-4d1e-9e21-e2c9325f0206",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Model"
]
},
{
"cell_type": "markdown",
"id": "ca89baa8-b76c-4f9e-8d60-74fdfacf141d",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Add a deal"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e6814d5-bfeb-413a-a4e9-7d9c70c4d95b",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"def add_deal(api_token, data):\n",
" url = f\"https://api.pipedrive.com/v1/deals?api_token={api_token}\"\n",
" \n",
" res = requests.post(url, json=data)\n",
" res.raise_for_status()\n",
" if res.status_code == 201:\n",
" return res.json()\n",
" \n",
"result = add_deal(api_token, data)\n",
"print(\"Deal ID:\", result.get('data').get(\"id\"))\n",
"print(\"Deal name:\", result.get('data').get(\"title\"))"
]
},
{
"cell_type": "markdown",
"id": "7c89f6ac-4231-46ea-81ba-3aa90bc46f3c",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Output"
]
},
{
"cell_type": "markdown",
"id": "c717952a-a404-43b8-91e7-abdacfdb6d65",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Display result"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10d83ed6-c8c7-4ba6-99c3-d55b04ad33c7",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"result"
]
},
{
"cell_type": "markdown",
"id": "5e625e87-9a42-44a4-a872-9ab557638886",
"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
}
Loading

0 comments on commit 37022f9

Please sign in to comment.