diff --git a/README.md b/README.md index faf3aa8..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,62 +12,62 @@ 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') ``` ### Activities -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Activities +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,36 +85,36 @@ 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() ``` ### Deals -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Deals +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,71 +153,76 @@ 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') +``` + ### Filters -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Filters +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': {}, @@ -227,7 +232,7 @@ response = client.filters.create_filter(data) ``` #### Update filter -``` +```python data = { 'name': '', 'conditions': {}, @@ -237,26 +242,26 @@ response = client.filters.update_filter('FILTER_ID', data) ``` #### Delete filter -``` +```python 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 -``` +```python response = client.notes.get_note('NOTE_ID') ``` #### Get all notes -``` +```python response = client.notes.get_all_notes() ``` #### Add a note -``` +```python data = { 'content': '' } @@ -264,7 +269,7 @@ response = client.notes.create_note(data) ``` #### Update a note -``` +```python data = { 'content': '' } @@ -272,31 +277,31 @@ 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() ``` ### Organizations -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Organizations +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': '' } @@ -304,7 +309,7 @@ response = client.products.search_organizations(params=params) ``` #### Add organization -``` +```python data = { 'name': '' } @@ -312,7 +317,7 @@ response = client.organizations.create_organization(data) ``` #### Update organization -``` +```python data = { 'name': '' } @@ -320,31 +325,31 @@ 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() ``` ### Persons -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Persons +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': '' } @@ -352,7 +357,7 @@ response = client.persons.search_persons(params=params) ``` #### Create person -``` +```python data = { 'name': '' } @@ -360,7 +365,7 @@ response = client.persons.create_person(data) ``` #### Update person -``` +```python data = { 'name': '' } @@ -368,55 +373,55 @@ 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() ``` ### Pipelines -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Pipelines +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() ``` ### Products -API docs: https://developers.pipedrive.com/docs/api/v1/#!/Products +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': '' } @@ -424,7 +429,7 @@ response = client.products.search_products(params=params) ``` #### Create a product -``` +```python data = { 'name': '' } @@ -432,7 +437,7 @@ response = client.products.create_product(data) ``` #### Update a product -``` +```python data = { 'name': '' } @@ -440,33 +445,46 @@ 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 +API docs: https://developers.pipedrive.com/docs/api/v1/Users #### Get an user ``` @@ -485,7 +503,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 ``` 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 a56bc47..856db91 100644 --- a/pipedrive/client.py +++ b/pipedrive/client.py @@ -13,7 +13,9 @@ 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.subscriptions import Subscriptions from pipedrive.users import Users from pipedrive.webhooks import Webhooks @@ -37,7 +39,9 @@ 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.stages = Stages(self) self.users = Users(self) self.webhooks = Webhooks(self) @@ -58,15 +62,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 +99,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) diff --git a/pipedrive/deals.py b/pipedrive/deals.py index 9c86153..d634fdd 100644 --- a/pipedrive/deals.py +++ b/pipedrive/deals.py @@ -3,87 +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) + 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/leads.py b/pipedrive/leads.py index b910116..2efe4f2 100644 --- a/pipedrive/leads.py +++ b/pipedrive/leads.py @@ -3,25 +3,29 @@ 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) + + def search_leads(self, params=None, **kwargs): + url = "leads/search" + 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 dbf6475..193d491 100644 --- a/pipedrive/organizations.py +++ b/pipedrive/organizations.py @@ -3,29 +3,38 @@ 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' - return self._client._get(self._client.BASE_URL + url, params=params, **kwargs) \ No newline at end of file + 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) + 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) diff --git a/pipedrive/persons.py b/pipedrive/persons.py index 7429d33..5d7f615 100644 --- a/pipedrive/persons.py +++ b/pipedrive/persons.py @@ -3,33 +3,42 @@ 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) + + 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) 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 new file mode 100644 index 0000000..d368f1d --- /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) 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/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0eab7cd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[tool.poetry] +name = "pipedrive-python-lib" +version = "1.2.3" +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 5673c5a..0000000 --- a/setup.py +++ /dev/null @@ -1,22 +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.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)