From 0a7514f4e997910df1872ddffc22b90f20b1bc5f Mon Sep 17 00:00:00 2001 From: Hedley Roos Date: Mon, 30 Nov 2020 11:12:16 +0200 Subject: [PATCH] Minimal implementation of leads --- pipedrive/client.py | 8 ++++---- pipedrive/leads.py | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 pipedrive/leads.py diff --git a/pipedrive/client.py b/pipedrive/client.py index dfdf2d4..eb468f9 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -6,13 +6,13 @@ from pipedrive.activities import Activities from pipedrive.deals import Deals from pipedrive.filters import Filters +from pipedrive.leads import Leads 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 +29,13 @@ 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.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) @@ -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, params=None, **kwargs): - return self._request('get', url, params=params, **kwargs) + def _get(self, url, **kwargs): + return self._request('get', url, **kwargs) def _post(self, url, **kwargs): return self._request('post', url, **kwargs) 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)