/** * Generic function for getting something and return the Json response * * @param $end_point * @return string */ protected function getInJson($end_point) { $end_point = strtolower($end_point); if (strpos($end_point, 'http') !== 0) { $end_point = $this->api->getApiUrl() . $end_point; } $request = $this->api->get($end_point); $response = $this->processRequest($request); $result = $response->json(); return $result; }
/** * Generic function for getting one entity * * @param $end_point * @return \Dlin\Zendesk\Entity\BaseEntity */ protected function getOne($end_point) { $end_point = strtolower($end_point); if (strpos($end_point, 'http') !== 0) { $end_point = $this->api->getApiUrl() . $end_point; } $request = $this->api->get($end_point); $response = $this->processRequest($request); $result = $response->json(); $type = $this->getType(); $className = explode('\\', $type); $baseName = strtolower(end($className)); if ($result && isset($result[$baseName])) { $t = new $type(); $t->setManagingClient($this); return $t->fromArray($result[$baseName]); } return null; }
public function testClient() { $api = new ZendeskApi('*****@*****.**', 'e6EFbHZ7YdggbIMSvOqiq3HduOLljaV7DSgexzoc', 'https://subdomain.zendesk.com/api/v2/'); $resp = $api->get('tickets.json')->send(); $this->assertArrayHasKey('tickets', $resp->json()); }