ConfigInterface
in
Interface to manage billing server API cinfiguration
Billing use this interface to know where to connect, store account, set HTTP(s) call options, e.t.c.
Table of Contents
- API_BASE = '/rest'
- override to use other API base on the same host
- ESPF_BASE = '/espf/v1'
- override to use other ESPF base on the same host
- LOGIN = 'login'
- Array key for login/username of account array
- PASSWORD = 'password'
- Array key for password of account array. Sould be used either password or token
- SCHEME = 'https'
- override in a case of need to use other scheme, example 'http'
- TOKEN = 'token'
- Array key for token of account array. Sould be used either password or token
- getAccount() : array<string|int, mixed>
- Provides account record or throw PortaAuthException if there no record inside.
- getBaseApiRequest() : RequestInterface
- Returns base API psr-7 request object with base path + given path
- getBaseEspfRequest() : RequestInterface
- Returns base ESPF psr-7 request of given type with base path + given path
- getCache() : CacheInterface
- Returns PSR-16 caching object to store persistent session data
- getCacheTag() : string
- Return cache tag to use for session storage object in the cache
- getClientAdaptor() : ClientAdapterInterface
- Returns ClientAdaptor for currently configured client
- getSessionRefreshMargin() : int
- Returns margin to token expire time triggering token refresh procedure.
- getStream() : StreamInterface
- Returns psr-7 Stream object created with given string
- 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
- setCacheTag() : ClientAdapterInterface
- Sets cache tag to use for session storage object in the cache
- setSessionRefreshMargin() : self
- Set margin to token expire time triggering token refresh procedure.
Constants
API_BASE
override to use other API base on the same host
public
mixed
API_BASE
= '/rest'
ESPF_BASE
override to use other ESPF base on the same host
public
mixed
ESPF_BASE
= '/espf/v1'
LOGIN
Array key for login/username of account array
public
mixed
LOGIN
= 'login'
PASSWORD
Array key for password of account array. Sould be used either password or token
public
mixed
PASSWORD
= 'password'
SCHEME
override in a case of need to use other scheme, example 'http'
public
mixed
SCHEME
= 'https'
TOKEN
Array key for token of account array. Sould be used either password or token
public
mixed
TOKEN
= 'token'
Methods
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
getBaseApiRequest()
Returns base API psr-7 request object with base path + given path
public
getBaseApiRequest([string $path = '' ]) : RequestInterface
Uses known factory to create base POST request with API base path and given extra path.
Parameters
- $path : string = ''
-
extra path to append after API prefix path
Return values
RequestInterface —base Request object, filled with URI
getBaseEspfRequest()
Returns base ESPF psr-7 request of given type with base path + given path
public
getBaseEspfRequest(string $method[, string $path = '' ]) : RequestInterface
Parameters
- $method : string
-
request method to use
- $path : string = ''
-
extra path to append after API prefix path
Return values
RequestInterface —Base Request object of given type, filled with URI
getCache()
Returns PSR-16 caching object to store persistent session data
public
getCache() : CacheInterface
Return values
CacheInterface —getCacheTag()
Return cache tag to use for session storage object in the cache
public
getCacheTag() : string
Return values
string —getClientAdaptor()
Returns ClientAdaptor for currently configured client
public
getClientAdaptor() : ClientAdapterInterface
Return values
ClientAdapterInterface —getSessionRefreshMargin()
Returns margin to token expire time triggering token refresh procedure.
public
getSessionRefreshMargin() : int
Default token expire is +48h from issue time, default margin is 3600 (1h) and a good for an app where you have more then one call in each hour.
Please mind that billing also has inactivity timer, 24h by default, which invalidates tocken even it is not yet expired.
Return values
int —seconds before token expire time to trigger refresh
getStream()
Returns psr-7 Stream object created with given string
public
getStream([string $content = '' ]) : StreamInterface
Parameters
- $content : string = ''
-
conten of the Stream
Return values
StreamInterface —Stream object, filled with content
hasAccount()
Returns true if accound record present in the config and it's correct.
public
hasAccount() : bool
Billing classes rely on account data is checked for consistency in the ConfigInterface class. Consistency mean that a pair of login+password or login+token present.
Billing class will not check it and send as is, generating API failure if the data is wrong.
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
setCacheTag()
Sets cache tag to use for session storage object in the cache
public
setCacheTag(string $tag) : ClientAdapterInterface
Parameters
- $tag : string
Return values
ClientAdapterInterface —self mutable object for chaining
setSessionRefreshMargin()
Set margin to token expire time triggering token refresh procedure.
public
setSessionRefreshMargin(int $margin) : self
Default token expire is +48h from issue time, default margin is 3600 (1h) and a good for an app where you have more then one call in each hour.
Please mind that billing also has inactivity timer, 24h by default, which invalidates tocken even it is not yet expired.
Parameters
- $margin : int
-
token refresh margin in seconds
Return values
self —for chaining