From d162807d8884cbf371d7c02ac2709826a4bd9f5a Mon Sep 17 00:00:00 2001 From: Brad Pitcher Date: Tue, 25 Apr 2017 17:00:54 -0700 Subject: [PATCH] add some contacts API methods --- README.md | 37 +++++++++++++++++++++++++++++++++++-- lib/SurveyMonkey.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4140cef..3dea0bc 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,11 @@ All methods return an array containing a **success** boolean, and the **data** - Advanced ---- ``` -$SM = new SurveyMonkey("myApiKey" , "myAccessToken", +$SM = new SurveyMonkey("myApiKey" , "myAccessToken", array( // Override default API options (quite useless at the moment) 'protocol' => 'http', // will not work.. they require SSL 'hostname' => 'fake-api.surveymonkey.net' // will also not work.. - ), + ), array( // CURL override options CURLOPT_SSL_VERIFYPEER => false // Better add cacert.pam, no? // ...... @@ -75,6 +75,39 @@ public function getSurveyDetails($surveyId, $params = array()){} public function getCollectorList($surveyId, $params = array()){} ``` +**getContacts** +``` +/** + * Returns a list of contacts + * @see https://developer.surveymonkey.com/api/v3/#contacts-and-contact-lists + * @param array $params optional request array + * @return array Results + */ +public function getContacts($params = array()){} +``` + +**getContactDetails** +``` +/** + * Gets the details for a contact + * @see https://developer.surveymonkey.com/api/v3/#contacts-and-contact-lists + * @param string $contactId Contact ID + * @return array Result + */ +public function getContactDetails($contactId){} +``` + +**deleteContact** +``` +/** + * Deletes a contact + * @see https://developer.surveymonkey.com/api/v3/#contacts-and-contact-lists + * @param string $contactId Contact ID + * @return array Result + */ +public function deleteContact($contactId){} +``` + **getRespondentList** ``` /** diff --git a/lib/SurveyMonkey.php b/lib/SurveyMonkey.php index c2185bb..24af16f 100644 --- a/lib/SurveyMonkey.php +++ b/lib/SurveyMonkey.php @@ -335,6 +335,39 @@ public function getCollectorList($surveyId, $params = array()) { return $this->run('surveys/' . $surveyId . '/collectors', $params, 'GET'); } + + /** + * Returns a list of contacts + * @see https://developer.surveymonkey.com/api/v3/#contacts-and-contact-lists + * @param array $params optional request array + * @return array Results + */ + public function getContacts($params = array()) + { + return $this->run('contacts', $params, "GET"); + } + + /** + * Gets the details for a contact + * @see https://developer.surveymonkey.com/api/v3/#contacts-and-contact-lists + * @param string $contactId Contact ID + * @return array Result + */ + public function getContactDetails($contactId) + { + return $this->run('contacts/' . $contactId, array(), "GET"); + } + + /** + * Deletes a contact + * @see https://developer.surveymonkey.com/api/v3/#contacts-and-contact-lists + * @param string $contactId Contact ID + * @return array Result + */ + public function deleteContact($contactId) + { + return $this->run('contacts/' . $contactId, array(), "DELETE"); + } } /**