src/API/Programs.php
<?php
namespace EventFarm\Marketo\API;
use EventFarm\Marketo\RestClient\MarketoRestClient;
class Programs
{
/**
* @var MarketoClientInterface
*/
private $marketoRestClient;
public function __construct(MarketoRestClient $marketoRestClient)
{
$this->marketoRestClient = $marketoRestClient;
}
public function getPrograms(array $options = array())
{
$endpoint = '/rest/asset/v1/programs.json?maxReturn=200';
foreach ($options as $key => $value) {
if (!empty($key)) {
$endpoint = strpos($endpoint, '.json?') ? $endpoint . '&' : $endpoint . '?';
$endpoint = $endpoint . $key . '=' . $value;
}
}
try {
$response = $this->marketoRestClient->request('get', $endpoint);
return $this->marketoRestClient->getBodyObjectFromResponse($response);
} catch (MarketoException $e) {
print_r('Unable to get programs: ' . $e);
}
}
}