Config
in package
implements
ConfigInterface
Porta-API configuration class
Interfaces, Classes, Traits and Enums
- ConfigInterface
- Interface to manage billing server API cinfiguration
Table of Contents
- __construct() : mixed
- Setup configuration object
- getAccount() : array<string|int, mixed>
- Provides account record or throw PortaAuthException if there no record inside.
- getAPIPath() : string
- Provides API base path, default is '/rest', no trailig slash
- getEspfPath() : string
- Provides ESPF base path, default is '/espf/v1', no trailig slash
- getOptions() : array<string|int, mixed>
- Provides Gizzle http call options
- getSessionRefreshMargin() : int
- Returns margin to token expire time triggering token refresh procedure.
- getUrl() : string
- Provides base server URI for all services like `'https://host.dom'`, no trailing slash.
- hasAccount() : bool
- Returns true if accound record present in the config and it's correct.
- setAccount() : self
- Sets account record. Exception if the record is inconsistent
- setOptions() : self
- Replace Guzzle http call options with a new set
Methods
__construct()
Setup configuration object
public
__construct(string $host[, array<string|int, mixed>|null $account = null ][, array<string|int, mixed> $options = [] ][, int $refreshMargin = 3600 ]) : mixed
Parameters
- $host : string
-
Hostname/IP address of the server, no slashes, no schema, but port if required. Example:
bill-sip.mycompany.com - $account : array<string|int, mixed>|null = null
-
Account record to login to the billing. Combination of login+password or login+token required
$account = [ 'login' => 'myUserName', // Mandatory username 'password' => 'myPassword', // When login with password 'token' => 'myToken' // When login with API token - $options : array<string|int, mixed> = []
-
oprions, passed to Guzzle HTTP client. Check Guzzle docs
Please, mind that Guzze options only apply at the moment of wrapper class creation by it's __construct(), so if options set after the wrapper created - it will not be used.
- $refreshMargin : int = 3600
-
margin in seconds before token expire time to trigger token refresh procedure.
Tags
Return values
mixed —getAccount()
Provides account record or throw PortaAuthException if there no record inside.
public
getAccount() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —must have a pair of keys: account+password or account+token
getAPIPath()
Provides API base path, default is '/rest', no trailig slash
public
getAPIPath() : string
Tags
Return values
string —getEspfPath()
Provides ESPF base path, default is '/espf/v1', no trailig slash
public
getEspfPath() : string
Tags
Return values
string —getOptions()
Provides Gizzle http call options
public
getOptions() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —to be passed to Guzzle
getSessionRefreshMargin()
Returns margin to token expire time triggering token refresh procedure.
public
getSessionRefreshMargin() : int
Tags
Return values
int —seconds before token expire time to trigger refresh
getUrl()
Provides base server URI for all services like `'https://host.dom'`, no trailing slash.
public
getUrl() : string
Tags
Return values
string —hasAccount()
Returns true if accound record present in the config and it's correct.
public
hasAccount() : bool
Tags
Return values
bool —setAccount()
Sets account record. Exception if the record is inconsistent
public
setAccount([array<string|int, mixed>|null $account = null ]) : self
Parameters
- $account : array<string|int, mixed>|null = null
-
must have a pair of keys: 'account'+'password' or 'account'+'token', null to clear account record out.
Tags
Return values
self —for chaining
setOptions()
Replace Guzzle http call options with a new set
public
setOptions(array<string|int, mixed> $options) : self
Parameters
- $options : array<string|int, mixed>
-
- new options set
Tags
Return values
self —- for chaining