Create a new instance:
$ihasco = Ihasco\ClientSDK\Manager::create('your-api-key');
All calls to the API return either a Ihasco\ClientSDK\Responses\Response
object or throw a Ihasco\ClientSDK\Exceptions\Exception
.
$response = $ihasco->programmes->all();
$allProgrammes = $response->getData();
Returns an array of Ihasco\ClientSDK\Responses\Programme
objects
$response = $ihasco->programmes->one(int $programmeId);
$oneProgramme = $response->getData();
Returns a single Ihasco\ClientSDK\Responses\Programme
object
$response = $ihasco->results->all();
$allResults = $response->getData();
Returns an array of Ihasco\ClientSDK\Responses\Result
objects
$response = $ihasco->results->one(int $resultId);
$oneResult = $response->getData();
Returns a single Ihasco\ClientSDK\Responses\Result
object
$response = $ihasco->users->all();
$allUsers = $response->getData();
Returns an array of Ihasco\ClientSDK\Responses\User
objects
Supply a userId or email address
$response = $ihasco->users->one(mixed $userId);
$oneUser = $response->getData();
Returns a single Ihasco\ClientSDK\Responses\User
object
$response = $ihasco->users->results(mixed $resultId, int $cursor = null);
$allResults = $response->getData();
Returns an array of Ihasco\ClientSDK\Responses\Result
objects
Send data as per api spec
$response = $ihasco->users->create(array $userData);
$oneUser = $response->getData();
Returns a single Ihasco\ClientSDK\Responses\User
object
Send data as per api spec
$response = $ihasco->users->update(int $userId, array $userData);
$oneUser = $response->getData();
Returns a single Ihasco\ClientSDK\Responses\User
object
$response = $users->delete(int $id);
Anything other than a 2xx response will result in a Ihasco\ClientSDK\Exceptions\Exception
being thrown. Possible exceptions are as follows:
try {
$response = $ihasco->programmes->all();
} catch(Ihasco\ClientSDK\Exceptions\CannotConnect $e) {
// Cannot connect to server
} catch(Ihasco\ClientSDK\Exceptions\CannotAuthenticate $e) {
// Bad API key
} catch(Ihasco\ClientSDK\Exceptions\InvalidResource $e) {
// Non-existent resource
} catch(Ihasco\ClientSDK\Exceptions\ServerError $e) {
// Something went wrong on the server
} catch(Ihasco\ClientSDK\Exceptions\BadMethod $e) {
// Invalid HTTP method
} catch(Ihasco\ClientSDK\Exceptions\ValidationError $e) {
// Something wrong with your submission
var_dump($e->getErrors());
} catch(Exception $e) {
// something else
}
$hasPagination = $response->hasPagination(); // boolean
$nextPage = $response->getNextPage(); // Response or null
$prevPage = $response->getPrevPage(); // Response or null