Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for Projects #55

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions pipedrive/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pipedrive import exceptions
from pipedrive.activities import Activities
from pipedrive.deals import Deals
from pipedrive.projects import Projects
from pipedrive.filters import Filters
from pipedrive.leads import Leads
from pipedrive.items import Items
Expand All @@ -31,6 +32,7 @@ def __init__(self, client_id=None, client_secret=None, domain=None):
self.api_token = None
self.activities = Activities(self)
self.deals = Deals(self)
self.projects = Projects(self)
self.filters = Filters(self)
self.leads = Leads(self)
self.items = Items(self)
Expand All @@ -49,6 +51,9 @@ def __init__(self, client_id=None, client_secret=None, domain=None):
if not domain.endswith("/"):
domain += "/"
self.BASE_URL = domain + "v1/"
else:
self.BASE_URL = self.BASE_URL + "v1/"


def authorization_url(self, redirect_uri, state=None):
params = {
Expand Down
77 changes: 77 additions & 0 deletions pipedrive/projects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
class Projects(object):
def __init__(self, client):
self._client = client

def get_project(self, project_id, **kwargs):
url = "projects/{}".format(project_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)

def get_all_projects(self, params=None, **kwargs):
url = "projects"
return self._client._get(self._client.BASE_URL + url, params=params, **kwargs)

def get_all_projects_with_filter(self, filter_id, params=None, **kwargs):
url = "projects?filter_id={}".format(filter_id)
return self._client._get(self._client.BASE_URL + url, params=params, **kwargs)

def create_project(self, data, **kwargs):
url = "projects"
return self._client._post(self._client.BASE_URL + url, json=data, **kwargs)

def update_project(self, project_id, data, **kwargs):
url = "projects/{}".format(project_id)
return self._client._put(self._client.BASE_URL + url, json=data, **kwargs)

def delete_project(self, project_id, **kwargs):
url = "projects/{}".format(project_id)
return self._client._delete(self._client.BASE_URL + url, **kwargs)

def duplicate_project(self, project_id, **kwargs):
url = "projects/{}/duplicate".format(project_id)
return self._client._post(self._client.BASE_URL + url, **kwargs)

def get_project_details(self, project_id, **kwargs):
url = "projects/{}".format(project_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)

def search_projects(self, params=None, **kwargs):
url = "projects/search"
return self._client._get(self._client.BASE_URL + url, params=params, **kwargs)

def get_project_plan(self, project_id, **kwargs):
url = "projects/{}/plan".format(project_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)

def get_project_groups(self, project_id, **kwargs):
url = "projects/{}/groups".format(project_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)

def get_project_tasks(self, project_id, **kwargs):
url = "projects/{}/tasks".format(project_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)

def get_project_activities(self, project_id, **kwargs):
url = "projects/{}/activities".format(project_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)

def get_project_fields(self, params=None, **kwargs):
url = "projectFields"
return self._client._get(self._client.BASE_URL + url, params=params, **kwargs)

def get_all_projects_boards(self, params=None, **kwargs):
url = "projects/boards"
return self._client._get(self._client.BASE_URL + url, params=params, **kwargs)

def get_board(self, board_id, **kwargs):
url = "projects/boards/{}".format(board_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)

def get_project_phases(self, board_id, **kwargs):
url = "projects/phases?board_id={}".format(board_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)

def get_phase(self, phase_id, **kwargs):
url = "projects/phases/{}".format(phase_id)
return self._client._get(self._client.BASE_URL + url, **kwargs)