<commit_before># fire-business-api-php
A PHP library for accessing the Fire Business API

[![Latest Version](https://img.shields.io/packagist/v/fire/business-api-sdk.svg?style=flat-square)](https://packagist.org/packages/fire/business-api-sdk) [![License](https://img.shields.io/packagist/l/fire/business-api-sdk.svg?style=flat-square)](LICENSE) 


## Installation

You can install **fire-business-api-php** by downloading the latest [release][releases] or using composer:

`composer require fire/business-api-sdk`

To run the samples, edit the file `sample/config.inc.php.sample` and rename to `sample/config.inc.php`.

## Quickstart

### Decode a webhook

```php
<?php
// you can either pull in the library using Fire/Starter if you've copied the library to your standard library location.
//include_once("Fire/Starter.php");

// Or using the Composer dependency manager
require "vendor/autoload.php"; 

// Receive a webhook from your business account
$keyId = "XXXXXX"; // The Key ID associated with your webhook
$secret = "YYYYYY"; // The Secret associated with your webhook

$handler = new Fire\Business\Webhook\Handler($keyId, $secret);

// $events is an array of Fire\Business\Model\Transactions
$events = $handler->parse($raw_post_data);

print $events[0];
```

## Documentation

The documentation for the Fire Business API is available at [fire.com/docs][apidocs].

## Prerequisites

* PHP >= 5.3
* The PHP JSON extension<commit_msg>Added a test for webhooks<commit_after># fire-business-api-php
A PHP library for accessing the Fire Business API

[![Latest Version](https://img.shields.io/packagist/v/fire/business-api-sdk.svg?style=flat-square)](https://packagist.org/packages/fire/business-api-sdk) [![License](https://img.shields.io/packagist/l/fire/business-api-sdk.svg?style=flat-square)](LICENSE) 


## Installation

You can install **fire-business-api-php** by downloading the latest [release][releases] or using composer:

`composer require fire/business-api-sdk`

To run the samples, edit the file `sample/config.inc.php.sample` and rename to `sample/config.inc.php`.

## Quickstart

### Decode a webhook

```php
<?php
// you can either pull in the library using Fire/Starter if you've copied the library to your standard library location.
//include_once("Fire/Starter.php");

// Or using the Composer dependency manager
require "vendor/autoload.php"; 

// Receive a webhook from your business account
$keyId = "XXXXXX"; // The Key ID associated with your webhook
$secret = "YYYYYY"; // The Secret associated with your webhook

$handler = new Fire\Business\Webhook\Handler($keyId, $secret);

// $events is an array of Fire\Business\Model\Transactions
$events = $handler->parse($raw_post_data);

print $events[0];
```

### Send a test webhook
You can send a webhook to your server using the sample script in samples/.

```php testwebhook.php --ref="INV 23798" --amount=1249 --endpoint=https://2i7yqo19qv39.runscope.net/``` 

The options are:
```
Usage: php testwebhook.php --endpoint=https://example.com [options]

  --ref=<reference> - the reference to use on the webhook lodgement
  --amount=<amount> - the amount (in pence/cent) to use on the lodgement
  --currency=<EUR|GBP> - the currency of the lodgement
  --fromAccountNum=<accountnum> - the account number this lodgement is from
  --fromNsc=<nsc> - the sortcode this lodgement is from
  --fromBIC=<bic> - the bic this lodgement is from
  --fromIBAN=<iban> - the IBAN this lodgement is from
  --toAccountNum=<accountnum> - the fire account number this lodgement is for
  --toIBAN=<iban> - the fire IBAN this lodgement is for
```


## Documentation

The documentation for the Fire Business API is available at [fire.com/docs][apidocs].

## Prerequisites

* PHP >= 5.3
* The PHP JSON extension
{'fraction_non_alphanumeric': 0.1298804780876494, 'fraction_numerical': 0.005577689243027889, 'mean_word_length': 4.426512968299712, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3761983', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1157, 'n_words': 372}