From 60d7a2aa7b1369a6b1c43fa147737e159bf15cd4 Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Mon, 23 Dec 2019 15:24:21 -0500 Subject: [PATCH 01/38] Adds add_product_to_deal method --- pipedrive/deals.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pipedrive/deals.py b/pipedrive/deals.py index f966d17..badbdfa 100644 --- a/pipedrive/deals.py +++ b/pipedrive/deals.py @@ -83,3 +83,7 @@ def get_deal_products(self, deal_id, **kwargs): def get_deal_fields(self, **kwargs): url = 'dealFields' return self._client._get(self._client.BASE_URL + url, **kwargs) + + def add_product_to_deal(self, deal_id, data, **kwargs): + url = 'deals/{}/products'.format(deal_id) + return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) From eb4894cba875f36b38f322f52e9e090b1ca369b1 Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Mon, 23 Dec 2019 15:27:20 -0500 Subject: [PATCH 02/38] Bump ver 1.1.2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c11ddb0..a0e384d 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def read(fname): setup(name='pipedrive-python-lib', - version='1.1.1', + version='1.1.2', description='API wrapper for Pipedrive written in Python', long_description=read('README.md'), long_description_content_type="text/markdown", From 08839fe66a8969762fba7094a8f6cb0762c4a6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0uste?= Date: Mon, 2 Mar 2020 12:45:12 +0100 Subject: [PATCH 03/38] Add stages api endpoints --- pipedrive/client.py | 2 ++ pipedrive/stages.py | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 pipedrive/stages.py diff --git a/pipedrive/client.py b/pipedrive/client.py index a219105..8b6c7c1 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -12,6 +12,7 @@ from pipedrive.pipelines import Pipelines from pipedrive.products import Products from pipedrive.recents import Recents +from pipedrive.stages import Stages from pipedrive.users import Users from pipedrive.webhooks import Webhooks @@ -34,6 +35,7 @@ def __init__(self, client_id=None, client_secret=None, domain=None): self.pipelines = Pipelines(self) self.products = Products(self) self.recents = Recents(self) + self.stages = Stages(self) self.users = Users(self) self.webhooks = Webhooks(self) diff --git a/pipedrive/stages.py b/pipedrive/stages.py new file mode 100644 index 0000000..536ce89 --- /dev/null +++ b/pipedrive/stages.py @@ -0,0 +1,27 @@ +class Stages(object): + def __init__(self, client): + self._client = client + + def get_stage(self, stage_id, **kwargs): + url = 'stages/{}'.format(stage_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) + + def get_all_stages(self, **kwargs): + url = 'stages' + return self._client._get(self._client.BASE_URL + url, **kwargs) + + def get_stage_deals(self, stage_id, **kwargs): + url = 'stages/{}/deals'.format(stage_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) + + def create_stage(self, data, **kwargs): + url = 'stages' + return self._client._post(self._client.BASE_URL + url, data, **kwargs) + + def update_stage(self, stage_id, data, **kwargs): + url = 'stages/{}'.format(stage_id) + return self._client._put(self._client.BASE_URL + url, data, **kwargs) + + def delete_stage(self, stage_id, **kwargs): + url = 'stages/{}'.format(stage_id) + return self._client._delete(self._client.BASE_URL + url, **kwargs) From 4ff814b5e06ca6f21476e58b431d013506c7e990 Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Tue, 10 Mar 2020 14:21:42 -0500 Subject: [PATCH 04/38] Bump ver. 1.1.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a0e384d..ac7b8bd 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def read(fname): setup(name='pipedrive-python-lib', - version='1.1.2', + version='1.1.3', description='API wrapper for Pipedrive written in Python', long_description=read('README.md'), long_description_content_type="text/markdown", From c5ef99d3342a85ede9f939db4858ce6ad50d880f Mon Sep 17 00:00:00 2001 From: PlayDay Date: Fri, 13 Mar 2020 00:37:23 +0200 Subject: [PATCH 05/38] Add Organizations.find_organization_by_name --- pipedrive/organizations.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pipedrive/organizations.py b/pipedrive/organizations.py index 35970d6..bc17da6 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -25,3 +25,7 @@ def delete_organization(self, organization_id, **kwargs): def get_organization_fields(self, **kwargs): url = 'organizationFields' return self._client._get(self._client.BASE_URL + url, **kwargs) + + def find_organization_by_name(self, **kwargs): + url = 'organizations/find' + return self._client._get(self._client.BASE_URL + url, **kwargs) From ce6e80512c70c24d0a5ca815b785749ade440f4a Mon Sep 17 00:00:00 2001 From: Rob Deeb Date: Mon, 23 Mar 2020 18:35:35 -0700 Subject: [PATCH 06/38] Adds params to GET calls and adds to relevant wrapper methods --- pipedrive/activities.py | 8 ++++---- pipedrive/client.py | 4 ++-- pipedrive/deals.py | 16 ++++++++-------- pipedrive/filters.py | 4 ++-- pipedrive/notes.py | 8 ++++---- pipedrive/organizations.py | 8 ++++---- pipedrive/persons.py | 12 ++++++------ pipedrive/recents.py | 4 ++-- pipedrive/stages.py | 4 ++-- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/pipedrive/activities.py b/pipedrive/activities.py index c09c832..b630b5e 100644 --- a/pipedrive/activities.py +++ b/pipedrive/activities.py @@ -6,9 +6,9 @@ def get_activity(self, activity_id, **kwargs): url = 'activities/{}'.format(activity_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_all_activities(self, **kwargs): + def get_all_activities(self, params=None, **kwargs): url = 'activities' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_activity(self, data, **kwargs): url = 'activities' @@ -22,6 +22,6 @@ def delete_activity(self, activity_id, **kwargs): url = 'activities/{}'.format(activity_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) - def get_activity_fields(self, **kwargs): + def get_activity_fields(self, params=None, **kwargs): url = 'activityFields' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/client.py b/pipedrive/client.py index 8b6c7c1..dfdf2d4 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -76,8 +76,8 @@ def set_access_token(self, access_token): def set_api_token(self, api_token): self.api_token = api_token - def _get(self, url, **kwargs): - return self._request('get', url, **kwargs) + def _get(self, url, params=None, **kwargs): + return self._request('get', url, params=params, **kwargs) def _post(self, url, **kwargs): return self._request('post', url, **kwargs) diff --git a/pipedrive/deals.py b/pipedrive/deals.py index badbdfa..2f4b3f7 100644 --- a/pipedrive/deals.py +++ b/pipedrive/deals.py @@ -6,13 +6,13 @@ def get_deal(self, deal_id, **kwargs): url = 'deals/{}'.format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_all_deals(self, **kwargs): + def get_all_deals(self, params=None, **kwargs): url = 'deals' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def get_all_deals_with_filter(self, filter_id, **kwargs): + def get_all_deals_with_filter(self, filter_id, params=None, **kwargs): url = 'deals?filter_id={}'.format(filter_id) - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_deal(self, data, **kwargs): url = 'deals' @@ -34,9 +34,9 @@ def get_deal_details(self, deal_id, **kwargs): url = 'deals/{}'.format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_deals_by_name(self, **kwargs): + def get_deals_by_name(self, params=None, **kwargs): url = 'deals/find' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def get_deal_followers(self, deal_id, **kwargs): url = 'deals/{}/followers'.format(deal_id) @@ -80,9 +80,9 @@ def get_deal_products(self, deal_id, **kwargs): url = 'deals/{}/products'.format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_deal_fields(self, **kwargs): + def get_deal_fields(self, params=None, **kwargs): url = 'dealFields' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def add_product_to_deal(self, deal_id, data, **kwargs): url = 'deals/{}/products'.format(deal_id) diff --git a/pipedrive/filters.py b/pipedrive/filters.py index d7dcb11..a481db8 100644 --- a/pipedrive/filters.py +++ b/pipedrive/filters.py @@ -6,9 +6,9 @@ def get_filter(self, filter_id, **kwargs): url = 'filters/{}'.format(filter_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_all_filters(self, **kwargs): + def get_all_filters(self, params=None, **kwargs): url = 'filters' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_filter(self, data, **kwargs): url = 'filters' diff --git a/pipedrive/notes.py b/pipedrive/notes.py index 159ac98..714ed83 100644 --- a/pipedrive/notes.py +++ b/pipedrive/notes.py @@ -6,9 +6,9 @@ def get_note(self, note_id, **kwargs): url = 'notes/{}'.format(note_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_all_notes(self, **kwargs): + def get_all_notes(self, params=None, **kwargs): url = 'notes' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_note(self, data, **kwargs): url = 'notes' @@ -22,6 +22,6 @@ def delete_note(self, note_id, **kwargs): url = 'notes/{}'.format(note_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) - def get_note_fields(self, **kwargs): + def get_note_fields(self, params=None, **kwargs): url = 'noteFields' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/organizations.py b/pipedrive/organizations.py index 35970d6..9c4d201 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -6,9 +6,9 @@ def get_organization(self, organization_id, **kwargs): url = 'organizations/{}'.format(organization_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_all_organizations(self, **kwargs): + def get_all_organizations(self, params=None, **kwargs): url = 'organizations' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_organization(self, data, **kwargs): url = 'organizations' @@ -22,6 +22,6 @@ def delete_organization(self, organization_id, **kwargs): url = 'organizations/{}'.format(organization_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) - def get_organization_fields(self, **kwargs): + def get_organization_fields(self, params=None, **kwargs): url = 'organizationFields' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index b803f32..20f3c43 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -6,13 +6,13 @@ def get_person(self, person_id, **kwargs): url = 'persons/{}'.format(person_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_all_persons(self, **kwargs): + def get_all_persons(self, params=None, **kwargs): url = 'persons' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def get_persons_by_name(self, **kwargs): + def get_persons_by_name(self, params=None, **kwargs): url = 'persons/find' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_person(self, data, **kwargs): url = 'persons' @@ -30,6 +30,6 @@ def get_person_deals(self, person_id, **kwargs): url = 'persons/{}/deals'.format(person_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_person_fields(self, **kwargs): + def get_person_fields(self, params=None, **kwargs): url = 'personFields' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/recents.py b/pipedrive/recents.py index 5135e80..9b9e761 100644 --- a/pipedrive/recents.py +++ b/pipedrive/recents.py @@ -2,6 +2,6 @@ class Recents(object): def __init__(self, client): self._client = client - def get_recent_changes(self, **kwargs): + def get_recent_changes(self, params=None, **kwargs): url = 'recents' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/stages.py b/pipedrive/stages.py index 536ce89..56e3573 100644 --- a/pipedrive/stages.py +++ b/pipedrive/stages.py @@ -6,9 +6,9 @@ def get_stage(self, stage_id, **kwargs): url = 'stages/{}'.format(stage_id) return self._client._get(self._client.BASE_URL + url, **kwargs) - def get_all_stages(self, **kwargs): + def get_all_stages(self, params=None, **kwargs): url = 'stages' - return self._client._get(self._client.BASE_URL + url, **kwargs) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def get_stage_deals(self, stage_id, **kwargs): url = 'stages/{}/deals'.format(stage_id) From da5171f160605fc45438a2e6b34f9f2a3f0b95c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= Date: Wed, 1 Apr 2020 12:02:40 +0200 Subject: [PATCH 07/38] Add link to pipedrive homepage --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d597ded..490d42e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pipedrive-python -pipedrive-python is an API wrapper for Pipedrive written in Python. +pipedrive-python is an API wrapper for [Pipedrive](https://www.pipedrive.com/) written in Python. ## Installing ``` From 8b9ccbc73d9825f9bf6a08b7abfb3471dcbd33e2 Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Fri, 22 May 2020 14:52:53 -0500 Subject: [PATCH 08/38] Bump ver 1.1.4 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ac7b8bd..0ad6bac 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def read(fname): setup(name='pipedrive-python-lib', - version='1.1.3', + version='1.1.4', description='API wrapper for Pipedrive written in Python', long_description=read('README.md'), long_description_content_type="text/markdown", From 8ed138f371b99e0c0dfeb4a5215b3d6ccc69413e Mon Sep 17 00:00:00 2001 From: Arnaud Rouanet Date: Mon, 8 Mar 2021 14:52:08 +0100 Subject: [PATCH 09/38] Add new /search API endpoints --- pipedrive/deals.py | 4 ++++ pipedrive/organizations.py | 4 ++++ pipedrive/persons.py | 4 ++++ pipedrive/products.py | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/pipedrive/deals.py b/pipedrive/deals.py index 2f4b3f7..ad963d9 100644 --- a/pipedrive/deals.py +++ b/pipedrive/deals.py @@ -34,6 +34,10 @@ def get_deal_details(self, deal_id, **kwargs): url = 'deals/{}'.format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) + def search_deals(self, params=None, **kwargs): + url = 'deals/search' + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + def get_deals_by_name(self, params=None, **kwargs): url = 'deals/find' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/organizations.py b/pipedrive/organizations.py index 8cb2ac2..98a6e42 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -26,6 +26,10 @@ def get_organization_fields(self, params=None, **kwargs): url = 'organizationFields' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + def search_organizations(self, params=None, **kwargs): + url = 'organizations/search' + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + def find_organization_by_name(self, **kwargs): url = 'organizations/find' return self._client._get(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index 20f3c43..a5ab754 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -10,6 +10,10 @@ def get_all_persons(self, params=None, **kwargs): url = 'persons' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + def search_persons(self, params=None, **kwargs): + url = 'persons/search' + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + def get_persons_by_name(self, params=None, **kwargs): url = 'persons/find' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/products.py b/pipedrive/products.py index 49870c5..f19a620 100644 --- a/pipedrive/products.py +++ b/pipedrive/products.py @@ -10,6 +10,10 @@ def get_all_products(self, **kwargs): url = 'products' return self._client._get(self._client.BASE_URL + url, **kwargs) + def search_products(self, params=None, **kwargs): + url = 'products/search' + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + def get_product_by_name(self, **kwargs): url = 'products/find' return self._client._get(self._client.BASE_URL + url, **kwargs) From cc086df6cc9a2534807e66e80e05a9441ea50649 Mon Sep 17 00:00:00 2001 From: Arnaud Rouanet Date: Mon, 8 Mar 2021 15:24:26 +0100 Subject: [PATCH 10/38] Update documentation with new endpoints --- README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 490d42e..faf3aa8 100644 --- a/README.md +++ b/README.md @@ -144,12 +144,12 @@ response = client.deals.duplicate_deal('DEAL_ID') response = client.deals.get_deal_details('DEAL_ID') ``` -#### Find deals by name +#### Search deals ``` params = { 'term': '' } -response = client.deals.get_deals_by_name(params=params) +response = client.deals.search_deals(params=params) ``` #### Get followers of a deal @@ -295,6 +295,14 @@ response = client.organizations.get_organization('ORGANIZATION_ID') response = client.organizations.get_all_organizations() ``` +#### Search organizations +``` +params = { + 'term': '' +} +response = client.products.search_organizations(params=params) +``` + #### Add organization ``` data = { @@ -335,12 +343,12 @@ response = client.persons.get_person('PERSON_ID') response = client.persons.get_all_persons() ``` -#### Get persons by name +#### Search persons ``` params = { 'term': '' } -response = client.persons.get_persons_by_name(params=params) +response = client.persons.search_persons(params=params) ``` #### Create person @@ -407,12 +415,12 @@ response = client.products.get_product('PRODUCT_ID') response = client.products.get_all_products() ``` -#### Get products by name +#### Search products ``` params = { 'term': '' } -response = client.products.get_product_by_name(params=params) +response = client.products.search_products(params=params) ``` #### Create a product From 2396c461f82c74fa87124b7e7109457d0041587b Mon Sep 17 00:00:00 2001 From: Arnaud Rouanet Date: Mon, 8 Mar 2021 15:39:20 +0100 Subject: [PATCH 11/38] Remove deprecated /find endpoints --- pipedrive/deals.py | 4 ---- pipedrive/organizations.py | 4 ---- pipedrive/persons.py | 4 ---- pipedrive/products.py | 4 ---- 4 files changed, 16 deletions(-) diff --git a/pipedrive/deals.py b/pipedrive/deals.py index ad963d9..9c86153 100644 --- a/pipedrive/deals.py +++ b/pipedrive/deals.py @@ -38,10 +38,6 @@ def search_deals(self, params=None, **kwargs): url = 'deals/search' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def get_deals_by_name(self, params=None, **kwargs): - url = 'deals/find' - return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def get_deal_followers(self, deal_id, **kwargs): url = 'deals/{}/followers'.format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/organizations.py b/pipedrive/organizations.py index 98a6e42..04e27b4 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -29,7 +29,3 @@ def get_organization_fields(self, params=None, **kwargs): def search_organizations(self, params=None, **kwargs): url = 'organizations/search' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - - def find_organization_by_name(self, **kwargs): - url = 'organizations/find' - return self._client._get(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index a5ab754..7984791 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -14,10 +14,6 @@ def search_persons(self, params=None, **kwargs): url = 'persons/search' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def get_persons_by_name(self, params=None, **kwargs): - url = 'persons/find' - return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def create_person(self, data, **kwargs): url = 'persons' return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) diff --git a/pipedrive/products.py b/pipedrive/products.py index f19a620..db5808e 100644 --- a/pipedrive/products.py +++ b/pipedrive/products.py @@ -14,10 +14,6 @@ def search_products(self, params=None, **kwargs): url = 'products/search' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def get_product_by_name(self, **kwargs): - url = 'products/find' - return self._client._get(self._client.BASE_URL + url, **kwargs) - def create_product(self, data, **kwargs): url = 'products' return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) From 599e9a511ba5f7982b12f1e9fdf8601758881b44 Mon Sep 17 00:00:00 2001 From: lucasnsdantas Date: Sat, 3 Apr 2021 20:31:12 -0300 Subject: [PATCH 12/38] fix delete_person bug --- pipedrive/persons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index 20f3c43..dd8b589 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -24,7 +24,7 @@ def update_person(self, person_id, data, **kwargs): def delete_person(self, person_id, **kwargs): url = 'persons/{}'.format(person_id) - return self._client._delete(url, **kwargs) + return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_person_deals(self, person_id, **kwargs): url = 'persons/{}/deals'.format(person_id) From 9518b8d6a87967dbbd723f82ba6d1ae44eedb100 Mon Sep 17 00:00:00 2001 From: Danie Krige Date: Sun, 25 Jul 2021 15:08:18 +0200 Subject: [PATCH 13/38] Update persons.py get_persons_by_name deprecated, added search_persons_by_term --- pipedrive/persons.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index 20f3c43..a82fea6 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -10,6 +10,7 @@ def get_all_persons(self, params=None, **kwargs): url = 'persons' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + #Deprecated Enpoint, rather use /persons/search instead def get_persons_by_name(self, params=None, **kwargs): url = 'persons/find' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) @@ -33,3 +34,7 @@ def get_person_deals(self, person_id, **kwargs): def get_person_fields(self, params=None, **kwargs): url = 'personFields' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + + def search_persons_by_term(self, term, **kwargs): + url = 'persons/search' + return self._client._get(self._client.BASE_URL + url, term=term, **kwargs) From 936e9d2d1581f570f5440219c00ffd0446019066 Mon Sep 17 00:00:00 2001 From: Danie Krige Date: Sun, 25 Jul 2021 16:55:45 +0200 Subject: [PATCH 14/38] Update persons.py More params --- pipedrive/persons.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index a82fea6..0d5e972 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -35,6 +35,6 @@ def get_person_fields(self, params=None, **kwargs): url = 'personFields' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def search_persons_by_term(self, term, **kwargs): + def search_persons_by_term(self, term, param, **kwargs): url = 'persons/search' - return self._client._get(self._client.BASE_URL + url, term=term, **kwargs) + return self._client._get(self._client.BASE_URL + url, term=term, param=param, **kwargs) \ No newline at end of file From 3df923ddf7e2a007258268e2260f8d4a820c1f9d Mon Sep 17 00:00:00 2001 From: Danie Krige Date: Mon, 26 Jul 2021 07:04:20 +0200 Subject: [PATCH 15/38] Update persons.py Correcting List of Paramaters --- pipedrive/persons.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index 0d5e972..087db66 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -35,6 +35,6 @@ def get_person_fields(self, params=None, **kwargs): url = 'personFields' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - def search_persons_by_term(self, term, param, **kwargs): + def search_persons_by_term(self, params=None, **kwargs): url = 'persons/search' - return self._client._get(self._client.BASE_URL + url, term=term, param=param, **kwargs) \ No newline at end of file + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) \ No newline at end of file From 3adc6de74b277f5f0108b04088098cdee7cb9fac Mon Sep 17 00:00:00 2001 From: Danie Krige Date: Mon, 26 Jul 2021 08:15:50 +0200 Subject: [PATCH 16/38] Added pull requests Added pull requests --- pipedrive/deals.py | 5 +++++ pipedrive/organizations.py | 5 +++++ pipedrive/persons.py | 2 +- pipedrive/products.py | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pipedrive/deals.py b/pipedrive/deals.py index 2f4b3f7..5bde5c4 100644 --- a/pipedrive/deals.py +++ b/pipedrive/deals.py @@ -34,6 +34,11 @@ def get_deal_details(self, deal_id, **kwargs): url = 'deals/{}'.format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) + def search_deals(self, params=None, **kwargs): + url = 'deals/search' + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + + #Deprecated, rather look at search_deals def get_deals_by_name(self, params=None, **kwargs): url = 'deals/find' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/organizations.py b/pipedrive/organizations.py index 8cb2ac2..d4e7c9a 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -26,6 +26,11 @@ def get_organization_fields(self, params=None, **kwargs): url = 'organizationFields' return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + def search_organizations(self, params=None, **kwargs): + url = 'organizations/search' + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + + #Deprecated, rather look at search_organizations def find_organization_by_name(self, **kwargs): url = 'organizations/find' return self._client._get(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index 087db66..3e1237a 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -25,7 +25,7 @@ def update_person(self, person_id, data, **kwargs): def delete_person(self, person_id, **kwargs): url = 'persons/{}'.format(person_id) - return self._client._delete(url, **kwargs) + return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_person_deals(self, person_id, **kwargs): url = 'persons/{}/deals'.format(person_id) diff --git a/pipedrive/products.py b/pipedrive/products.py index 49870c5..a76ef94 100644 --- a/pipedrive/products.py +++ b/pipedrive/products.py @@ -10,6 +10,11 @@ def get_all_products(self, **kwargs): url = 'products' return self._client._get(self._client.BASE_URL + url, **kwargs) + def search_products(self, params=None, **kwargs): + url = 'products/search' + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + + #Deprecated rather use search_products def get_product_by_name(self, **kwargs): url = 'products/find' return self._client._get(self._client.BASE_URL + url, **kwargs) From 0cffb28873caf0aa5cda62459ab4815dd92150b9 Mon Sep 17 00:00:00 2001 From: Danie Krige Date: Wed, 8 Sep 2021 16:18:13 +0200 Subject: [PATCH 17/38] Added support for Leads, Added itemSearch Leads by Hedley Co-Authored-By: Hedley Roos <316314+hedleyroos@users.noreply.github.com> --- pipedrive/client.py | 6 ++++-- pipedrive/items.py | 7 +++++++ pipedrive/leads.py | 27 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 pipedrive/items.py create mode 100644 pipedrive/leads.py diff --git a/pipedrive/client.py b/pipedrive/client.py index dfdf2d4..8acad39 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -6,13 +6,14 @@ from pipedrive.activities import Activities from pipedrive.deals import Deals from pipedrive.filters import Filters +from pipedrive.leads import Leads +from pipedrive.items import Items from pipedrive.notes import Notes from pipedrive.organizations import Organizations from pipedrive.persons import Persons from pipedrive.pipelines import Pipelines from pipedrive.products import Products from pipedrive.recents import Recents -from pipedrive.stages import Stages from pipedrive.users import Users from pipedrive.webhooks import Webhooks @@ -29,13 +30,14 @@ def __init__(self, client_id=None, client_secret=None, domain=None): self.activities = Activities(self) self.deals = Deals(self) self.filters = Filters(self) + self.leads = Leads(self) + self.items = Items(self) self.notes = Notes(self) self.organizations = Organizations(self) self.persons = Persons(self) self.pipelines = Pipelines(self) self.products = Products(self) self.recents = Recents(self) - self.stages = Stages(self) self.users = Users(self) self.webhooks = Webhooks(self) diff --git a/pipedrive/items.py b/pipedrive/items.py new file mode 100644 index 0000000..9ae4e8a --- /dev/null +++ b/pipedrive/items.py @@ -0,0 +1,7 @@ +class Items(object): + def __init__(self, client): + self._client = client + + def get_item_search(self, **kwargs): + url = 'itemSearch' + return self._client._get(self._client.BASE_URL + url, **kwargs) \ No newline at end of file diff --git a/pipedrive/leads.py b/pipedrive/leads.py new file mode 100644 index 0000000..b910116 --- /dev/null +++ b/pipedrive/leads.py @@ -0,0 +1,27 @@ +class Leads(object): + def __init__(self, client): + self._client = client + + def get_lead(self, lead_id, **kwargs): + url = 'leads/{}'.format(lead_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) + + def get_all_leads(self, **kwargs): + url = 'leads' + return self._client._get(self._client.BASE_URL + url, **kwargs) + + def create_lead(self, data, **kwargs): + url = 'leads' + return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) + + def update_lead(self, lead_id, data, **kwargs): + url = 'leads/{}'.format(lead_id) + return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) + + def delete_lead(self, lead_id, **kwargs): + url = 'leads/{}'.format(lead_id) + return self._client._delete(self._client.BASE_URL + url, **kwargs) + + def get_lead_details(self, lead_id, **kwargs): + url = 'leads/{}'.format(lead_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) From c603c8fb95cee88a34c4e0b11b9f55df50d3a94e Mon Sep 17 00:00:00 2001 From: Danie Krige Date: Wed, 8 Sep 2021 17:15:07 +0200 Subject: [PATCH 18/38] Fixed Params --- pipedrive/items.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipedrive/items.py b/pipedrive/items.py index 9ae4e8a..e538d26 100644 --- a/pipedrive/items.py +++ b/pipedrive/items.py @@ -2,6 +2,6 @@ class Items(object): def __init__(self, client): self._client = client - def get_item_search(self, **kwargs): + def get_item_search(self, params=None, **kwargs): url = 'itemSearch' return self._client._get(self._client.BASE_URL + url, **kwargs) \ No newline at end of file From 47b6e62d75c1020b1ba0afaddecc9f5b3266ffd0 Mon Sep 17 00:00:00 2001 From: Danie Krige Date: Wed, 8 Sep 2021 17:27:23 +0200 Subject: [PATCH 19/38] Return params=params --- pipedrive/items.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipedrive/items.py b/pipedrive/items.py index e538d26..c52c98a 100644 --- a/pipedrive/items.py +++ b/pipedrive/items.py @@ -4,4 +4,4 @@ def __init__(self, client): def get_item_search(self, params=None, **kwargs): url = 'itemSearch' - return self._client._get(self._client.BASE_URL + url, **kwargs) \ No newline at end of file + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) \ No newline at end of file From 3f9b910574222241282411143b7fd5bf511d5cb5 Mon Sep 17 00:00:00 2001 From: sgiraldo Date: Thu, 16 Dec 2021 18:12:36 -0500 Subject: [PATCH 20/38] fix: file format and default BASE_URL --- pipedrive/client.py | 50 +++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/pipedrive/client.py b/pipedrive/client.py index dfdf2d4..ef2464b 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -18,8 +18,8 @@ class Client: - BASE_URL = 'https://api-proxy.pipedrive.com/' - OAUTH_BASE_URL = 'https://oauth.pipedrive.com/oauth/' + BASE_URL = "https://api.pipedrive.com/" + OAUTH_BASE_URL = "https://oauth.pipedrive.com/oauth/" def __init__(self, client_id=None, client_secret=None, domain=None): self.client_id = client_id @@ -40,35 +40,31 @@ def __init__(self, client_id=None, client_secret=None, domain=None): self.webhooks = Webhooks(self) if domain: - if not domain.endswith('/'): - domain += '/' - self.BASE_URL = domain + 'v1/' + if not domain.endswith("/"): + domain += "/" + self.BASE_URL = domain + "v1/" def authorization_url(self, redirect_uri, state=None): params = { - 'client_id': self.client_id, - 'redirect_uri': redirect_uri, + "client_id": self.client_id, + "redirect_uri": redirect_uri, } if state is not None: - params['state'] = state + params["state"] = state - return self.OAUTH_BASE_URL + 'authorize?' + urlencode(params) + return self.OAUTH_BASE_URL + "authorize?" + urlencode(params) def exchange_code(self, redirect_uri, code): - data = { - 'grant_type': 'authorization_code', - 'code': code, - 'redirect_uri': redirect_uri - } - return self._post(self.OAUTH_BASE_URL + 'token', data=data, auth=(self.client_id, self.client_secret)) + data = {"grant_type": "authorization_code", "code": code, "redirect_uri": redirect_uri} + return self._post(self.OAUTH_BASE_URL + "token", data=data, auth=(self.client_id, self.client_secret)) def refresh_token(self, refresh_token): data = { - 'grant_type': 'refresh_token', - 'refresh_token': refresh_token, + "grant_type": "refresh_token", + "refresh_token": refresh_token, } - return self._post(self.OAUTH_BASE_URL + 'token', data=data, auth=(self.client_id, self.client_secret)) + return self._post(self.OAUTH_BASE_URL + "token", data=data, auth=(self.client_id, self.client_secret)) def set_access_token(self, access_token): self.access_token = access_token @@ -77,24 +73,24 @@ def set_api_token(self, api_token): self.api_token = api_token def _get(self, url, params=None, **kwargs): - return self._request('get', url, params=params, **kwargs) + return self._request("get", url, params=params, **kwargs) def _post(self, url, **kwargs): - return self._request('post', url, **kwargs) + return self._request("post", url, **kwargs) def _put(self, url, **kwargs): - return self._request('put', url, **kwargs) + return self._request("put", url, **kwargs) def _delete(self, url, **kwargs): - return self._request('delete', url, **kwargs) + return self._request("delete", url, **kwargs) def _request(self, method, url, headers=None, params=None, **kwargs): _headers = {} _params = {} if self.access_token: - _headers['Authorization'] = 'Bearer {}'.format(self.access_token) + _headers["Authorization"] = "Bearer {}".format(self.access_token) if self.api_token: - _params['api_token'] = self.api_token + _params["api_token"] = self.api_token if headers: _headers.update(headers) if params: @@ -103,15 +99,15 @@ def _request(self, method, url, headers=None, params=None, **kwargs): def _parse(self, response): status_code = response.status_code - if 'Content-Type' in response.headers and 'application/json' in response.headers['Content-Type']: + if "Content-Type" in response.headers and "application/json" in response.headers["Content-Type"]: r = response.json() else: return response.text if not response.ok: error = None - if 'error' in r: - error = r['error'] + if "error" in r: + error = r["error"] if status_code == 400: raise exceptions.BadRequestError(error, response) elif status_code == 401: From 4cfcee3fe0adb47446754f8254bf27552930603a Mon Sep 17 00:00:00 2001 From: sgiraldo Date: Thu, 16 Dec 2021 18:15:39 -0500 Subject: [PATCH 21/38] fix: file format and webhook endpoints --- pipedrive/webhooks.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pipedrive/webhooks.py b/pipedrive/webhooks.py index 47f0264..a83eaf0 100644 --- a/pipedrive/webhooks.py +++ b/pipedrive/webhooks.py @@ -3,19 +3,18 @@ def __init__(self, client): self._client = client def get_hooks_subscription(self, **kwargs): - url = 'webhooks' + url = "webhooks" return self._client._get(url, **kwargs) def create_hook_subscription(self, subscription_url, event_action, event_object, **kwargs): - url = 'webhooks' + url = "webhooks" data = { - 'subscription_url': - subscription_url, - 'event_action': event_action, - 'event_object': event_object + "subscription_url": subscription_url, + "event_action": event_action, + "event_object": event_object, } - return self._client._post(url, json=data, **kwargs) + return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def delete_hook_subscription(self, hook_id, **kwargs): - url = 'webhooks/{}'.format(hook_id) - return self._client._delete(url, **kwargs) + url = "webhooks/{}".format(hook_id) + return self._client._delete(self._client.BASE_URL + url, **kwargs) From 4be3562ccd24bf6234a28dbce814c7a94b240b39 Mon Sep 17 00:00:00 2001 From: sgiraldo Date: Wed, 22 Dec 2021 08:55:29 -0500 Subject: [PATCH 22/38] fix: get_hooks_subscription endpoint --- pipedrive/webhooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipedrive/webhooks.py b/pipedrive/webhooks.py index a83eaf0..bdf9c07 100644 --- a/pipedrive/webhooks.py +++ b/pipedrive/webhooks.py @@ -4,7 +4,7 @@ def __init__(self, client): def get_hooks_subscription(self, **kwargs): url = "webhooks" - return self._client._get(url, **kwargs) + return self._client._get(self._client.BASE_URL + url, **kwargs) def create_hook_subscription(self, subscription_url, event_action, event_object, **kwargs): url = "webhooks" From e2bd1f759290931639eeb3822ea6b7e15f5ab9df Mon Sep 17 00:00:00 2001 From: sgiraldo Date: Wed, 22 Dec 2021 08:57:54 -0500 Subject: [PATCH 23/38] fix: update setup version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0ad6bac..5673c5a 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def read(fname): setup(name='pipedrive-python-lib', - version='1.1.4', + version='1.1.5', description='API wrapper for Pipedrive written in Python', long_description=read('README.md'), long_description_content_type="text/markdown", From 434c6824701942cfe8d0cbe658c31dafefe76151 Mon Sep 17 00:00:00 2001 From: Julien Bordet Date: Thu, 3 Feb 2022 19:22:31 +0100 Subject: [PATCH 24/38] Get stages back --- pipedrive/client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pipedrive/client.py b/pipedrive/client.py index a56bc47..49f9b3b 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -13,6 +13,7 @@ from pipedrive.persons import Persons from pipedrive.pipelines import Pipelines from pipedrive.products import Products +from pipedrive.stages import Stages from pipedrive.recents import Recents from pipedrive.users import Users from pipedrive.webhooks import Webhooks @@ -38,6 +39,7 @@ def __init__(self, client_id=None, client_secret=None, domain=None): self.pipelines = Pipelines(self) self.products = Products(self) self.recents = Recents(self) + self.stages = Stages(self) self.users = Users(self) self.webhooks = Webhooks(self) From 16cfecaebff3f81c31d71dc2d343b2e80ff2c676 Mon Sep 17 00:00:00 2001 From: Julien Bordet Date: Thu, 3 Feb 2022 21:00:51 +0100 Subject: [PATCH 25/38] add Subscriptions interface for Pipedrive --- pipedrive/client.py | 2 ++ pipedrive/subscriptions.py | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 pipedrive/subscriptions.py diff --git a/pipedrive/client.py b/pipedrive/client.py index a56bc47..803bd16 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -14,6 +14,7 @@ from pipedrive.pipelines import Pipelines from pipedrive.products import Products from pipedrive.recents import Recents +from pipedrive.subscriptions import Subscriptions from pipedrive.users import Users from pipedrive.webhooks import Webhooks @@ -37,6 +38,7 @@ def __init__(self, client_id=None, client_secret=None, domain=None): self.persons = Persons(self) self.pipelines = Pipelines(self) self.products = Products(self) + self.subscriptions = Subscriptions(self) self.recents = Recents(self) self.users = Users(self) self.webhooks = Webhooks(self) diff --git a/pipedrive/subscriptions.py b/pipedrive/subscriptions.py new file mode 100644 index 0000000..feb8cae --- /dev/null +++ b/pipedrive/subscriptions.py @@ -0,0 +1,39 @@ +class Subscriptions(object): + def __init__(self, client): + self._client = client + + def get_subscription(self, subscription_id, **kwargs): + url = 'subscriptions/{}'.format(subscription_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) + + def get_deal_subscription(self, deal_id, **kwargs): + url = 'subscriptions/find/{}'.format(deal_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) + + def get_all_payments(self, subscription_id, **kwargs): + url = 'subscriptions/{}/payments'.format(subscription_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) + + def add_recurring_subscription(self, data, **kwargs): + url = 'subscriptions/recurring' + return self._client._post(self._client.BASE_URL + url, data, **kwargs) + + def add_installment_subscription(self, data, **kwargs): + url = 'subscriptions/installment' + return self._client._post(self._client.BASE_URL + url, data, **kwargs) + + def update_recurring_subscription(self, subscription_id, data, **kwargs): + url = 'subscriptions/recurring/{}'.format(subscription_id) + return self._client._put(self._client.base_url + url, data, **kwargs) + + def update_installment_subscription(self, subscription_id, data, **kwargs): + url = 'subscriptions/installment/{}'.format(subscription_id) + return self._client._put(self._client.base_url + url, data, **kwargs) + + def cancel_recurring_subscription(self, subscription_id, data, **kwargs): + url = 'subscriptions/recurring/{}/cancel'.format(subscription_id) + return self._client._put(self._client.base_url + url, data, **kwargs) + + def delete_subscription(self, subscription_id, **kwargs): + url = 'subscriptions/{}'.format(subscription_id) + return self._client._delete(self._client.BASE_URL + url, **kwargs) From aef12e421b7d182e1776ad1374bae887a874e208 Mon Sep 17 00:00:00 2001 From: Sadik Bakiu Date: Wed, 23 Mar 2022 12:02:24 +0100 Subject: [PATCH 26/38] Add deal/{id}/flow endpoint --- README.md | 5 +++++ pipedrive/deals.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index faf3aa8..616f759 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,11 @@ response = client.deals.get_deal_products('DEAL_ID') response = client.deals.get_deal_fields() ``` +#### Get updates of a deal +``` +response = client.deals.get_deal_updates('DEAL_ID') +``` + ### Filters API docs: https://developers.pipedrive.com/docs/api/v1/#!/Filters diff --git a/pipedrive/deals.py b/pipedrive/deals.py index 9c86153..118d025 100644 --- a/pipedrive/deals.py +++ b/pipedrive/deals.py @@ -87,3 +87,7 @@ def get_deal_fields(self, params=None, **kwargs): def add_product_to_deal(self, deal_id, data, **kwargs): url = 'deals/{}/products'.format(deal_id) return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) + + def get_deal_updates(self, deal_id, **kwargs): + url = 'deals/{}/flow'.format(deal_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) From 150585f952d6137957352812f2641fff9e4c4850 Mon Sep 17 00:00:00 2001 From: "Teal (P&B)" <87190689+teal-pb@users.noreply.github.com> Date: Fri, 15 Apr 2022 18:58:10 +0200 Subject: [PATCH 27/38] Add support for `organizations/:id/persons` call https://developers.pipedrive.com/docs/api/v1/Organizations#getOrganizationPersons --- pipedrive/organizations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pipedrive/organizations.py b/pipedrive/organizations.py index dbf6475..1c6743a 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -28,4 +28,8 @@ def get_organization_fields(self, params=None, **kwargs): def search_organizations(self, params=None, **kwargs): url = 'organizations/search' - return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) \ No newline at end of file + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + + def get_organization_persons(self, organization_id, params=None, **kwargs): + url = 'organizations/{}/persons'.format(organization_id) + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) From 62d5730f509dffb70f72f429c7943657961e1190 Mon Sep 17 00:00:00 2001 From: rusty Date: Thu, 8 Sep 2022 10:32:22 +0300 Subject: [PATCH 28/38] Added PATCH client method, fix Lead update method --- pipedrive/client.py | 30 +++++++++++++++++++++++++----- pipedrive/leads.py | 14 +++++++------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/pipedrive/client.py b/pipedrive/client.py index a56bc47..463371e 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -58,15 +58,27 @@ def authorization_url(self, redirect_uri, state=None): return self.OAUTH_BASE_URL + "authorize?" + urlencode(params) def exchange_code(self, redirect_uri, code): - data = {"grant_type": "authorization_code", "code": code, "redirect_uri": redirect_uri} - return self._post(self.OAUTH_BASE_URL + "token", data=data, auth=(self.client_id, self.client_secret)) + data = { + "grant_type": "authorization_code", + "code": code, + "redirect_uri": redirect_uri, + } + return self._post( + self.OAUTH_BASE_URL + "token", + data=data, + auth=(self.client_id, self.client_secret), + ) def refresh_token(self, refresh_token): data = { "grant_type": "refresh_token", "refresh_token": refresh_token, } - return self._post(self.OAUTH_BASE_URL + "token", data=data, auth=(self.client_id, self.client_secret)) + return self._post( + self.OAUTH_BASE_URL + "token", + data=data, + auth=(self.client_id, self.client_secret), + ) def set_access_token(self, access_token): self.access_token = access_token @@ -83,6 +95,9 @@ def _post(self, url, **kwargs): def _put(self, url, **kwargs): return self._request("put", url, **kwargs) + def _patch(self, url, **kwargs): + return self._request("patch", url, **kwargs) + def _delete(self, url, **kwargs): return self._request("delete", url, **kwargs) @@ -97,11 +112,16 @@ def _request(self, method, url, headers=None, params=None, **kwargs): _headers.update(headers) if params: _params.update(params) - return self._parse(requests.request(method, url, headers=_headers, params=_params, **kwargs)) + return self._parse( + requests.request(method, url, headers=_headers, params=_params, **kwargs) + ) def _parse(self, response): status_code = response.status_code - if "Content-Type" in response.headers and "application/json" in response.headers["Content-Type"]: + if ( + "Content-Type" in response.headers + and "application/json" in response.headers["Content-Type"] + ): r = response.json() else: return response.text diff --git a/pipedrive/leads.py b/pipedrive/leads.py index b910116..9ea9802 100644 --- a/pipedrive/leads.py +++ b/pipedrive/leads.py @@ -3,25 +3,25 @@ def __init__(self, client): self._client = client def get_lead(self, lead_id, **kwargs): - url = 'leads/{}'.format(lead_id) + url = "leads/{}".format(lead_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_leads(self, **kwargs): - url = 'leads' + url = "leads" return self._client._get(self._client.BASE_URL + url, **kwargs) def create_lead(self, data, **kwargs): - url = 'leads' + url = "leads" return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def update_lead(self, lead_id, data, **kwargs): - url = 'leads/{}'.format(lead_id) - return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) + url = "leads/{}".format(lead_id) + return self._client._patch(self._client.BASE_URL + url, json=data, **kwargs) def delete_lead(self, lead_id, **kwargs): - url = 'leads/{}'.format(lead_id) + url = "leads/{}".format(lead_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_lead_details(self, lead_id, **kwargs): - url = 'leads/{}'.format(lead_id) + url = "leads/{}".format(lead_id) return self._client._get(self._client.BASE_URL + url, **kwargs) From caf364a0b51cc60f6d390c0fe91e518a72eb92ad Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Wed, 23 Nov 2022 11:22:28 -0500 Subject: [PATCH 29/38] fix: formatting; bump version --- pipedrive/activities.py | 12 ++++----- pipedrive/client.py | 9 ++----- pipedrive/deals.py | 50 ++++++++++++++++++-------------------- pipedrive/filters.py | 10 ++++---- pipedrive/items.py | 4 +-- pipedrive/notes.py | 12 ++++----- pipedrive/organizations.py | 18 +++++++------- pipedrive/persons.py | 18 +++++++------- pipedrive/pipelines.py | 6 ++--- pipedrive/products.py | 16 ++++++------ pipedrive/recents.py | 2 +- pipedrive/stages.py | 12 ++++----- pipedrive/subscriptions.py | 18 +++++++------- pipedrive/users.py | 6 ++--- setup.py | 30 ++++++++++++----------- 15 files changed, 108 insertions(+), 115 deletions(-) diff --git a/pipedrive/activities.py b/pipedrive/activities.py index b630b5e..5b41c6f 100644 --- a/pipedrive/activities.py +++ b/pipedrive/activities.py @@ -3,25 +3,25 @@ def __init__(self, client): self._client = client def get_activity(self, activity_id, **kwargs): - url = 'activities/{}'.format(activity_id) + url = "activities/{}".format(activity_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_activities(self, params=None, **kwargs): - url = 'activities' + url = "activities" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_activity(self, data, **kwargs): - url = 'activities' + url = "activities" return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def update_activity(self, activity_id, data, **kwargs): - url = 'activities/{}'.format(activity_id) + url = "activities/{}".format(activity_id) return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) def delete_activity(self, activity_id, **kwargs): - url = 'activities/{}'.format(activity_id) + url = "activities/{}".format(activity_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_activity_fields(self, params=None, **kwargs): - url = 'activityFields' + url = "activityFields" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/client.py b/pipedrive/client.py index eb5f62f..856db91 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -116,16 +116,11 @@ def _request(self, method, url, headers=None, params=None, **kwargs): _headers.update(headers) if params: _params.update(params) - return self._parse( - requests.request(method, url, headers=_headers, params=_params, **kwargs) - ) + return self._parse(requests.request(method, url, headers=_headers, params=_params, **kwargs)) def _parse(self, response): status_code = response.status_code - if ( - "Content-Type" in response.headers - and "application/json" in response.headers["Content-Type"] - ): + if "Content-Type" in response.headers and "application/json" in response.headers["Content-Type"]: r = response.json() else: return response.text diff --git a/pipedrive/deals.py b/pipedrive/deals.py index 118d025..d634fdd 100644 --- a/pipedrive/deals.py +++ b/pipedrive/deals.py @@ -3,91 +3,87 @@ def __init__(self, client): self._client = client def get_deal(self, deal_id, **kwargs): - url = 'deals/{}'.format(deal_id) + url = "deals/{}".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_deals(self, params=None, **kwargs): - url = 'deals' + url = "deals" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def get_all_deals_with_filter(self, filter_id, params=None, **kwargs): - url = 'deals?filter_id={}'.format(filter_id) + url = "deals?filter_id={}".format(filter_id) return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_deal(self, data, **kwargs): - url = 'deals' + url = "deals" return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def update_deal(self, deal_id, data, **kwargs): - url = 'deals/{}'.format(deal_id) + url = "deals/{}".format(deal_id) return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) def delete_deal(self, deal_id, **kwargs): - url = 'deals/{}'.format(deal_id) + url = "deals/{}".format(deal_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def duplicate_deal(self, deal_id, **kwargs): - url = 'deals/{}/duplicate'.format(deal_id) + url = "deals/{}/duplicate".format(deal_id) return self._client._post(self._client.BASE_URL + url, **kwargs) def get_deal_details(self, deal_id, **kwargs): - url = 'deals/{}'.format(deal_id) + url = "deals/{}".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def search_deals(self, params=None, **kwargs): - url = 'deals/search' + url = "deals/search" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def get_deal_followers(self, deal_id, **kwargs): - url = 'deals/{}/followers'.format(deal_id) + url = "deals/{}/followers".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def add_follower_to_deal(self, deal_id, user_id, **kwargs): - url = 'deals/{}/followers'.format(deal_id) - data = { - 'user_id': user_id - } + url = "deals/{}/followers".format(deal_id) + data = {"user_id": user_id} return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def delete_follower_to_deal(self, deal_id, follower_id, **kwargs): - url = 'deals/{}/followers/{}'.format(deal_id, follower_id) + url = "deals/{}/followers/{}".format(deal_id, follower_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_deal_participants(self, deal_id, **kwargs): - url = 'deals/{}/participants'.format(deal_id) + url = "deals/{}/participants".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def add_participants_to_deal(self, deal_id, person_id, **kwargs): - url = 'deals/{}/participants'.format(deal_id) - data = { - 'person_id': person_id - } + url = "deals/{}/participants".format(deal_id) + data = {"person_id": person_id} return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def delete_participant_to_deal(self, deal_id, participant_id, **kwargs): - url = 'deals/{}/participants/{}'.format(deal_id, participant_id) + url = "deals/{}/participants/{}".format(deal_id, participant_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_deal_activities(self, deal_id, **kwargs): - url = 'deals/{}/activities'.format(deal_id) + url = "deals/{}/activities".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_deal_mail_messages(self, deal_id, **kwargs): - url = 'deals/{}/mailMessages'.format(deal_id) + url = "deals/{}/mailMessages".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_deal_products(self, deal_id, **kwargs): - url = 'deals/{}/products'.format(deal_id) + url = "deals/{}/products".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_deal_fields(self, params=None, **kwargs): - url = 'dealFields' + url = "dealFields" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def add_product_to_deal(self, deal_id, data, **kwargs): - url = 'deals/{}/products'.format(deal_id) + url = "deals/{}/products".format(deal_id) return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def get_deal_updates(self, deal_id, **kwargs): - url = 'deals/{}/flow'.format(deal_id) + url = "deals/{}/flow".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/filters.py b/pipedrive/filters.py index a481db8..8d3d338 100644 --- a/pipedrive/filters.py +++ b/pipedrive/filters.py @@ -3,21 +3,21 @@ def __init__(self, client): self._client = client def get_filter(self, filter_id, **kwargs): - url = 'filters/{}'.format(filter_id) + url = "filters/{}".format(filter_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_filters(self, params=None, **kwargs): - url = 'filters' + url = "filters" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_filter(self, data, **kwargs): - url = 'filters' + url = "filters" return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def update_filter(self, filter_id, data, **kwargs): - url = 'filters/{}'.format(filter_id) + url = "filters/{}".format(filter_id) return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) def delete_filter(self, filter_id, **kwargs): - url = 'filters/{}'.format(filter_id) + url = "filters/{}".format(filter_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/items.py b/pipedrive/items.py index c52c98a..124a0a7 100644 --- a/pipedrive/items.py +++ b/pipedrive/items.py @@ -3,5 +3,5 @@ def __init__(self, client): self._client = client def get_item_search(self, params=None, **kwargs): - url = 'itemSearch' - return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) \ No newline at end of file + url = "itemSearch" + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/notes.py b/pipedrive/notes.py index 714ed83..362686d 100644 --- a/pipedrive/notes.py +++ b/pipedrive/notes.py @@ -3,25 +3,25 @@ def __init__(self, client): self._client = client def get_note(self, note_id, **kwargs): - url = 'notes/{}'.format(note_id) + url = "notes/{}".format(note_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_notes(self, params=None, **kwargs): - url = 'notes' + url = "notes" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_note(self, data, **kwargs): - url = 'notes' + url = "notes" return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def update_note(self, note_id, data, **kwargs): - url = 'notes/{}'.format(note_id) + url = "notes/{}".format(note_id) return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) def delete_note(self, note_id, **kwargs): - url = 'notes/{}'.format(note_id) + url = "notes/{}".format(note_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_note_fields(self, params=None, **kwargs): - url = 'noteFields' + url = "noteFields" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/organizations.py b/pipedrive/organizations.py index 1c6743a..fed3279 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -3,33 +3,33 @@ def __init__(self, client): self._client = client def get_organization(self, organization_id, **kwargs): - url = 'organizations/{}'.format(organization_id) + url = "organizations/{}".format(organization_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_organizations(self, params=None, **kwargs): - url = 'organizations' + url = "organizations" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_organization(self, data, **kwargs): - url = 'organizations' + url = "organizations" return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def update_organization(self, organization_id, data, **kwargs): - url = 'organizations/{}'.format(organization_id) + url = "organizations/{}".format(organization_id) return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) def delete_organization(self, organization_id, **kwargs): - url = 'organizations/{}'.format(organization_id) + url = "organizations/{}".format(organization_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_organization_fields(self, params=None, **kwargs): - url = 'organizationFields' + url = "organizationFields" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def search_organizations(self, params=None, **kwargs): - url = 'organizations/search' + url = "organizations/search" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) - + def get_organization_persons(self, organization_id, params=None, **kwargs): - url = 'organizations/{}/persons'.format(organization_id) + url = "organizations/{}/persons".format(organization_id) return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index 7429d33..0d52bbe 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -3,33 +3,33 @@ def __init__(self, client): self._client = client def get_person(self, person_id, **kwargs): - url = 'persons/{}'.format(person_id) + url = "persons/{}".format(person_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_persons(self, params=None, **kwargs): - url = 'persons' + url = "persons" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def search_persons(self, params=None, **kwargs): - url = 'persons/search' + url = "persons/search" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_person(self, data, **kwargs): - url = 'persons' + url = "persons" return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def update_person(self, person_id, data, **kwargs): - url = 'persons/{}'.format(person_id) + url = "persons/{}".format(person_id) return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) def delete_person(self, person_id, **kwargs): - url = 'persons/{}'.format(person_id) + url = "persons/{}".format(person_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_person_deals(self, person_id, **kwargs): - url = 'persons/{}/deals'.format(person_id) + url = "persons/{}/deals".format(person_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_person_fields(self, params=None, **kwargs): - url = 'personFields' - return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) \ No newline at end of file + url = "personFields" + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/pipelines.py b/pipedrive/pipelines.py index 46c44f9..d22b177 100644 --- a/pipedrive/pipelines.py +++ b/pipedrive/pipelines.py @@ -3,13 +3,13 @@ def __init__(self, client): self._client = client def get_pipeline(self, pipeline_id, **kwargs): - url = 'pipelines/{}'.format(pipeline_id) + url = "pipelines/{}".format(pipeline_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_pipelines(self, **kwargs): - url = 'pipelines' + url = "pipelines" return self._client._get(self._client.BASE_URL + url, **kwargs) def get_pipeline_deals(self, pipeline_id, **kwargs): - url = 'pipelines/{}/deals'.format(pipeline_id) + url = "pipelines/{}/deals".format(pipeline_id) return self._client._get(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/products.py b/pipedrive/products.py index db5808e..1eff025 100644 --- a/pipedrive/products.py +++ b/pipedrive/products.py @@ -3,33 +3,33 @@ def __init__(self, client): self._client = client def get_product(self, product_id, **kwargs): - url = 'products/{}'.format(product_id) + url = "products/{}".format(product_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_products(self, **kwargs): - url = 'products' + url = "products" return self._client._get(self._client.BASE_URL + url, **kwargs) def search_products(self, params=None, **kwargs): - url = 'products/search' + url = "products/search" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def create_product(self, data, **kwargs): - url = 'products' + url = "products" return self._client._post(self._client.BASE_URL + url, json=data, **kwargs) def update_product(self, product_id, data, **kwargs): - url = 'products/{}'.format(product_id) + url = "products/{}".format(product_id) return self._client._put(self._client.BASE_URL + url, json=data, **kwargs) def delete_product(self, product_id, **kwargs): - url = 'products/{}'.format(product_id) + url = "products/{}".format(product_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) def get_product_deal(self, product_id, **kwargs): - url = 'products/{}/deals'.format(product_id) + url = "products/{}/deals".format(product_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_product_fields(self, **kwargs): - url = 'productFields' + url = "productFields" return self._client._get(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/recents.py b/pipedrive/recents.py index 9b9e761..3de33b7 100644 --- a/pipedrive/recents.py +++ b/pipedrive/recents.py @@ -3,5 +3,5 @@ def __init__(self, client): self._client = client def get_recent_changes(self, params=None, **kwargs): - url = 'recents' + url = "recents" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) diff --git a/pipedrive/stages.py b/pipedrive/stages.py index 56e3573..57ae854 100644 --- a/pipedrive/stages.py +++ b/pipedrive/stages.py @@ -3,25 +3,25 @@ def __init__(self, client): self._client = client def get_stage(self, stage_id, **kwargs): - url = 'stages/{}'.format(stage_id) + url = "stages/{}".format(stage_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_stages(self, params=None, **kwargs): - url = 'stages' + url = "stages" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) def get_stage_deals(self, stage_id, **kwargs): - url = 'stages/{}/deals'.format(stage_id) + url = "stages/{}/deals".format(stage_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def create_stage(self, data, **kwargs): - url = 'stages' + url = "stages" return self._client._post(self._client.BASE_URL + url, data, **kwargs) def update_stage(self, stage_id, data, **kwargs): - url = 'stages/{}'.format(stage_id) + url = "stages/{}".format(stage_id) return self._client._put(self._client.BASE_URL + url, data, **kwargs) def delete_stage(self, stage_id, **kwargs): - url = 'stages/{}'.format(stage_id) + url = "stages/{}".format(stage_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/subscriptions.py b/pipedrive/subscriptions.py index feb8cae..d368f1d 100644 --- a/pipedrive/subscriptions.py +++ b/pipedrive/subscriptions.py @@ -3,37 +3,37 @@ def __init__(self, client): self._client = client def get_subscription(self, subscription_id, **kwargs): - url = 'subscriptions/{}'.format(subscription_id) + url = "subscriptions/{}".format(subscription_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_deal_subscription(self, deal_id, **kwargs): - url = 'subscriptions/find/{}'.format(deal_id) + url = "subscriptions/find/{}".format(deal_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_payments(self, subscription_id, **kwargs): - url = 'subscriptions/{}/payments'.format(subscription_id) + url = "subscriptions/{}/payments".format(subscription_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def add_recurring_subscription(self, data, **kwargs): - url = 'subscriptions/recurring' + url = "subscriptions/recurring" return self._client._post(self._client.BASE_URL + url, data, **kwargs) def add_installment_subscription(self, data, **kwargs): - url = 'subscriptions/installment' + url = "subscriptions/installment" return self._client._post(self._client.BASE_URL + url, data, **kwargs) def update_recurring_subscription(self, subscription_id, data, **kwargs): - url = 'subscriptions/recurring/{}'.format(subscription_id) + url = "subscriptions/recurring/{}".format(subscription_id) return self._client._put(self._client.base_url + url, data, **kwargs) def update_installment_subscription(self, subscription_id, data, **kwargs): - url = 'subscriptions/installment/{}'.format(subscription_id) + url = "subscriptions/installment/{}".format(subscription_id) return self._client._put(self._client.base_url + url, data, **kwargs) def cancel_recurring_subscription(self, subscription_id, data, **kwargs): - url = 'subscriptions/recurring/{}/cancel'.format(subscription_id) + url = "subscriptions/recurring/{}/cancel".format(subscription_id) return self._client._put(self._client.base_url + url, data, **kwargs) def delete_subscription(self, subscription_id, **kwargs): - url = 'subscriptions/{}'.format(subscription_id) + url = "subscriptions/{}".format(subscription_id) return self._client._delete(self._client.BASE_URL + url, **kwargs) diff --git a/pipedrive/users.py b/pipedrive/users.py index 3eb7ee4..fee6b79 100644 --- a/pipedrive/users.py +++ b/pipedrive/users.py @@ -3,13 +3,13 @@ def __init__(self, client): self._client = client def get_user(self, user_id, **kwargs): - url = 'users/{}'.format(user_id) + url = "users/{}".format(user_id) return self._client._get(self._client.BASE_URL + url, **kwargs) def get_all_users(self, **kwargs): - url = 'users' + url = "users" return self._client._get(self._client.BASE_URL + url, **kwargs) def get_me(self, **kwargs): - url = 'users/me' + url = "users/me" return self._client._get(self._client.BASE_URL + url, **kwargs) diff --git a/setup.py b/setup.py index 5673c5a..631dc97 100644 --- a/setup.py +++ b/setup.py @@ -6,17 +6,19 @@ def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() -setup(name='pipedrive-python-lib', - version='1.1.5', - description='API wrapper for Pipedrive written in Python', - long_description=read('README.md'), - long_description_content_type="text/markdown", - url='https://github.com/GearPlug/pipedrive-python', - author='Miguel Ferrer', - author_email='ingferrermiguel@gmail.com', - license='MIT', - packages=['pipedrive'], - install_requires=[ - 'requests', - ], - zip_safe=False) +setup( + name="pipedrive-python-lib", + version="1.2.0", + description="API wrapper for Pipedrive written in Python", + long_description=read("README.md"), + long_description_content_type="text/markdown", + url="https://github.com/GearPlug/pipedrive-python", + author="Miguel Ferrer", + author_email="ingferrermiguel@gmail.com", + license="MIT", + packages=["pipedrive"], + install_requires=[ + "requests", + ], + zip_safe=False, +) From ea1700689c8d1b42c9233b14c7173f966c21c99d Mon Sep 17 00:00:00 2001 From: polux Date: Mon, 9 Jan 2023 11:39:48 -0300 Subject: [PATCH 30/38] get_persons_activities() added to function list --- pipedrive/persons.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index 0d52bbe..ead4399 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -33,3 +33,7 @@ def get_person_deals(self, person_id, **kwargs): def get_person_fields(self, params=None, **kwargs): url = "personFields" return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + + def get_person_activities(self, person_id, **kwargs): + url = "persons/{}/activities".format(person_id) + return self._client._get(self._client.BASE_URL + url, **kwargs) From 273b61bb65a3de325fe46dcbb651ea88444bef57 Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Mon, 30 Jan 2023 09:14:13 -0500 Subject: [PATCH 31/38] bump ver --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 631dc97..498f8c4 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(fname): setup( name="pipedrive-python-lib", - version="1.2.0", + version="1.2.1", description="API wrapper for Pipedrive written in Python", long_description=read("README.md"), long_description_content_type="text/markdown", From dd3979b79fba52592bc2f326b8e9a5c995bda3b2 Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Mon, 27 Mar 2023 15:48:04 -0500 Subject: [PATCH 32/38] feat: pyproject.toml --- pyproject.toml | 18 ++++++++++++++++++ setup.py | 24 ------------------------ 2 files changed, 18 insertions(+), 24 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..dcd6287 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[tool.poetry] +name = "pipedrive-python-lib" +version = "1.2.2" +description = "API wrapper for Pipedrive written in Python" +authors = ["Miguel Ferrer "] +license = "MIT" +readme = "README.md" +packages = [{include = "pipedrive"}] + +[tool.poetry.dependencies] +python = "^3.7" +requests = "^2.26.0" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + diff --git a/setup.py b/setup.py deleted file mode 100644 index 498f8c4..0000000 --- a/setup.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -from setuptools import setup - - -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - - -setup( - name="pipedrive-python-lib", - version="1.2.1", - description="API wrapper for Pipedrive written in Python", - long_description=read("README.md"), - long_description_content_type="text/markdown", - url="https://github.com/GearPlug/pipedrive-python", - author="Miguel Ferrer", - author_email="ingferrermiguel@gmail.com", - license="MIT", - packages=["pipedrive"], - install_requires=[ - "requests", - ], - zip_safe=False, -) From 2d44053f08e8a128d4521a29d11ecf29b4fb6644 Mon Sep 17 00:00:00 2001 From: martin sarsale Date: Fri, 23 Jun 2023 11:03:58 -0300 Subject: [PATCH 33/38] Update README.md Fixes URLs in Pipedrive API docs --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 616f759..0092091 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ client.set_api_token('API_TOKEN') ### Activities -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Activities +API docs: https://developers.pipedrive.com/docs/api/v1/Activities #### Get an activity ``` @@ -96,7 +96,7 @@ response = client.activities.get_activity_fields() ### Deals -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Deals +API docs: https://developers.pipedrive.com/docs/api/v1/Deals #### Get a deal ``` @@ -209,7 +209,7 @@ response = client.deals.get_deal_updates('DEAL_ID') ### Filters -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Filters +API docs: https://developers.pipedrive.com/docs/api/v1/Filters #### Get a filter ``` @@ -248,7 +248,7 @@ response = client.filters.delete_filter('FILTER_ID') ### Notes -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Notes +API docs: https://developers.pipedrive.com/docs/api/v1/Notes #### Get a note ``` @@ -288,7 +288,7 @@ response = client.notes.get_note_fields() ### Organizations -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Organizations +API docs: https://developers.pipedrive.com/docs/api/v1/Organizations #### Get an organization ``` @@ -336,7 +336,7 @@ response = client.organizations.get_organization_fields() ### Persons -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Persons +API docs: https://developers.pipedrive.com/docs/api/v1/Persons #### Get a person ``` @@ -389,7 +389,7 @@ response = client.persons.get_person_fields() ### Pipelines -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Pipelines +API docs: https://developers.pipedrive.com/docs/api/v1/Pipelines #### Get a pipeline ``` @@ -408,7 +408,7 @@ response = client.pipelines.get_pipeline_deals() ### Products -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Products +API docs: https://developers.pipedrive.com/docs/api/v1/Products #### Get a product ``` @@ -471,7 +471,7 @@ response = client.recents.get_recent_changes(params=params) ### Users -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Users +API docs: https://developers.pipedrive.com/docs/api/v1/Users #### Get an user ``` @@ -490,7 +490,7 @@ response = client.users.get_me() ### Webhook -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Webhooks +API docs: https://developers.pipedrive.com/docs/api/v1/Webhooks #### Get webhooks ``` From 0e3c7f41fbc3c2d1e2a447d38c2632f0ca29e90b Mon Sep 17 00:00:00 2001 From: Nikita Pokidyshev Date: Wed, 27 Sep 2023 19:53:12 +0300 Subject: [PATCH 34/38] Add search_leads --- pipedrive/leads.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pipedrive/leads.py b/pipedrive/leads.py index 9ea9802..2efe4f2 100644 --- a/pipedrive/leads.py +++ b/pipedrive/leads.py @@ -25,3 +25,7 @@ def delete_lead(self, lead_id, **kwargs): def get_lead_details(self, lead_id, **kwargs): url = "leads/{}".format(lead_id) return self._client._get(self._client.BASE_URL + url, **kwargs) + + def search_leads(self, params=None, **kwargs): + url = "leads/search" + return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) From fdd447edc949f9ceaff628313dcfb8ad2e475abc Mon Sep 17 00:00:00 2001 From: Juan Date: Fri, 29 Sep 2023 12:22:32 -0500 Subject: [PATCH 35/38] readme leads and fixes --- README.md | 159 ++++++++++++++++++++++++++----------------------- pyproject.toml | 2 +- 2 files changed, 87 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 0092091..f6b5ebe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pipedrive-python - -pipedrive-python is an API wrapper for [Pipedrive](https://www.pipedrive.com/) written in Python. +![](https://img.shields.io/badge/version-1.2.3-success) ![](https://img.shields.io/badge/Python-3.8%20|%203.9%20|%203.10%20|%203.11-4B8BBE?logo=python&logoColor=white) +*pipedrive-python* is an API wrapper for [Pipedrive](https://www.pipedrive.com/) written in Python. ## Installing ``` @@ -12,43 +12,43 @@ pip install pipedrive-python-lib ### Using this library with OAuth 2.0 #### Client instantiation -``` +```python from pipedrive.client import Client client = Client('CLIENT_ID', 'CLIENT_SECRET') ``` #### Get authorization url -``` +```python url = client.authorization_url('REDIRECT_URL') ``` #### Exchange the code for an access token -``` +```python token = client.exchange_code('REDIRECT_URL', 'CODE') ``` #### Set access token in the library -``` +```python client.set_access_token('ACCESS_TOKEN') ``` #### Refresh token -``` +```python token = client.refresh_token('REFRESH_TOKEN') ``` ### Using this library with API Token #### Client instantiation -``` +```python from pipedrive.client import Client client = Client(domain='https://companydomain.pipedrive.com/') ``` #### Set API token in the library -``` +```python client.set_api_token('API_TOKEN') ``` @@ -57,17 +57,17 @@ client.set_api_token('API_TOKEN') API docs: https://developers.pipedrive.com/docs/api/v1/Activities #### Get an activity -``` +```python response = client.activities.get_activity('ACTIVITY_ID') ``` #### Get all activities -``` +```python response = client.activities.get_all_activities() ``` #### Create an activity -``` +```python data = { 'subject': '', 'type': '' @@ -76,7 +76,7 @@ response = client.activities.create_activity(data) ``` #### Update an activity -``` +```python data = { 'subject': '', 'type': '' @@ -85,12 +85,12 @@ response = client.activities.update_activity('ACTIVITY_ID', data) ``` #### Delete an activity -``` +```python response = client.activities.delete_activity('ACTIVITY_ID') ``` #### Get activity fields -``` +```python response = client.activities.get_activity_fields() ``` @@ -99,22 +99,22 @@ response = client.activities.get_activity_fields() API docs: https://developers.pipedrive.com/docs/api/v1/Deals #### Get a deal -``` +```python response = client.deals.get_deal('DEAL_ID') ``` #### Get all deals -``` +```python response = client.deals.get_all_deals() ``` #### Get all deals based on filter -``` +```python response = client.deals.get_all_deals_with_filter('FILTER_ID') ``` #### Create deal -``` +```python data = { 'title': '' } @@ -122,7 +122,7 @@ response = client.deals.create_deal(data) ``` #### Update deal -``` +```python data = { 'title': '' } @@ -130,22 +130,22 @@ response = client.deals.update_deal('DEAL_ID', data) ``` #### Delete deal -``` +```python response = client.deals.delete_deal('DEAL_ID') ``` #### Duplicate deal -``` +```python response = client.deals.duplicate_deal('DEAL_ID') ``` #### Get details of a deal -``` +```python response = client.deals.get_deal_details('DEAL_ID') ``` #### Search deals -``` +```python params = { 'term': '' } @@ -153,57 +153,57 @@ response = client.deals.search_deals(params=params) ``` #### Get followers of a deal -``` +```python response = client.deals.get_deal_followers('DEAL_ID') ``` #### Add a follower to a deal -``` +```python response = client.deals.add_follower_to_deal('DEAL_ID', 'USER_ID') ``` #### Delete a follower from a deal -``` +```python response = client.deals.delete_follower_to_deal('DEAL_ID', 'FOLLOWER_ID') ``` #### Get participants of a deal -``` +```python response = client.deals.get_deal_participants('DEAL_ID') ``` #### Add a participant to a deal -``` +```python response = client.deals.add_participants_to_deal('DEAL_ID', 'PERSON_ID') ``` #### Delete a participant from a deal -``` +```python response = client.deals.delete_participant_to_deal('DEAL_ID', 'PARTICIPANT_ID') ``` #### Get activities associated with a deal -``` +```python response = client.deals.get_deal_activities('DEAL_ID') ``` #### Get mail messages associated with a deal -``` +```python response = client.deals.get_deal_mail_messages('DEAL_ID') ``` #### Get products attached to a deal -``` +```python response = client.deals.get_deal_products('DEAL_ID') ``` #### Get deal fields -``` +```python response = client.deals.get_deal_fields() ``` #### Get updates of a deal -``` +```python response = client.deals.get_deal_updates('DEAL_ID') ``` @@ -212,17 +212,17 @@ response = client.deals.get_deal_updates('DEAL_ID') API docs: https://developers.pipedrive.com/docs/api/v1/Filters #### Get a filter -``` +```python response = client.filters.get_filter('FILTER_ID') ``` #### Get all filters -``` +```python response = client.filters.get_all_filters() ``` #### Create filter -``` +```python data = { 'name': '', 'conditions': {}, @@ -232,7 +232,7 @@ response = client.filters.create_filter(data) ``` #### Update filter -``` +```python data = { 'name': '', 'conditions': {}, @@ -242,7 +242,7 @@ response = client.filters.update_filter('FILTER_ID', data) ``` #### Delete filter -``` +```python response = client.filters.delete_filter('FILTER_ID') ``` @@ -251,17 +251,17 @@ response = client.filters.delete_filter('FILTER_ID') API docs: https://developers.pipedrive.com/docs/api/v1/Notes #### Get a note -``` +```python response = client.notes.get_note('NOTE_ID') ``` #### Get all notes -``` +```python response = client.notes.get_all_notes() ``` #### Add a note -``` +```python data = { 'content': '' } @@ -269,7 +269,7 @@ response = client.notes.create_note(data) ``` #### Update a note -``` +```python data = { 'content': '' } @@ -277,12 +277,12 @@ response = client.notes.update_note('NOTE_ID', data) ``` #### Delete a note -``` +```python response = client.notes.delete_note('NOTE_ID') ``` #### Get note fields -``` +```python response = client.notes.get_note_fields() ``` @@ -291,17 +291,17 @@ response = client.notes.get_note_fields() API docs: https://developers.pipedrive.com/docs/api/v1/Organizations #### Get an organization -``` +```python response = client.organizations.get_organization('ORGANIZATION_ID') ``` #### Get all organizations -``` +```python response = client.organizations.get_all_organizations() ``` #### Search organizations -``` +```python params = { 'term': '' } @@ -309,7 +309,7 @@ response = client.products.search_organizations(params=params) ``` #### Add organization -``` +```python data = { 'name': '' } @@ -317,7 +317,7 @@ response = client.organizations.create_organization(data) ``` #### Update organization -``` +```python data = { 'name': '' } @@ -325,12 +325,12 @@ response = client.organizations.update_organization('ORGANIZATION_ID', data) ``` #### Delete an organization -``` +```python response = client.organizations.delete_organization('ORGANIZATION_ID') ``` #### Get organization fields -``` +```python response = client.organizations.get_organization_fields() ``` @@ -339,17 +339,17 @@ response = client.organizations.get_organization_fields() API docs: https://developers.pipedrive.com/docs/api/v1/Persons #### Get a person -``` +```python response = client.persons.get_person('PERSON_ID') ``` #### Get all persons -``` +```python response = client.persons.get_all_persons() ``` #### Search persons -``` +```python params = { 'term': '' } @@ -357,7 +357,7 @@ response = client.persons.search_persons(params=params) ``` #### Create person -``` +```python data = { 'name': '' } @@ -365,7 +365,7 @@ response = client.persons.create_person(data) ``` #### Update person -``` +```python data = { 'name': '' } @@ -373,17 +373,17 @@ response = client.persons.update_person('PERSON_ID', data) ``` #### Delete person -``` +```python response = client.persons.delete_person('PERSON_ID') ``` #### Get deals associated with a person -``` +```python response = client.persons.get_person_deals('PERSON_ID') ``` #### Get person fields -``` +```python response = client.persons.get_person_fields() ``` @@ -392,17 +392,17 @@ response = client.persons.get_person_fields() API docs: https://developers.pipedrive.com/docs/api/v1/Pipelines #### Get a pipeline -``` +```python response = client.pipelines.get_pipeline('PIPELINE_ID') ``` #### Get all pipelines -``` +```python response = client.pipelines.get_all_pipelines() ``` #### Get deals attached to a pipeline -``` +```python response = client.pipelines.get_pipeline_deals() ``` @@ -411,17 +411,17 @@ response = client.pipelines.get_pipeline_deals() API docs: https://developers.pipedrive.com/docs/api/v1/Products #### Get a product -``` +```python response = client.products.get_product('PRODUCT_ID') ``` #### Get all products -``` +```python response = client.products.get_all_products() ``` #### Search products -``` +```python params = { 'term': '' } @@ -429,7 +429,7 @@ response = client.products.search_products(params=params) ``` #### Create a product -``` +```python data = { 'name': '' } @@ -437,7 +437,7 @@ response = client.products.create_product(data) ``` #### Update a product -``` +```python data = { 'name': '' } @@ -445,30 +445,43 @@ response = client.products.update_product('PRODUCT_ID', data) ``` #### Delete a product -``` +```python response = client.products.delete_product('PRODUCT_ID') ``` #### Get deals where a product is attached to -``` +```python response = client.products.get_product_deal('PRODUCT_ID') ``` #### Get product fields -``` +```python response = client.products.get_product_fields() ``` ### Recents #### Get recent changes -``` +```python params = { 'since_timestamp': 'YYYY-MM-DD HH:MM:SS' } response = client.recents.get_recent_changes(params=params) ``` +### Leads +API docs: https://developers.pipedrive.com/docs/api/v1/Leads +#### Get a lead +```python +response = client.leads.get_lead('LEAD_ID') +``` +#### Search leads +```python +params = { + 'term': '' +} +response = client.leads.search_leads(params=params) +``` ### Users API docs: https://developers.pipedrive.com/docs/api/v1/Users diff --git a/pyproject.toml b/pyproject.toml index dcd6287..0eab7cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pipedrive-python-lib" -version = "1.2.2" +version = "1.2.3" description = "API wrapper for Pipedrive written in Python" authors = ["Miguel Ferrer "] license = "MIT" From d190673b0ae3d0272e379712dcf885b605f4167d Mon Sep 17 00:00:00 2001 From: Ape Toshi Date: Thu, 26 Oct 2023 20:28:41 +0200 Subject: [PATCH 36/38] Add add_follower_to_person --- pipedrive/persons.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index ead4399..ce92945 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -37,3 +37,8 @@ def get_person_fields(self, params=None, **kwargs): def get_person_activities(self, person_id, **kwargs): url = "persons/{}/activities".format(person_id) return self._client._get(self._client.BASE_URL + url, **kwargs) + + def add_follower_to_person(self, person_id, user_id, **kwargs): + url = "persons/{}/followers".format(person_id) + data = {'user_id': user_id} + return self.client._post(self.BASE_URL+url, json=data, **kwargs) From f25b6f2fe904bf7afd13297179a3965514c95a45 Mon Sep 17 00:00:00 2001 From: Ape Toshi Date: Thu, 26 Oct 2023 20:33:47 +0200 Subject: [PATCH 37/38] Changed single to double quotes --- pipedrive/persons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index ce92945..5d7f615 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -40,5 +40,5 @@ def get_person_activities(self, person_id, **kwargs): def add_follower_to_person(self, person_id, user_id, **kwargs): url = "persons/{}/followers".format(person_id) - data = {'user_id': user_id} + data = {"user_id": user_id} return self.client._post(self.BASE_URL+url, json=data, **kwargs) From ffd556ab3749f0da8db0c6f8e029a3a3b3ec2469 Mon Sep 17 00:00:00 2001 From: Ape Toshi Date: Thu, 26 Oct 2023 20:43:48 +0200 Subject: [PATCH 38/38] Add add_follower_to_organization --- pipedrive/organizations.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pipedrive/organizations.py b/pipedrive/organizations.py index fed3279..193d491 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -33,3 +33,8 @@ def search_organizations(self, params=None, **kwargs): def get_organization_persons(self, organization_id, params=None, **kwargs): url = "organizations/{}/persons".format(organization_id) return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) + + def add_follower_to_organization(self, org_id, user_id, **kwargs): + url = "organizations/{}/followers".format(org_id) + data = {"user_id": user_id} + return self._post(self.BASE_URL+url, json=data, **kwargs)