abstract class Apis \ Api

All known direct subclasses:
CachedApi,ApiListApi


Method Summary

Name Description
getEndpoint()
getJSON($arguments) Compile the JSON with the given arguments, as parsed from the #getEndpoint() string.
render($arguments) Try and get the JSON result for this API, and return either {success: true: result: $json} or {success: false, error: $message} if an exception occured.

abstract function getEndpoint()

Returns:
e.g. "/api/v1/currency/:currency"

abstract function getJSON($arguments)

Compile the JSON with the given arguments, as parsed from the #getEndpoint() string.


public function render($arguments)

Try and get the JSON result for this API, and return either {success: true: result: $json} or {success: false, error: $message} if an exception occured.

This means this Api can be used directly with openclerk/routing as a route callback:

 foreach (DiscoveredComponents\Apis::getAllInstances() as $uri => $handler) { \Openclerk\Router::addRoutes(array( $uri => $handler, )); } 

If openclerk/exceptions is installed, logs a new uncaught CaughtApiException if there was an exception that occured.

Caching can be achieved with a CachedApi.