Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand Down Expand Up @@ -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.
*
Expand Down
8 changes: 8 additions & 0 deletions src/service.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}