From 0a555a17f3ede3fb1aa00e34ba6e283cc16a5f3d Mon Sep 17 00:00:00 2001 From: atomasevic Date: Thu, 2 Jul 2015 15:31:57 +0200 Subject: [PATCH 01/35] Added method getById to Activities. Fixed spelling in Activities, mistyped details (before commit detials) --- .gitignore | 33 +++++++++++++++++-- .../Pipedrive/Library/Activities.php | 17 ++++++++-- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5970802..4e4a6b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,32 @@ +# phpstorm project files +.idea + +# netbeans project files +nbproject + +# zend studio for eclipse project files +.buildpath +.project +.settings + +# windows thumbnail cache +Thumbs.db + +# composer vendor dir +/vendor +# cubrid install dir +/cubrid + +# composer itself is not needed composer.phar -composer.lock + +# composer.lock in applications is ignored since it's automatically created by composer when application is installed +/apps/*/composer.lock + +# Mac DS_Store Files .DS_Store -Thumbs.db -sftp-config.json \ No newline at end of file + +# phpunit itself is not needed +phpunit.phar +# local phpunit config +/phpunit.xml diff --git a/src/Benhawker/Pipedrive/Library/Activities.php b/src/Benhawker/Pipedrive/Library/Activities.php index cf93df3..3023c2e 100644 --- a/src/Benhawker/Pipedrive/Library/Activities.php +++ b/src/Benhawker/Pipedrive/Library/Activities.php @@ -32,8 +32,9 @@ public function __construct(\Benhawker\Pipedrive\Pipedrive $master) /** * Adds a activity * - * @param array $data activity detials - * @return array returns detials of the activity + * @param array $data activity details + * @return array returns details of the activity + * @throws PipedriveMissingFieldError */ public function add(array $data) { @@ -45,4 +46,16 @@ public function add(array $data) return $this->curl->post('activities', $data); } + + + /** + * Return activity + * + * @param int $id pipedrive activity id + * @return array returns details of activity + */ + public function getById($id) + { + return $this->curl->get('activities/' . $id); + } } From ab3a251e5618382c95b90c4dae19d45eb3d40a62 Mon Sep 17 00:00:00 2001 From: atomasevic Date: Thu, 2 Jul 2015 16:20:21 +0200 Subject: [PATCH 02/35] Added method getById to Activities. Fixed spelling in Activities, mistyped details (before commit detials) --- .gitignore | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 4e4a6b9..5970802 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,5 @@ -# phpstorm project files -.idea - -# netbeans project files -nbproject - -# zend studio for eclipse project files -.buildpath -.project -.settings - -# windows thumbnail cache -Thumbs.db - -# composer vendor dir -/vendor -# cubrid install dir -/cubrid - -# composer itself is not needed composer.phar - -# composer.lock in applications is ignored since it's automatically created by composer when application is installed -/apps/*/composer.lock - -# Mac DS_Store Files +composer.lock .DS_Store - -# phpunit itself is not needed -phpunit.phar -# local phpunit config -/phpunit.xml +Thumbs.db +sftp-config.json \ No newline at end of file From 3f3db6d084bd795701e79c8759ecb0d733debf01 Mon Sep 17 00:00:00 2001 From: atomasevic Date: Thu, 2 Jul 2015 16:20:51 +0200 Subject: [PATCH 03/35] Reverted gitignore file for pull request --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5970802..e1c6abd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ composer.phar composer.lock .DS_Store Thumbs.db -sftp-config.json \ No newline at end of file +sftp-config.json From 3c553abeaba89080b37a91894f060ea9fe8b1bb9 Mon Sep 17 00:00:00 2001 From: atomasevic Date: Thu, 2 Jul 2015 16:22:14 +0200 Subject: [PATCH 04/35] Reverted gitignore file for pull request --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e1c6abd..5970802 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ composer.phar composer.lock .DS_Store Thumbs.db -sftp-config.json +sftp-config.json \ No newline at end of file From cd6692ed42c1226d14f3799be27f815cb057295c Mon Sep 17 00:00:00 2001 From: atomasevic Date: Fri, 17 Jul 2015 15:40:45 +0200 Subject: [PATCH 05/35] included persons:getByEmail --- src/Benhawker/Pipedrive/Library/Persons.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Persons.php b/src/Benhawker/Pipedrive/Library/Persons.php index e87f39b..14c53fa 100644 --- a/src/Benhawker/Pipedrive/Library/Persons.php +++ b/src/Benhawker/Pipedrive/Library/Persons.php @@ -49,6 +49,18 @@ public function getByName($name) return $this->curl->get('persons/find', array('term' => $name)); } + /** + + * Returns a person / people + + * + + * @param string $email pipedrive persons email + + * @return array returns details of a person + + */ + public function getByEmail($email) + { + return $this->curl->get('persons/find', array('term' => $email, 'search_by_email' => 1)); + } + + /** * Lists deals associated with a person. * From 25835e5e1e7f28df7c60f3a00efc8ed992f25795 Mon Sep 17 00:00:00 2001 From: atomasevic Date: Fri, 17 Jul 2015 17:24:45 +0200 Subject: [PATCH 06/35] activities getByUser --- .idea/misc.xml | 4 ++++ src/Benhawker/Pipedrive/Library/Activities.php | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 .idea/misc.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8662aa9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Benhawker/Pipedrive/Library/Activities.php b/src/Benhawker/Pipedrive/Library/Activities.php index 3023c2e..42ae578 100644 --- a/src/Benhawker/Pipedrive/Library/Activities.php +++ b/src/Benhawker/Pipedrive/Library/Activities.php @@ -58,4 +58,13 @@ public function getById($id) { return $this->curl->get('activities/' . $id); } + + /** + * @param array $data + * @return array returns all activities by data fields + */ + public function getByUser(array $data) + { + return $this->curl->get('activities', $data); + } } From 7cf7333cc8d41709789e095dc09b1e3a9f831beb Mon Sep 17 00:00:00 2001 From: atomasevic Date: Fri, 17 Jul 2015 17:33:30 +0200 Subject: [PATCH 07/35] activities delete activity by id --- src/Benhawker/Pipedrive/Library/Activities.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Activities.php b/src/Benhawker/Pipedrive/Library/Activities.php index 42ae578..76ea95e 100644 --- a/src/Benhawker/Pipedrive/Library/Activities.php +++ b/src/Benhawker/Pipedrive/Library/Activities.php @@ -47,6 +47,14 @@ public function add(array $data) return $this->curl->post('activities', $data); } + /** + * @param $id + * @return array returns deleted id + */ + public function delete($id){ + return $this->curl->delete('activities/'.$id); + } + /** * Return activity From 37985244e5bb90542f19920db2f5d2744b195804 Mon Sep 17 00:00:00 2001 From: atomasevic Date: Mon, 27 Jul 2015 11:51:56 +0200 Subject: [PATCH 08/35] Deals.php - Added bulk delete request --- src/Benhawker/Pipedrive/Library/Curl.php | 20 +++++++++++++++++++ src/Benhawker/Pipedrive/Library/Deals.php | 24 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Curl.php b/src/Benhawker/Pipedrive/Library/Curl.php index 8ed21fc..4642052 100644 --- a/src/Benhawker/Pipedrive/Library/Curl.php +++ b/src/Benhawker/Pipedrive/Library/Curl.php @@ -122,6 +122,26 @@ public function delete($method) ->exec(); } + + /** + * Bulk delete request + * + * @param $method + * @param array $data + * @return array + * @throws PipedriveApiError + * @throws PipedriveHttpError + */ + public function bulkDelete($method, array $data) + { + + return $this->createEndPoint($method) + ->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE') + ->setOpt(CURLOPT_POSTFIELDS, http_build_query($data)) + ->exec(); + + } + /** * Execute current cURL session * diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index 533c2d8..4355ad1 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -142,4 +142,28 @@ public function moveStage($dealId, $stageId) return $this->curl->put('deals/' . $dealId, array('stage_id' => $stageId)); } + /** + * Delete single deal by deal id + * + * @param $dealId + * @return array + */ + + public function delete($dealId) + { + return $this->curl->delete('deals/'.$dealId); + } + + + /** + * Bulk delete deals + * + * @param $ids comma separated ids + * @return mixed + */ + public function bulkDelete($ids) + { + return $this->curl->bulkDelete('deals', array('ids' => $ids)); + } + } From f0eee55fb7ba0c40f0085c9fa2a5f6f997716f90 Mon Sep 17 00:00:00 2001 From: atomasevic Date: Wed, 29 Jul 2015 12:54:29 +0200 Subject: [PATCH 09/35] Organizations.php - list persons in organizations --- src/Benhawker/Pipedrive/Library/Organizations.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Organizations.php b/src/Benhawker/Pipedrive/Library/Organizations.php index ac21d59..a55b1fd 100644 --- a/src/Benhawker/Pipedrive/Library/Organizations.php +++ b/src/Benhawker/Pipedrive/Library/Organizations.php @@ -116,4 +116,17 @@ public function delete($organizationId) { return $this->curl->delete('organizations/' . $organizationId); } + + + /** + * Get persons of organization + * + * @param $organizationId + * @return array + */ + + public function listPersons($organizationId) + { + return $this->curl->get('organizations/'.$organizationId.'/persons'); + } } From 456c5bb4371883a4046660904b24c059cde7c8d7 Mon Sep 17 00:00:00 2001 From: atomasevic Date: Wed, 29 Jul 2015 23:56:49 +0200 Subject: [PATCH 10/35] Organizations.php - bulk delete organizations --- src/Benhawker/Pipedrive/Library/Organizations.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Organizations.php b/src/Benhawker/Pipedrive/Library/Organizations.php index a55b1fd..ea3d0ba 100644 --- a/src/Benhawker/Pipedrive/Library/Organizations.php +++ b/src/Benhawker/Pipedrive/Library/Organizations.php @@ -117,6 +117,17 @@ public function delete($organizationId) return $this->curl->delete('organizations/' . $organizationId); } + /** + * Bulk delete organizations + * + * @param $ids + * @return array + */ + public function bulkDelete($ids) + { + return $this->curl->bulkDelete('organizations', array('ids' => $ids)); + } + /** * Get persons of organization From 5590c220da24da070e143724cecf3a09665cc762 Mon Sep 17 00:00:00 2001 From: atomasevic Date: Tue, 20 Oct 2015 23:53:20 +0200 Subject: [PATCH 11/35] Deals.php - Added getDealsTimeline method for endpoint [GET] deals/timeline --- src/Benhawker/Pipedrive/Library/Deals.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index 4355ad1..086503b 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -166,4 +166,26 @@ public function bulkDelete($ids) return $this->curl->bulkDelete('deals', array('ids' => $ids)); } + /** + * Get deals timeline + * + */ + + public function getDealsTimeline($params) + { + if(!isset($params['start_date'])){ + throw new PipedriveMissingFieldError('You must include "start_date" when getting deals timeline'); + } + if(!isset($params['interval']) || !in_array($params['interval'],['day','week','month','quarter']) ){ + throw new PipedriveMissingFieldError('You must include "interval" when getting deals timeline'); + } + if(!isset($params['amount'])){ + throw new PipedriveMissingFieldError('You must include "amount" when getting deals timeline'); + } + if(!isset($params['field_key'])){ + throw new PipedriveMissingFieldError('You must include "field_key" when getting deals timeline'); + } + + return $this->curl->get('deals/timeline', $params); + } } From fe2f97337c649dc78f3b71fc75cb0ef29594b86c Mon Sep 17 00:00:00 2001 From: atomasevic Date: Fri, 20 Nov 2015 13:58:03 +0100 Subject: [PATCH 12/35] Deals.php - Added updateProduct method for updating products attached to a single deal --- src/Benhawker/Pipedrive/Library/Deals.php | 28 ++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index 086503b..1552d52 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -1,5 +1,6 @@ curl->post('deals/' . $dealId . '/products', $data); } + + /** + * Update deal attached product. + * @param $dealId + * @param array $data + * @return array + * @throws PipedriveMissingFieldError + */ + public function updateProduct($dealId, array $data) + { + if(!isset($data['deal_product_id'])){ + throw new PipedriveMissingFieldError('You must include "deal_product_id" field when updating product.'); + } + + if(!isset($data['item_price'])){ + throw new PipedriveMissingFieldError('You must include "item_price" field when updating product.'); + } + + if(!isset($data['quantity'])){ + throw new PipedriveMissingFieldError('You must include "quantity" field when updating product'); + } + + return $this->curl->put('deals/'.$dealId.'/products/'.$data['deal_product_id'], $data); + } + /** * Updates a deal * From dd3c14d6832558d32802ac869c69a3100189c825 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Tue, 16 Feb 2016 16:29:57 +0100 Subject: [PATCH 13/35] gitignore .idea --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5970802..0ebeed0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ composer.phar composer.lock .DS_Store Thumbs.db -sftp-config.json \ No newline at end of file +sftp-config.json +.idea \ No newline at end of file From b91648200aca3cb922e209861da07e4a17987a21 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Tue, 16 Feb 2016 16:30:40 +0100 Subject: [PATCH 14/35] updated deal products to include product details in response --- .idea/misc.xml | 4 ---- src/Benhawker/Pipedrive/Library/Deals.php | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 .idea/misc.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 8662aa9..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index 1552d52..b3c7357 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -74,7 +74,7 @@ public function products(array $data) throw new PipedriveMissingFieldError('You must include the "id" of the deal when getting products'); } - return $this->curl->get('deals/' . $data['id'] . '/products'); + return $this->curl->get('deals/' . $data['id'] . '/products', $data); } /** From 3b3c62a76c025122a50d6336d0b4115ec0fa0f6c Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Thu, 25 Feb 2016 13:25:26 +0100 Subject: [PATCH 15/35] pipedrive-api - Added method getAllDeals --- src/Benhawker/Pipedrive/Library/Deals.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index b3c7357..e345e5f 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -214,4 +214,14 @@ public function getDealsTimeline($params) return $this->curl->get('deals/timeline', $params); } + + /** + * Get all deals by filter id + * @param $params + * @return array + */ + public function getAllDeals($params) + { + return $this->curl->get('deals', $params); + } } From e982fbd0d62bdf78f4445097ce0b92cf007f10a1 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Fri, 26 Feb 2016 11:34:30 +0100 Subject: [PATCH 16/35] pipedrive-api - Updated Organizations: list deals params --- src/Benhawker/Pipedrive/Library/Organizations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Benhawker/Pipedrive/Library/Organizations.php b/src/Benhawker/Pipedrive/Library/Organizations.php index ea3d0ba..bf6ce3d 100644 --- a/src/Benhawker/Pipedrive/Library/Organizations.php +++ b/src/Benhawker/Pipedrive/Library/Organizations.php @@ -75,7 +75,7 @@ public function deals(array $data) if (!isset($data['id'])) { throw new PipedriveMissingFieldError('You must include the "id" of the organization when getting deals'); } - return $this->curl->get('organizations/' . $data['id'] . '/deals'); + return $this->curl->get('organizations/' . $data['id'] . '/deals', $data); } /** From 28aa4851991e3d934a12f11c52e80e156b08ba43 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Tue, 1 Mar 2016 12:29:40 +0100 Subject: [PATCH 17/35] pipedrive-api - added SearchResults class with methods for general and field search - fixed few typos in comments --- src/Benhawker/Pipedrive/Library/Curl.php | 2 +- .../Pipedrive/Library/SearchResults.php | 76 +++++++++++++++++++ src/Benhawker/Pipedrive/Pipedrive.php | 30 ++++++-- 3 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 src/Benhawker/Pipedrive/Library/SearchResults.php diff --git a/src/Benhawker/Pipedrive/Library/Curl.php b/src/Benhawker/Pipedrive/Library/Curl.php index 4642052..e099cae 100644 --- a/src/Benhawker/Pipedrive/Library/Curl.php +++ b/src/Benhawker/Pipedrive/Library/Curl.php @@ -252,7 +252,7 @@ protected function postfields($data) } /** - * Build multidimenianl query + * Build multidimensional query * from: https://github.com/php-curl-class/php-curl-class * * @param array $data post data diff --git a/src/Benhawker/Pipedrive/Library/SearchResults.php b/src/Benhawker/Pipedrive/Library/SearchResults.php new file mode 100644 index 0000000..72d0e8c --- /dev/null +++ b/src/Benhawker/Pipedrive/Library/SearchResults.php @@ -0,0 +1,76 @@ +curl = $master->curl(); + } + + /** + * Performs a search across the account and returns SearchResults. + * @param array $data + * @return array + * @throws PipedriveApiError + * @throws PipedriveMissingFieldError + */ + public function search(array $data) + { + $this->validateSearchTerm($data, 2); + return $this->curl->get('searchResults', $data); + } + + /** + * Performs a search from a specific field's values. Results can be either the + * distinct values of the field (useful for searching autocomplete field values), + * or actual items IDs (deals, persons, organizations or products). Works only with the + * following field types: varchar, varchar_auto, double, address, text, phone, date. + * @param array $data + * @return array + * @throws PipedriveApiError + * @throws PipedriveMissingFieldError + */ + public function searchField(array $data) + { + $this->validateSearchTerm($data, 3); + return $this->curl->get('searchResults/field', $data); + } + + /** + * Validate that search query has term with min length + * @param array $data + * @param int $minLength + * @throws PipedriveApiError + * @throws PipedriveMissingFieldError + */ + private function validateSearchTerm(array $data, $minLength = 2) + { + if(!isset($data['term'])){ + throw new PipedriveMissingFieldError('You must include "term" in search method.'); + } else { + if(strlen($data['term']) < $minLength){ + throw new PipedriveApiError('Search term must be at least '. $minLength .' characters long'); + } + } + } +} \ No newline at end of file diff --git a/src/Benhawker/Pipedrive/Pipedrive.php b/src/Benhawker/Pipedrive/Pipedrive.php index 1fe7b18..3d87ae3 100644 --- a/src/Benhawker/Pipedrive/Pipedrive.php +++ b/src/Benhawker/Pipedrive/Pipedrive.php @@ -1,4 +1,5 @@ dealFields = new Library\DealFields($this); $this->organizations = new Library\Organizations($this); $this->products = new Library\Products($this); + $this->searchResults = new Library\SearchResults($this); } /** @@ -204,4 +211,13 @@ public function products() { return $this->products; } + + /** + * Returns the Pipedrive SearchResults Object + * @return SearchResults Object + */ + public function searchResults() + { + return $this->searchResults; + } } From 68e160a54f8c03f4d978b07b8cfdb0556eaff87a Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Mon, 6 Jun 2016 14:29:36 +0200 Subject: [PATCH 18/35] Pipedrive-Api - Deals->listActivities --- src/Benhawker/Pipedrive/Library/Deals.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index e345e5f..19e2d57 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -224,4 +224,15 @@ public function getAllDeals($params) { return $this->curl->get('deals', $params); } + + /** + * List all activities associated to deal. + * @param $dealId + * @param array $params + * @return array + */ + public function listActivities($dealId, $params = []) + { + return $this->curl->get('deals/' . $dealId . '/activities', $params); + } } From 4e7f21e228884d3af61f68e8d0668a8322bb239f Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Mon, 6 Jun 2016 15:06:00 +0200 Subject: [PATCH 19/35] Pipedrive-Api - Activities->update --- src/Benhawker/Pipedrive/Library/Activities.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Activities.php b/src/Benhawker/Pipedrive/Library/Activities.php index 76ea95e..4df1be1 100644 --- a/src/Benhawker/Pipedrive/Library/Activities.php +++ b/src/Benhawker/Pipedrive/Library/Activities.php @@ -55,6 +55,16 @@ public function delete($id){ return $this->curl->delete('activities/'.$id); } + /** + * Update activity + * @param $id + * @param $data + * @return array + */ + public function update($id, $data) + { + return $this->curl->put('activities/' . $id, $data); + } /** * Return activity From 38933d66d1abcebdb8d98ad78480793d81a16be1 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Wed, 20 Jul 2016 11:26:14 +0200 Subject: [PATCH 20/35] Pipedrive-Api - Filters class & methods --- src/Benhawker/Pipedrive/Library/Filters.php | 108 ++++++++++++++++++++ src/Benhawker/Pipedrive/Pipedrive.php | 16 +++ 2 files changed, 124 insertions(+) create mode 100644 src/Benhawker/Pipedrive/Library/Filters.php diff --git a/src/Benhawker/Pipedrive/Library/Filters.php b/src/Benhawker/Pipedrive/Library/Filters.php new file mode 100644 index 0000000..047ebcc --- /dev/null +++ b/src/Benhawker/Pipedrive/Library/Filters.php @@ -0,0 +1,108 @@ +curl = $master->curl(); + } + + /** + * Returns a filter + * + * @param int $id filter id + * @return array returns details of filter + */ + public function getById($id) + { + return $this->curl->get('filters/' . $id); + } + + /** + * Add new filter + * + * @param array $data filter details + * @return array returns details of filter + * @throws PipedriveMissingFieldError + */ + public function add(array $data) + { + //if there is no title set throw error as it is a required field + if (!isset($data['name']) || !isset($data['conditions'])) { + throw new PipedriveMissingFieldError('Missing required field name/conditions'); + } + + return $this->curl->post('filters', $data); + } + + /** + * Updates a deal + * + * @param $filterId + * @param array $data new details of filter + * @return array returns details of filter + * @internal param int $filterId + */ + public function update($filterId, array $data = array()) + { + return $this->curl->put('filters/' . $filterId, $data); + } + + + /** + * Delete single filter by filter id + * + * @param $filterId + * @return array + */ + + public function delete($filterId) + { + return $this->curl->delete('filters/'.$filterId); + } + + + /** + * Bulk delete filters + * + * @param $ids comma separated ids + * @return mixed + */ + public function bulkDelete($ids) + { + return $this->curl->bulkDelete('filters', array('ids' => $ids)); + } + + /** + * Get all filters by filter type + * @param $type + * @return array + * @throws PipedriveMissingFieldError + * @internal param $params + */ + public function getAll($type) + { + $supportedTypes = ['deals', 'org', 'people', 'products']; + if(!in_array($type, $supportedTypes)){ + throw new PipedriveMissingFieldError("Unrecognized filter type. Supported types are:" . implode(', ', $supportedTypes)); + } + return $this->curl->get('filters', $type); + } + +} diff --git a/src/Benhawker/Pipedrive/Pipedrive.php b/src/Benhawker/Pipedrive/Pipedrive.php index 3d87ae3..5ba32b9 100644 --- a/src/Benhawker/Pipedrive/Pipedrive.php +++ b/src/Benhawker/Pipedrive/Pipedrive.php @@ -68,6 +68,12 @@ class Pipedrive * @var \Benhawker\Pipedrive\Library\Deals Deals Object */ protected $deals; + + /** + * Placeholder attribute for pipedrive filters class + * @var \Benhawker\Pipedrive\Library\Filters Filters Object + */ + protected $filters; /** * Placeholder attribute for the pipedrive activities class * @var \Benhawker\Pipedrive\Library\Activities Activities Object @@ -130,6 +136,7 @@ public function __construct($apiKey = '', $protocol = 'https', $host = 'api.pipe $this->organizations = new Library\Organizations($this); $this->products = new Library\Products($this); $this->searchResults = new Library\SearchResults($this); + $this->filters = new Library\Filters($this); } /** @@ -162,6 +169,15 @@ public function deals() return $this->deals; } + /** + * Returns the Pipedrive Filters Object + * @return Library\Filters + */ + public function filters() + { + return $this->filters; + } + /** * Returns the Pipedrive Activities Object * From 801565315cc3e3b37971966964b9bd0e7d07ad05 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Wed, 20 Jul 2016 12:21:54 +0200 Subject: [PATCH 21/35] Pipedrive-Api - all persons method --- src/Benhawker/Pipedrive/Library/Persons.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Persons.php b/src/Benhawker/Pipedrive/Library/Persons.php index 14c53fa..613f331 100644 --- a/src/Benhawker/Pipedrive/Library/Persons.php +++ b/src/Benhawker/Pipedrive/Library/Persons.php @@ -121,6 +121,16 @@ public function add(array $data) return $this->curl->post('persons', $data); } + /** + * Get all persons by filter id + * @param $params + * @return array + */ + public function getAll($params) + { + return $this->curl->get('persons', $params); + } + /** * Deletes a person * From a3090fcd973ab0950bba2dd641c68bfe897213b1 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Tue, 30 Aug 2016 14:58:55 +0200 Subject: [PATCH 22/35] CURL timeout to 8000ms --- src/Benhawker/Pipedrive/Library/Curl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Benhawker/Pipedrive/Library/Curl.php b/src/Benhawker/Pipedrive/Library/Curl.php index e099cae..17d352e 100644 --- a/src/Benhawker/Pipedrive/Library/Curl.php +++ b/src/Benhawker/Pipedrive/Library/Curl.php @@ -44,6 +44,7 @@ public function __construct($url, $apiKey) $this->setOpt(CURLOPT_USERAGENT, self::USER_AGENT) ->setOpt(CURLOPT_HEADER, false) ->setOpt(CURLOPT_RETURNTRANSFER, true) + ->setOpt(CURLOPT_TIMEOUT_MS, 8000) ->setOpt(CURLOPT_HTTPHEADER, array("Accept: application/json")); } From 59817942c3aaf63876a7a691b9707ff167610cad Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Tue, 4 Jul 2017 11:02:59 +0200 Subject: [PATCH 23/35] - ORGANIZATION/DEAL: add/delete followers - Typo fixes --- .../Pipedrive/Library/DealFields.php | 3 +- src/Benhawker/Pipedrive/Library/Deals.php | 47 +++++++++++++++---- .../Pipedrive/Library/Organizations.php | 39 ++++++++++++--- 3 files changed, 72 insertions(+), 17 deletions(-) diff --git a/src/Benhawker/Pipedrive/Library/DealFields.php b/src/Benhawker/Pipedrive/Library/DealFields.php index 3c8f50e..33adcab 100644 --- a/src/Benhawker/Pipedrive/Library/DealFields.php +++ b/src/Benhawker/Pipedrive/Library/DealFields.php @@ -57,8 +57,9 @@ public function getById($id) /** * Adds a dealField * - * @param array $data deal field detials + * @param array $data deal field details * @return array returns details of the deal field + * @throws PipedriveMissingFieldError */ public function add(array $data) { diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index 19e2d57..cc42b4a 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -36,7 +36,7 @@ public function __construct(\Benhawker\Pipedrive\Pipedrive $master) * Returns a deal * * @param int $id pipedrive deals id - * @return array returns detials of a deal + * @return array returns details of a deal */ public function getById($id) { @@ -47,7 +47,7 @@ public function getById($id) * Returns a deal / deals * * @param string $name pipedrive deals title - * @return array returns detials of a deal + * @return array returns details of a deal */ public function getByName($name, $personId=null, $orgId=null) { @@ -66,6 +66,7 @@ public function getByName($name, $personId=null, $orgId=null) * * @param array $data (id, start, limit) * @return array products + * @throws PipedriveMissingFieldError */ public function products(array $data) { @@ -80,8 +81,9 @@ public function products(array $data) /** * Adds a deal * - * @param array $data deal detials - * @return array returns detials of the deal + * @param array $data deal details + * @return array returns details of the deal + * @throws PipedriveMissingFieldError */ public function add(array $data) { @@ -97,8 +99,8 @@ public function add(array $data) * Adds a product to a deal * * @param int $dealId deal id - * @param array $data deal and product detials - * @return array returns detials of the deal-product + * @param array $data deal and product details + * @return array returns details of the deal-product * @throws PipedriveMissingFieldError */ public function addProduct($dealId, array $data) @@ -148,8 +150,8 @@ public function updateProduct($dealId, array $data) * Updates a deal * * @param int $dealId pipedrives deal Id - * @param array $data new detials of deal - * @return array returns detials of a deal + * @param array $data new details of deal + * @return array returns details of a deal */ public function update($dealId, array $data = array()) { @@ -161,7 +163,7 @@ public function update($dealId, array $data = array()) * * @param int $dealId deal id * @param int $stageId stage id - * @return array returns detials of the deal + * @return array returns details of the deal */ public function moveStage($dealId, $stageId) { @@ -184,7 +186,7 @@ public function delete($dealId) /** * Bulk delete deals * - * @param $ids comma separated ids + * @param $ids string Comma separated ids * @return mixed */ public function bulkDelete($ids) @@ -235,4 +237,29 @@ public function listActivities($dealId, $params = []) { return $this->curl->get('deals/' . $dealId . '/activities', $params); } + + /** + * Add follower to a deal. + * @param $dealId + * @param $userId + * @return array + */ + public function addFollower($dealId, $userId) + { + return $this->curl->post('deals/' . $dealId . '/followers', [ + 'id' => $dealId, + 'user_id' => $userId + ]); + } + + /** + * Delete follower from a deal. + * @param $dealId + * @param $userId + * @return array + */ + public function deleteFollower($dealId, $userId) + { + return $this->curl->delete('deals/' . $dealId . '/followers/' . $userId); + } } diff --git a/src/Benhawker/Pipedrive/Library/Organizations.php b/src/Benhawker/Pipedrive/Library/Organizations.php index bf6ce3d..8b919ba 100644 --- a/src/Benhawker/Pipedrive/Library/Organizations.php +++ b/src/Benhawker/Pipedrive/Library/Organizations.php @@ -62,12 +62,13 @@ public function getAll(array $data = array()) { return $this->curl->get('organizations/', $data); } - + /** * Lists deals associated with a organization. * * @param array $data (id, start, limit) * @return array deals + * @throws PipedriveMissingFieldError */ public function deals(array $data) { @@ -82,8 +83,8 @@ public function deals(array $data) * Updates an organization * * @param int $organizationId pipedrives organization Id - * @param array $data new detials of organization - * @return array returns detials of a organization + * @param array $data new details of organization + * @return array returns details of a organization */ public function update($organizationId, array $data = array()) { @@ -93,8 +94,9 @@ public function update($organizationId, array $data = array()) /** * Adds a organization * - * @param array $data organizations detials - * @return array returns detials of a organization + * @param array $data organizations details + * @return array returns details of a organization + * @throws PipedriveMissingFieldError */ public function add(array $data) { @@ -110,7 +112,7 @@ public function add(array $data) * Deletes an organization * * @param int $organizationId pipedrives organization Id - * @return array returns detials of a organization + * @return array returns details of a organization */ public function delete($organizationId) { @@ -140,4 +142,29 @@ public function listPersons($organizationId) { return $this->curl->get('organizations/'.$organizationId.'/persons'); } + + /** + * Add follower to organization. + * @param $organizationId + * @param $userId + * @return array + */ + public function addFollower($organizationId, $userId) + { + return $this->curl->post('organizations/' . $organizationId . '/followers',[ + 'id' => $organizationId, + 'user_id' => $userId + ]); + } + + /** + * Delete organization follower. + * @param $organizationId + * @param $userId + * @return array + */ + public function deleteFollower($organizationId, $userId) + { + return $this->curl->delete('organizations/' . $organizationId . '/followers/' . $userId); + } } From 399cdc767362820b64ea16f308628039348ede21 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Tue, 3 Oct 2017 14:04:16 +0200 Subject: [PATCH 24/35] ACTIVITIES: - List activities - extracted from pipedrive dashboard XHR calls, since this method is not visible in API docs --- src/Benhawker/Pipedrive/Library/Activities.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Activities.php b/src/Benhawker/Pipedrive/Library/Activities.php index 4df1be1..3f067ca 100644 --- a/src/Benhawker/Pipedrive/Library/Activities.php +++ b/src/Benhawker/Pipedrive/Library/Activities.php @@ -85,4 +85,15 @@ public function getByUser(array $data) { return $this->curl->get('activities', $data); } + + /** + * List activities by condition + * + * @param array $data + * @return array return all activities by data fields + */ + public function getList(array $data) + { + return $this->curl->get('activities/list', $data); + } } From dcf1d8d12967b2d7eb98e465ec227f4014fa8a29 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Fri, 10 Nov 2017 15:45:30 +0100 Subject: [PATCH 25/35] PERSONS: - add follower, delete follower --- src/Benhawker/Pipedrive/Library/Persons.php | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Persons.php b/src/Benhawker/Pipedrive/Library/Persons.php index 613f331..ac5a498 100644 --- a/src/Benhawker/Pipedrive/Library/Persons.php +++ b/src/Benhawker/Pipedrive/Library/Persons.php @@ -66,6 +66,7 @@ public function getByEmail($email) * * @param array $data (id, start, limit) * @return array deals + * @throws PipedriveMissingFieldError */ public function deals(array $data) { @@ -82,6 +83,7 @@ public function deals(array $data) * * @param array $data (id, start, limit) * @return array products + * @throws PipedriveMissingFieldError */ public function products(array $data) { @@ -110,6 +112,7 @@ public function update($personId, array $data = array()) * * @param array $data persons detials * @return array returns detials of a person + * @throws PipedriveMissingFieldError */ public function add(array $data) { @@ -141,4 +144,27 @@ public function delete($personId) { return $this->curl->delete('persons/' . $personId); } + + /** + * @param $personId + * @param $followerId + * @return array + */ + public function addFollower($personId, $followerId) + { + return $this->curl->post('persons/' . $personId . '/followers', [ + 'id' => $personId, + 'user_id' => $followerId + ]); + } + + /** + * @param $personId + * @param $followerId + * @return array + */ + public function deleteFollower($personId, $followerId) + { + return $this->curl->delete('persons/' . $personId . '/followers/' . $followerId); + } } From 0823255b4da024e46a76edf1dc24740797724bd5 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Fri, 10 Nov 2017 17:08:01 +0100 Subject: [PATCH 26/35] - list followers methods --- src/Benhawker/Pipedrive/Library/Deals.php | 9 +++++++++ src/Benhawker/Pipedrive/Library/Organizations.php | 9 +++++++++ src/Benhawker/Pipedrive/Library/Persons.php | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index cc42b4a..c4c5918 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -262,4 +262,13 @@ public function deleteFollower($dealId, $userId) { return $this->curl->delete('deals/' . $dealId . '/followers/' . $userId); } + + /** + * @param $dealId + * @return array + */ + public function listFollowers($dealId) + { + return $this->curl->get('deals/' . $dealId . '/followers'); + } } diff --git a/src/Benhawker/Pipedrive/Library/Organizations.php b/src/Benhawker/Pipedrive/Library/Organizations.php index 8b919ba..36ab85d 100644 --- a/src/Benhawker/Pipedrive/Library/Organizations.php +++ b/src/Benhawker/Pipedrive/Library/Organizations.php @@ -143,6 +143,15 @@ public function listPersons($organizationId) return $this->curl->get('organizations/'.$organizationId.'/persons'); } + /** + * @param $organizationId + * @return array + */ + public function listFollowers($organizationId) + { + return $this->curl->get('organizations/' . $organizationId . '/followers'); + } + /** * Add follower to organization. * @param $organizationId diff --git a/src/Benhawker/Pipedrive/Library/Persons.php b/src/Benhawker/Pipedrive/Library/Persons.php index ac5a498..039dacc 100644 --- a/src/Benhawker/Pipedrive/Library/Persons.php +++ b/src/Benhawker/Pipedrive/Library/Persons.php @@ -145,6 +145,11 @@ public function delete($personId) return $this->curl->delete('persons/' . $personId); } + public function listFollowers($personId) + { + return $this->curl->get('persons/' . $personId . '/followers'); + } + /** * @param $personId * @param $followerId From efa2d67cb37619577f4004bcc533487e7930fb45 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Tue, 28 Nov 2017 14:15:17 +0100 Subject: [PATCH 27/35] - delete product from deal - fixed filters getAll supported type check - getAll products, getOne product --- src/Benhawker/Pipedrive/Library/Deals.php | 52 ++++++++++++-------- src/Benhawker/Pipedrive/Library/Filters.php | 12 ++--- src/Benhawker/Pipedrive/Library/Notes.php | 5 +- src/Benhawker/Pipedrive/Library/Persons.php | 28 +++++------ src/Benhawker/Pipedrive/Library/Products.php | 21 +++++++- src/Benhawker/Pipedrive/Pipedrive.php | 8 +-- 6 files changed, 80 insertions(+), 46 deletions(-) diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index c4c5918..0577212 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -35,7 +35,7 @@ public function __construct(\Benhawker\Pipedrive\Pipedrive $master) /** * Returns a deal * - * @param int $id pipedrive deals id + * @param int $id pipedrive deals id * @return array returns details of a deal */ public function getById($id) @@ -49,13 +49,13 @@ public function getById($id) * @param string $name pipedrive deals title * @return array returns details of a deal */ - public function getByName($name, $personId=null, $orgId=null) + public function getByName($name, $personId = null, $orgId = null) { $params = array('term' => $name); - if($personId) { + if ($personId) { $params['person_id'] = $personId; } - if($orgId) { + if ($orgId) { $params['org_id'] = $orgId; } return $this->curl->get('deals/find', $params); @@ -94,11 +94,11 @@ public function add(array $data) return $this->curl->post('deals', $data); } - + /** * Adds a product to a deal * - * @param int $dealId deal id + * @param int $dealId deal id * @param array $data deal and product details * @return array returns details of the deal-product * @throws PipedriveMissingFieldError @@ -131,26 +131,38 @@ public function addProduct($dealId, array $data) */ public function updateProduct($dealId, array $data) { - if(!isset($data['deal_product_id'])){ + if (!isset($data['deal_product_id'])) { throw new PipedriveMissingFieldError('You must include "deal_product_id" field when updating product.'); } - if(!isset($data['item_price'])){ + if (!isset($data['item_price'])) { throw new PipedriveMissingFieldError('You must include "item_price" field when updating product.'); } - if(!isset($data['quantity'])){ + if (!isset($data['quantity'])) { throw new PipedriveMissingFieldError('You must include "quantity" field when updating product'); } - return $this->curl->put('deals/'.$dealId.'/products/'.$data['deal_product_id'], $data); + return $this->curl->put('deals/' . $dealId . '/products/' . $data['deal_product_id'], $data); + } + + /** + * Delete attached product from deal. + * + * @param $dealId + * @param $productAttachmentId + * @return array + */ + public function deleteProduct($dealId, $productAttachmentId) + { + return $this->curl->delete('deals/' . $dealId . '/products/' . $productAttachmentId); } /** * Updates a deal * - * @param int $dealId pipedrives deal Id - * @param array $data new details of deal + * @param int $dealId pipedrives deal Id + * @param array $data new details of deal * @return array returns details of a deal */ public function update($dealId, array $data = array()) @@ -161,8 +173,8 @@ public function update($dealId, array $data = array()) /** * Moves deal to a new stage * - * @param int $dealId deal id - * @param int $stageId stage id + * @param int $dealId deal id + * @param int $stageId stage id * @return array returns details of the deal */ public function moveStage($dealId, $stageId) @@ -179,7 +191,7 @@ public function moveStage($dealId, $stageId) public function delete($dealId) { - return $this->curl->delete('deals/'.$dealId); + return $this->curl->delete('deals/' . $dealId); } @@ -196,21 +208,21 @@ public function bulkDelete($ids) /** * Get deals timeline - * + * */ public function getDealsTimeline($params) { - if(!isset($params['start_date'])){ + if (!isset($params['start_date'])) { throw new PipedriveMissingFieldError('You must include "start_date" when getting deals timeline'); } - if(!isset($params['interval']) || !in_array($params['interval'],['day','week','month','quarter']) ){ + if (!isset($params['interval']) || !in_array($params['interval'], ['day', 'week', 'month', 'quarter'])) { throw new PipedriveMissingFieldError('You must include "interval" when getting deals timeline'); } - if(!isset($params['amount'])){ + if (!isset($params['amount'])) { throw new PipedriveMissingFieldError('You must include "amount" when getting deals timeline'); } - if(!isset($params['field_key'])){ + if (!isset($params['field_key'])) { throw new PipedriveMissingFieldError('You must include "field_key" when getting deals timeline'); } diff --git a/src/Benhawker/Pipedrive/Library/Filters.php b/src/Benhawker/Pipedrive/Library/Filters.php index 047ebcc..1d922cd 100644 --- a/src/Benhawker/Pipedrive/Library/Filters.php +++ b/src/Benhawker/Pipedrive/Library/Filters.php @@ -26,7 +26,7 @@ public function __construct(\Benhawker\Pipedrive\Pipedrive $master) /** * Returns a filter * - * @param int $id filter id + * @param int $id filter id * @return array returns details of filter */ public function getById($id) @@ -74,14 +74,14 @@ public function update($filterId, array $data = array()) public function delete($filterId) { - return $this->curl->delete('filters/'.$filterId); + return $this->curl->delete('filters/' . $filterId); } /** * Bulk delete filters * - * @param $ids comma separated ids + * @param string $ids comma separated ids * @return mixed */ public function bulkDelete($ids) @@ -98,11 +98,11 @@ public function bulkDelete($ids) */ public function getAll($type) { - $supportedTypes = ['deals', 'org', 'people', 'products']; - if(!in_array($type, $supportedTypes)){ + $supportedTypes = ['deals', 'org', 'people', 'products', 'activity']; + if (!in_array($type, $supportedTypes)) { throw new PipedriveMissingFieldError("Unrecognized filter type. Supported types are:" . implode(', ', $supportedTypes)); } - return $this->curl->get('filters', $type); + return $this->curl->get('filters', ['type' => $type]); } } diff --git a/src/Benhawker/Pipedrive/Library/Notes.php b/src/Benhawker/Pipedrive/Library/Notes.php index 4034a99..5604d21 100644 --- a/src/Benhawker/Pipedrive/Library/Notes.php +++ b/src/Benhawker/Pipedrive/Library/Notes.php @@ -31,8 +31,9 @@ public function __construct(\Benhawker\Pipedrive\Pipedrive $master) /** * Adds a note * - * @param array $data note detials - * @return array returns detials of the note + * @param array $data note details + * @return array returns details of the note + * @throws PipedriveMissingFieldError */ public function add(array $data) { diff --git a/src/Benhawker/Pipedrive/Library/Persons.php b/src/Benhawker/Pipedrive/Library/Persons.php index 039dacc..802fd63 100644 --- a/src/Benhawker/Pipedrive/Library/Persons.php +++ b/src/Benhawker/Pipedrive/Library/Persons.php @@ -30,8 +30,8 @@ public function __construct(\Benhawker\Pipedrive\Pipedrive $master) /** * Returns a person * - * @param int $id pipedrive persons id - * @return array returns detials of a person + * @param int $id pipedrive persons id + * @return array returns details of a person */ public function getById($id) { @@ -42,7 +42,7 @@ public function getById($id) * Returns a person / people * * @param string $name pipedrive persons name - * @return array returns detials of a person + * @return array returns details of a person */ public function getByName($name) { @@ -50,11 +50,11 @@ public function getByName($name) } /** - + * Returns a person / people - + * - + * @param string $email pipedrive persons email - + * @return array returns details of a person - + */ + * + * Returns a person / people + * + * + * + * @param string $email pipedrive persons email + * + * @return array returns details of a person + * + */ public function getByEmail($email) { return $this->curl->get('persons/find', array('term' => $email, 'search_by_email' => 1)); @@ -98,9 +98,9 @@ public function products(array $data) /** * Updates a person * - * @param int $personId pipedrives person Id - * @param array $data new detials of person - * @return array returns detials of a person + * @param int $personId pipedrives person Id + * @param array $data new details of person + * @return array returns details of a person */ public function update($personId, array $data = array()) { @@ -111,7 +111,7 @@ public function update($personId, array $data = array()) * Adds a person * * @param array $data persons detials - * @return array returns detials of a person + * @return array returns details of a person * @throws PipedriveMissingFieldError */ public function add(array $data) @@ -137,8 +137,8 @@ public function getAll($params) /** * Deletes a person * - * @param int $personId pipedrives person Id - * @return array returns detials of a person + * @param int $personId pipedrives person Id + * @return array returns details of a person */ public function delete($personId) { diff --git a/src/Benhawker/Pipedrive/Library/Products.php b/src/Benhawker/Pipedrive/Library/Products.php index 8afca4b..f0a2660 100644 --- a/src/Benhawker/Pipedrive/Library/Products.php +++ b/src/Benhawker/Pipedrive/Library/Products.php @@ -1,6 +1,5 @@ curl = $master->curl(); } + /** + * @see https://developers.pipedrive.com/docs/api/v1/#!/Products/get_products + * @param $data + * @return array + */ + public function getAll($data) + { + return $this->curl->get('products', $data); + } + /** * Returns a product / products * @@ -42,4 +51,14 @@ public function getByName($name) return $this->curl->get('products/find', $params); } + /** + * @see https://developers.pipedrive.com/docs/api/v1/#!/Products/get_products_id + * @param $productId + * @return array + */ + public function getOne($productId) + { + return $this->curl->get('products/' . $productId); + } + } diff --git a/src/Benhawker/Pipedrive/Pipedrive.php b/src/Benhawker/Pipedrive/Pipedrive.php index 5ba32b9..5be1983 100644 --- a/src/Benhawker/Pipedrive/Pipedrive.php +++ b/src/Benhawker/Pipedrive/Pipedrive.php @@ -1,4 +1,6 @@ Date: Tue, 9 Jan 2018 15:29:35 +0100 Subject: [PATCH 28/35] - stages support --- src/Benhawker/Pipedrive/Library/Stages.php | 63 ++++++++++++++++++++++ src/Benhawker/Pipedrive/Pipedrive.php | 20 ++++++- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/Benhawker/Pipedrive/Library/Stages.php diff --git a/src/Benhawker/Pipedrive/Library/Stages.php b/src/Benhawker/Pipedrive/Library/Stages.php new file mode 100644 index 0000000..708083b --- /dev/null +++ b/src/Benhawker/Pipedrive/Library/Stages.php @@ -0,0 +1,63 @@ +curl = $master->curl(); + } + + /** + * If pipeline_id is ommited, + * all stages from all pipelines will be returned. + * + * @param null $pipeline_id + * @return array + */ + public function getAll($pipeline_id = null) + { + return $this->curl->get('stages', ['pipeline_id' => null]); + } + + /** + * Returns a stage + * + * @param int $id pipedrive stage id + * @return array returns details of a stage + */ + public function getById($id) + { + return $this->curl->get('stages/' . $id); + } + + /** + * Get all deals in stage + * + * @param $stage_id + * @param array $params + * @return array + */ + public function getDealsInStage($stage_id, $params = []) + { + return $this->curl->get('stages/' . $stage_id . '/deals', $params); + } + +} \ No newline at end of file diff --git a/src/Benhawker/Pipedrive/Pipedrive.php b/src/Benhawker/Pipedrive/Pipedrive.php index 5be1983..da11a3a 100644 --- a/src/Benhawker/Pipedrive/Pipedrive.php +++ b/src/Benhawker/Pipedrive/Pipedrive.php @@ -2,8 +2,9 @@ use Benhawker\Pipedrive\Library\Organizations; use Benhawker\Pipedrive\Library\Products; use Benhawker\Pipedrive\Library\SearchResults; +use Benhawker\Pipedrive\Library\Stages; - /** +/** * Pipedrive API wrapper class v0.1 * * Author: Ben Hawker (ben@tickettoridegroup.com) 2014 @@ -107,6 +108,12 @@ class Pipedrive */ protected $searchResults; + /** + * Placeholder attribute for Pipedrive Stages class + * @var Stages Object + */ + protected $stages; + /** * Set up API url and load library classes * @@ -139,6 +146,7 @@ public function __construct($apiKey = '', $protocol = 'https', $host = 'api.pipe $this->products = new Library\Products($this); $this->searchResults = new Library\SearchResults($this); $this->filters = new Library\Filters($this); + $this->stages = new Stages($this); } /** @@ -238,4 +246,14 @@ public function searchResults() { return $this->searchResults; } + + /** + * Returns the Pipedrive Stages Object + * @return Stages + */ + public function stages() + { + return $this->stages; + } + } From 690ecb2f20fddf53f7392df161bb59ebf5a99a3d Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Wed, 24 Jan 2018 17:05:54 +0100 Subject: [PATCH 29/35] - deal flow method --- src/Benhawker/Pipedrive/Library/Deals.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index 0577212..0d1f275 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -283,4 +283,14 @@ public function listFollowers($dealId) { return $this->curl->get('deals/' . $dealId . '/followers'); } + + /** + * @param $dealId + * @param array $params + * @return array + */ + public function flow($dealId, $params = []) + { + return $this->curl->get('deals/' . $dealId . '/flow', $params); + } } From bc25383cca1ce6881fd3856e59f560fc5fd0840f Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Fri, 26 Jan 2018 13:28:13 +0100 Subject: [PATCH 30/35] - increased curl timeout from 8kms to 14kms --- src/Benhawker/Pipedrive/Library/Curl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Benhawker/Pipedrive/Library/Curl.php b/src/Benhawker/Pipedrive/Library/Curl.php index 17d352e..1c0716c 100644 --- a/src/Benhawker/Pipedrive/Library/Curl.php +++ b/src/Benhawker/Pipedrive/Library/Curl.php @@ -44,7 +44,7 @@ public function __construct($url, $apiKey) $this->setOpt(CURLOPT_USERAGENT, self::USER_AGENT) ->setOpt(CURLOPT_HEADER, false) ->setOpt(CURLOPT_RETURNTRANSFER, true) - ->setOpt(CURLOPT_TIMEOUT_MS, 8000) + ->setOpt(CURLOPT_TIMEOUT_MS, 15000) ->setOpt(CURLOPT_HTTPHEADER, array("Accept: application/json")); } From dd778ebeca17db7f016f65b74e8b2854e4035d41 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Fri, 26 Jan 2018 14:42:08 +0100 Subject: [PATCH 31/35] - deals summary --- src/Benhawker/Pipedrive/Library/Deals.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Deals.php b/src/Benhawker/Pipedrive/Library/Deals.php index 0d1f275..ff5ab95 100644 --- a/src/Benhawker/Pipedrive/Library/Deals.php +++ b/src/Benhawker/Pipedrive/Library/Deals.php @@ -293,4 +293,13 @@ public function flow($dealId, $params = []) { return $this->curl->get('deals/' . $dealId . '/flow', $params); } + + /** + * @param array $params + * @return array + */ + public function summary($params = []) + { + return $this->curl->get('deals/summary', $params); + } } From d0366449f99c703c9a4895ce5997b96e98e51cdb Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Mon, 26 Feb 2018 09:56:36 +0100 Subject: [PATCH 32/35] - notes methods --- src/Benhawker/Pipedrive/Library/Notes.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Notes.php b/src/Benhawker/Pipedrive/Library/Notes.php index 5604d21..4716766 100644 --- a/src/Benhawker/Pipedrive/Library/Notes.php +++ b/src/Benhawker/Pipedrive/Library/Notes.php @@ -49,4 +49,26 @@ public function add(array $data) return $this->curl->post('notes', $data); } + + /** + * Get All Notes By Params + * + * @param array $params + * @return array + */ + public function getAll(array $params) + { + return $this->curl->get('notes/', $params); + } + + /** + * Get single note by ID + * + * @param $noteId + * @return array + */ + public function getOne($noteId) + { + return $this->curl->get('notes/' . $noteId); + } } From 7771788f70868fd50b7f7610a1dd3a73c0a53d6c Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Fri, 4 May 2018 14:15:00 +0200 Subject: [PATCH 33/35] - summary methods --- src/Benhawker/Pipedrive/Library/Organizations.php | 9 +++++++++ src/Benhawker/Pipedrive/Library/Persons.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Organizations.php b/src/Benhawker/Pipedrive/Library/Organizations.php index 36ab85d..d6a70d1 100644 --- a/src/Benhawker/Pipedrive/Library/Organizations.php +++ b/src/Benhawker/Pipedrive/Library/Organizations.php @@ -176,4 +176,13 @@ public function deleteFollower($organizationId, $userId) { return $this->curl->delete('organizations/' . $organizationId . '/followers/' . $userId); } + + /** + * @param array $params + * @return array + */ + public function summary($params = []) + { + return $this->curl->get('organizations/summary', $params); + } } diff --git a/src/Benhawker/Pipedrive/Library/Persons.php b/src/Benhawker/Pipedrive/Library/Persons.php index 802fd63..3caedf1 100644 --- a/src/Benhawker/Pipedrive/Library/Persons.php +++ b/src/Benhawker/Pipedrive/Library/Persons.php @@ -172,4 +172,13 @@ public function deleteFollower($personId, $followerId) { return $this->curl->delete('persons/' . $personId . '/followers/' . $followerId); } + + /** + * @param array $params + * @return array + */ + public function summary($params = []) + { + return $this->curl->get('persons/summary', $params); + } } From f6d3d6dfafd6e303039dd7f0cfc82fbfca452b7b Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Wed, 30 May 2018 16:44:49 +0200 Subject: [PATCH 34/35] - persons/id/activities --- src/Benhawker/Pipedrive/Library/Persons.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Persons.php b/src/Benhawker/Pipedrive/Library/Persons.php index 3caedf1..4e355f1 100644 --- a/src/Benhawker/Pipedrive/Library/Persons.php +++ b/src/Benhawker/Pipedrive/Library/Persons.php @@ -181,4 +181,18 @@ public function summary($params = []) { return $this->curl->get('persons/summary', $params); } + + /** + * @param array $params + * @return array + * @throws PipedriveMissingFieldError + */ + public function listActivities(array $params) + { + //if there is no id set throw error as it is a required field + if (!isset($data['id'])) { + throw new PipedriveMissingFieldError('You must include the "id" of the person when getting activities'); + } + return $this->curl->get('persons/' . $params['id'] . '/activities', $params); + } } From 8a39e860fd3f4d6edd967e095c666266eecbaba0 Mon Sep 17 00:00:00 2001 From: Antun Tomasevic Date: Wed, 5 Sep 2018 16:38:25 +0200 Subject: [PATCH 35/35] - organizations/id/activities --- src/Benhawker/Pipedrive/Library/Organizations.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Benhawker/Pipedrive/Library/Organizations.php b/src/Benhawker/Pipedrive/Library/Organizations.php index d6a70d1..318dfdc 100644 --- a/src/Benhawker/Pipedrive/Library/Organizations.php +++ b/src/Benhawker/Pipedrive/Library/Organizations.php @@ -185,4 +185,15 @@ public function summary($params = []) { return $this->curl->get('organizations/summary', $params); } + + /** + * List activities associated with organization + * @param $organizationId + * @param array $data + * @return array + */ + public function listActivities($organizationId, array $data = []) + { + return $this->curl->get('organizations/' . $organizationId . '/activities', $data); + } }