PHP library


Composer (More info?) composer require dividebv/phpdivideiq
Manual -

DivideIQ Class


Access modifier Name Parameters Description
Public DivideIQ( string $username, string $password, string $environment = 'production' )

$username: The username used to authenticate.

$password: The password used to authenticate.

$environment: The environment to use. (Default: Production)
May be one of the following:
- Production (Live environment)
- Staging (Test environment)

Initializes a new instance of the DivideIQ class.


Access modifier Name Parameters Description


Access modifier Name Parameters Description
Public setFile ( SplFileObject $file )

$file: The file to store connection details to. Should be openend using the c+ mode.

Set the file to use for persisting the connection details.
Public static fromFile( SplFileObject $file )

$file: The file to be read from. Since it may also be written to, it should be opened with mode c+.

Unserializes the object from JSON contained in the given file.
Public request( string $serviceName, array $payload = [], string $method = 'GET' )

$serviceName: The codename of the service to access.

$payload: The data to send with the request. (Optional)

$method: The HTTP method to use to access the service. (Default: GET)

Accesses a service provided by Divide.IQ using the stored access token.
Public toJson( ) Serializes the object using JSON.
Public static fromJson( string $json )

$json: The object as serialized using JSON.

Unserializes the object from JSON.

Example code

        use DivideBV\PHPDivideIQ\PHPDivideIQ;

        $username = 'user';          // You will receive this from the provider.
        $password = 'password';      // You will receive this from the provider.
        $environment = 'production'; // May also be 'staging' or an arbitrary URL.

        // A file storing the connection status.
        $file = new SplFileObject('', 'c+');

        if ($file->getSize()) {
            // The file already exists, instantiate DivideIQ using the file.
            $divideIq = DivideIQ::fromFile($file);
        } else {
            // File doesn't exist. Instantiate DivideIQ using the constructor.
            $divideIq = new DivideIQ($username, $password, $environment);