From d5803bc65ec72b7078324870bc6c81c9ecf565a0 Mon Sep 17 00:00:00 2001 From: txm241 Date: Mon, 10 Oct 2016 16:30:43 -0400 Subject: [PATCH] Added all describe calls to repo --- src/Client.php | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ src/service.json | 8 ++++ 2 files changed, 106 insertions(+) diff --git a/src/Client.php b/src/Client.php index eec03b9..513fc7c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -40,6 +40,17 @@ */ class Client extends GuzzleClient { + /** + * @var array + */ + private $marketoObjects = array( + 'Leads' => 'leads', + 'Companies' => 'companies', + 'Opportunities' => 'opportunities', + 'Opportunities Roles' => 'opportunities/roles', + 'Sales Persons' => 'salespersons' + ); + /** * {@inheritdoc} */ @@ -684,6 +695,93 @@ public function approveEmail($emailId, $args = array(), $returnRaw = false) return $this->getResult('approveEmailbyId', $args, false, $returnRaw); } + /** + * Describe the leads object + * + * @param bool|false $returnRaw + * @throws \Exception + * + * @link http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Leads/describeUsingGET_2 + * + * @return Response + */ + public function describeLeads($returnRaw = false) { + return $this->describeObject('Leads', $returnRaw); + } + + /** + * Describe the opportunities object + * + * @param bool|false $returnRaw + * @throws \Exception + * + * @link http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Opportunities/describeUsingGET_3 + * + * @return Response + */ + public function describeOpportunities($returnRaw = false) { + return $this->describeObject('Opportunities', $returnRaw); + } + + /** + * Describe the opportunities roles object + * + * @param bool|false $returnRaw + * @throws \Exception + * + * @link http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Opportunities/describeOpportunityRoleUsingGET + * + * @return Response + */ + public function describeOpportunityRoles($returnRaw = false) { + return $this->describeObject('Opportunities Roles', $returnRaw); + } + + /** + * Describe the companies object + * + * @param bool|false $returnRaw + * @throws \Exception + * + * @link http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Companies/describeUsingGET + * + * @return Response + */ + public function describeCompanies($returnRaw = false) { + return $this->describeObject('Companies', $returnRaw); + } + + /** + * Describe the Sales Persons object + * + * @param bool|false $returnRaw + * @throws \Exception + * + * @link http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Sales_Persons/describeUsingGET_4 + * + * @return Response + */ + public function describeSalesPersons($returnRaw = false) { + return $this->describeObject('Sales Persons', $returnRaw); + } + + /** + * Generic method to describe a Marketo object + * + * @param string $objectName + * @param bool|false $returnRaw + * @return Response + * @throws \Exception + */ + private function describeObject($objectName, $returnRaw = false) { + if (!isset($this->marketoObjects[$objectName])) { + throw new \Exception('Expected parameter $objectName, to be a valid Marketo object ' . "but $objectName provided"); + }; + + $args['objectName'] = $this->marketoObjects[$objectName]; + return $this->getResult('describeObject', $args, false, $returnRaw); + } + /** * Internal helper method to actually perform command. * diff --git a/src/service.json b/src/service.json index 80d2709..f691d9b 100644 --- a/src/service.json +++ b/src/service.json @@ -247,6 +247,14 @@ "id": {"location": "uri"} }, "responseClass": "CSD\\Marketo\\Response\\ApproveEmailResponse" + }, + "describeObject": { + "httpMethod": "GET", + "uri": "/rest/v1/{objectName}/describe.json", + "parameters": { + "objectName": {"location": "uri"} + }, + "responseClass": "CSD\\Marketo\\Response" } } }