PHPackages                             fiorello/affinity-integration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. fiorello/affinity-integration

ActiveLibrary

fiorello/affinity-integration
=============================

Affinity Integration system. Consumes Affinity APIs to perform basic functions

110PHP

Since Mar 7Pushed 10y ago2 watchersCompare

[ Source](https://github.com/AlexFiorello/AffinityIntegration)[ Packagist](https://packagist.org/packages/fiorello/affinity-integration)[ RSS](/packages/fiorello-affinity-integration/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Affinity Integration
--------------------

[](#affinity-integration)

Affinity Integration gives you access to the Affinity API to perform general tasks. It includes the ability to create tickets, view records, update details.

```
Affinity::login();
$siteID = Affinity::getSiteId();
Affinity:::logout();
```

---

[![Latest Stable Version](https://camo.githubusercontent.com/668cdd8bf931fe1ae3a0e92b2933d2d746052545d3a63ba00e05727478da631d/68747470733a2f2f706f7365722e707567782e6f72672f66696f72656c6c6f2f616666696e6974792d696e746567726174696f6e2f762f737461626c65)](https://packagist.org/packages/fiorello/affinity-integration) [![Total Downloads](https://camo.githubusercontent.com/0248ecc73b27db5abb5cbedaaa0f75661548a289349cfa2f75c661580219a578/68747470733a2f2f706f7365722e707567782e6f72672f66696f72656c6c6f2f616666696e6974792d696e746567726174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/fiorello/affinity-integration) [![Latest Unstable Version](https://camo.githubusercontent.com/791fdfe8a373309df65716ea4de4a18d3d4fa407079fab3172cdf7ec0b9516a1/68747470733a2f2f706f7365722e707567782e6f72672f66696f72656c6c6f2f616666696e6974792d696e746567726174696f6e2f762f756e737461626c65)](https://packagist.org/packages/fiorello/affinity-integration) [![License](https://camo.githubusercontent.com/28f62bfb12d34f0b145e28d69de40d28b7a24afa48ef564c05131ef8fec59470/68747470733a2f2f706f7365722e707567782e6f72672f66696f72656c6c6f2f616666696e6974792d696e746567726174696f6e2f6c6963656e7365)](https://packagist.org/packages/fiorello/affinity-integration)

Installation
============

[](#installation)

Require this package in your `composer.json` and update composer. This will download the package.

```
"fiorello/affinity-integration": "dev-master"
```

After updating composer, add the ServiceProvider to the providoers array in `app/config/app.php`

```
'fiorello\AffinityIntegration\AffinityIntegrationServiceProvider',
```

You will need to publish the configuration, and amend it.

```
"php artisan config:publish fiorello/affinity-integration"
```

Then go to: `app/config/packages/fiorello/affinity-integration/config.php` and enter your own Affinity API connection details.

```
return array(
    'affinityWSDL'      =>  "https://api.affinity.akjl.co.uk/[APIuser]/WSDL/AffinityAPIService.WSDL",
    'affinityUserName'  =>  "[AffinityUsername]",
    'affinityPassword'  =>  "[AffinityPassword]",
    'affinityAppName'   =>  "[AppName]",
    'affinityAppRef'    =>  "[LaravelAPI]"
);
```

---

Usage
=====

[](#usage)

Before you can make any calls to Affinity, you must login. This process gets a unique Token which will be used for all subsequent calls automatically. You must remember to log out when you have finished.

```
Affinity::login();
//Do Stuff
Affinity::logout();
```

There are two types of result returned from a function call. Where a function call was succesful the following properties will be returned (`errorCode` will be equal to `0`):

```
errorCode
result
properties
```

Where a function call fails the following is returned:

```
errorCode
errorMessage
```

The `result` property will either be a string, integer or a JSON object. Where `result` is a JSON object the `properties` property will be returned as an array with the available properties for the `result` object. You can use this if you do not know what data the object contains.

\#An Example

```
Affinity::login()
$siteResponse = Affinity::getSiteId("HT123456");
if($siteResponse->errorCode > 0) {
 //An error has occured, display the message
 echo $siteResponse->errorMessage;
} else {
 //All processed fine, lets handle the data.
 //I know that getSiteId returns an Integer.
 //So use this to get Site Details
 $detailsResponse = Affinity::getSite($siteResponse->result);
 if($detailsResponse->errorCode > 0) {
  //An error occured so display the message
  echo $detailsResponse->errorMessage;
 } else {
  //getSite returns an object of site details
  var_dump($detailsResponse->result);
 }

 Affinity::logout();

```

The above `$detailsResponse->result` would produce the following:

```
{
 "SiteName":"Claire Test",
 "SiteRef":"NN12345678",
 "CompanyVATNumber":{},
 "CompanyRegNumber":{},
 "DealerID":"10",
 "CompanyID":"654321",
 "CompanyName":"Claire Test",
 "CompanyWebAddress":{}
}
```

The `$detailsResponse->properties` would contain:

```
(
 [0] => SiteName
 [1] => SiteRef
 [2] => CompanyVATNumber
 [3] => CompanyRegNumber
 [4] => DealerID
 [5] => CompanyID
 [6] => CompanyName
 [7] => CompanyWebAddress
)
```

Authors and Contributors
========================

[](#authors-and-contributors)

Created in Jan 2016 by Alex Fiorello (@AlexFiorello)

License
=======

[](#license)

This package is licensed under LGPL. You are free to use it in personal and commercial projects. The code can be forked and modified, but the original copyright author should always be included!

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/11ba62cbf9fc4b188c04b9adf11654476f1196fb7c2d60b2fa1c93fcc1fe37db?d=identicon)[AlexFiorello](/maintainers/AlexFiorello)

---

Top Contributors

[![AlexFiorello](https://avatars.githubusercontent.com/u/11734973?v=4)](https://github.com/AlexFiorello "AlexFiorello (9 commits)")

### Embed Badge

![Health badge](/badges/fiorello-affinity-integration/health.svg)

```
[![Health](https://phpackages.com/badges/fiorello-affinity-integration/health.svg)](https://phpackages.com/packages/fiorello-affinity-integration)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
