fiorello / affinity-integration
Affinity Integration system. Consumes Affinity APIs to perform basic functions
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is not auto-updated.
Last update: 2024-11-09 20:39:19 UTC
README
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();
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
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
Created in Jan 2016 by Alex Fiorello (@AlexFiorello)
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!