PortaBilling API

ConfigInterface

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.
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

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
throws
PortaAuthException
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
Return values
string —

getEspfPath()

Provides ESPF base path, default is '/espf/v1', no trailig slash

public getEspfPath() : string
Return values
string —

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

getUrl()

Provides base server URI for all services like `'https://host.dom'`, no trailing slash.

public getUrl() : string
Return values
string —

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
throws
PortaAuthException
Return values
self —

for chaining

setOptions()

Replace Guzzle http call options with a new set

public setOptions(array<string|int, mixed> $options) : self

Be careful and consult Guzzle docs on request options

Parameters
$options : array<string|int, mixed>
  • new options set
Return values
self —
  • for chaining

Search results