AlexFiorello / AffinityIntegration by AlexFiorello

Affinity Integration system. Consumes Affinity APIs to perform basic functions
10
1
2
Package Data
Maintainer Username: AlexFiorello
Maintainer Contact: alex.fiorello@gmail.com (Alex Fiorello)
Package Create Date: 2016-01-21
Package Last Update: 2016-03-07
Language: PHP
License: LPGL
Last Refreshed: 2024-11-18 03:05:26
Package Statistics
Total Downloads: 10
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

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 Total Downloads Latest Unstable Version License

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!