# Prism PHP Library

You can sign up for a Prism account at https://prismapp.io

## Requirements

PHP 5.4 and later.

## Composer

You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:

```bash
composer require coralhq/prism-php-sdk
```

To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/00-intro.md#autoloading):

```php
require_once('vendor/autoload.php');
```

## Manual Installation

If you do not wish to use Composer, you can download the [latest release](https://github.com/coralhq/prism-php-sdk/releases). Then, to use the bindings, include the `init.php` file.

```php
require_once('/path/to/prism-php-sdk/init.php');
```

## Dependencies

The bindings require the following extension in order to work properly:

- [`curl`](https://secure.php.net/manual/en/book.curl.php)
- [`json`](https://secure.php.net/manual/en/book.json.php)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

## Getting Started

Simple usage looks like:

```php
\PrismAppIo\Prism::setClientApp('clientId', 'clientSecret');
$app = \PrismAppIo\Prism::getClientApp();

$clientId = $app['clientId'];
$clientSecret = $app['clientSecret'];

$getToken = \PrismAppIo\OAuth::fetchToken();
$getToken->json->access_token;
$getToken->json->expires_in;

$getProduct = \PrismAppIo\Products::retrieve('001');
$getProduct->json->id;
$getProduct->json->name;
```

## Development

Install dependencies:

``` bash
composer install
```
## Test
### all tests
``` bash
vendor/bin/phpunit
```
### single test
``` bash
vendor/bin/phpunit tests/test-oauth.php
```
### display code coverage
``` bash
vendor/bin/phpunit --coverage-text
```
### code coverage report
After run unit test, report will show in `build/report/index.html` and `build/clover.xml`