Firebrand\Hail\Api\Client
API client for the Hail Api
It uses Guzzle HTTP Client to communicate with Hail
An Client ID and a Client Secret must be provided in your .env file for HailAPI
Errors are shown in the CMS via session variables and logged to file
- Author: Marc Espiard, Firebrand
Synopsis
class Client
{
- // members
- private $client_id;
- private $client_secret;
- private $access_token;
- private $access_token_expire;
- private $refresh_token;
- private $user_id;
- private $orgs_ids;
- private string $scopes = "user.basic content.read";
- // methods
- public void __construct()
- public array get()
- public array getOne()
- public void fetchAccessToken()
- public void getHTTPClient()
- public void getApiBaseURL()
- public void getRedirectURL()
- public void setAccessTokenExpire()
- public void setRefreshToken()
- public void handleException()
- public string getAuthorizationURL()
- public void setUserID()
- public string getAccessToken()
- public void setAccessToken()
- public void refreshAccessToken()
- public boolean isAuthorised()
- public boolean isReadyToAuthorised()
- public array getAvailableOrganisations()
- public array|boolean getAvailablePrivateTags()
- public array|boolean getAvailablePublicTags()
- public static int getRefreshRate()
- public array getImagesByArticles()
- public array getVideosByArticles()
Hierarchy
Uses
- SilverStripe\Core\Config\Configurable
Members
private
- $access_token
- $access_token_expire
- $client_id
- $client_secret
- $orgs_ids
- $refresh_token
- $scopes
- $user_id
Methods
public
- __construct()
- fetchAccessToken() — Fetch OAuth Access token from the HAil API
- get() — Send a GET request to the Hail API for a specific URI and returns the results. Extra parameters can be passed with the $body variable.
- getAccessToken() — Get current Hail API OAuth Access token Will refresh the token from the API if it has expired
- getApiBaseURL() — Get Hail API base URL from yml config
- getAuthorizationURL() — Build Hail API Authorization URL
- getAvailableOrganisations() — Get all available Hail Organisation the configured client has access to
- getAvailablePrivateTags() — Get all available Private Tags from the Hail API Will get all tags from all configured organisations unless specified otherwise
- getAvailablePublicTags() — Get all available Public Tags from the Hail API Will get all tags from all configured organisations unless specified otherwise
- getHTTPClient() — Create a new Guzzle HTTP Client
- getImagesByArticles() — Retrieve a list of images for a given article.
- getOne() — Get one Hail object from the API
- getRedirectURL() — Get Redirect URL Hail OAuth uses after authorization
- getRefreshRate() — Get the refresh rate in seconds for Hail Objects. Hail Object that have not been retrieve for longer than the refresh rate, should be fetched again.
- getVideosByArticles() — Retrieve a list of videos for a given article.
- handleException() — Silently handle Hail API HTTP Exception to avoid CMS crashes Stores error message in a session variable for CMS display
- isAuthorised() — Check if the Hail module is Authorized with the Hail API
- isReadyToAuthorised() — Check if the Hail module is ready to be authorized with the Hail API
- refreshAccessToken() — Refresh Hail API OAuth Access token from the API
- setAccessToken() — Set Hail API OAuth token in the current SiteConfig
- setAccessTokenExpire() — Set Hail API OAuth access token expiry time in current SiteConfig
- setRefreshToken() — Set Hail API OAuth refresh token in current SiteConfig
- setUserID() — Get Hail User ID from the API and set it in the current SiteConfig