Client
in package
A forge-dashboard API client (github.com/alrayyes/forge-dashboard).
Every operation except HealthApi::health(), HealthApi::getVersion()
and the two webhook receivers (WebhooksApi) requires an
authenticated session. forge-dashboard accepts either a browser's
passkey session cookie or a personal API token
(Authorization: Bearer <token>, minted via POST /api/tokens) -- this
client only speaks the token half, the headless-friendly one. Pass it
to the constructor or set self::API_TOKEN_ENV_VAR. See the
README for the full explanation and an example.
Each generated Api class is exposed as a public, readonly property (self::$dashboard, self::$tokens, ...) for direct, one-response-at-a-time calls -- forge-dashboard's spec has no pagination to wrap.
Table of Contents
Constants
- API_TOKEN_ENV_VAR : mixed = 'FORGE_DASHBOARD_API_TOKEN'
- Environment variable the constructor falls back to when no API token is passed explicitly.
Properties
- $admin : AdminApi
- $auth : AuthApi
- $dashboard : DashboardApi
- $health : HealthApi
- $pullRequests : PullRequestsApi
- $settings : SettingsApi
- $sharing : SharingApi
- $tokens : TokensApi
- $webhooks : WebhooksApi
Methods
- __construct() : mixed
- buildGuzzleClient() : Client
Constants
API_TOKEN_ENV_VAR
Environment variable the constructor falls back to when no API token is passed explicitly.
public
mixed
API_TOKEN_ENV_VAR
= 'FORGE_DASHBOARD_API_TOKEN'
Properties
$admin
public
AdminApi
$admin
$auth
public
AuthApi
$auth
$dashboard
public
DashboardApi
$dashboard
$health
public
HealthApi
$health
$pullRequests
public
PullRequestsApi
$pullRequests
$settings
public
SettingsApi
$settings
$sharing
public
SharingApi
$sharing
$tokens
public
TokensApi
$tokens
$webhooks
public
WebhooksApi
$webhooks
Methods
__construct()
public
__construct(string $baseUrl[, string|null $apiToken = null ][, ClientInterface|null $httpClient = null ][, HandlerStack|null $handlerStack = null ][, int $maxRetries = 3 ][, float $retryBaseDelaySeconds = 0.25 ]) : mixed
Parameters
- $baseUrl : string
-
the forge-dashboard instance's origin, e.g. "https://forge-dashboard.example.com"
- $apiToken : string|null = null
-
overrides self::API_TOKEN_ENV_VAR when given
- $httpClient : ClientInterface|null = null
-
replaces the underlying Guzzle client entirely (a test double, usually); when given, the retry and auth-injection middleware below are not applied, and $handlerStack/$maxRetries/$retryBaseDelaySeconds are ignored -- the caller owns that behaviour instead
- $handlerStack : HandlerStack|null = null
-
the base handler stack the retry and auth-injection middleware get pushed onto -- pass a stack built around a MockHandler in a test to exercise both against a fake transport. Defaults to a fresh HandlerStack::create() (the real cURL/stream handler). Ignored when $httpClient is given.
- $maxRetries : int = 3
-
additional attempts after the first, for a 429/5xx or network failure
- $retryBaseDelaySeconds : float = 0.25
-
the starting backoff before jitter and any server-sent Retry-After
buildGuzzleClient()
private
buildGuzzleClient(HandlerStack $stack, string|null $token, int $maxRetries, float $baseDelaySeconds) : Client
Parameters
- $stack : HandlerStack
- $token : string|null
- $maxRetries : int
- $baseDelaySeconds : float