Download the PHP package we-simply-code/laravel-afas-rest-connector without Composer
On this page you can find all versions of the php package we-simply-code/laravel-afas-rest-connector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download we-simply-code/laravel-afas-rest-connector
More information about we-simply-code/laravel-afas-rest-connector
Files in we-simply-code/laravel-afas-rest-connector
Package laravel-afas-rest-connector
Short Description This package integrates the AFAS REST API with Laravel
License MIT
Informations about the package laravel-afas-rest-connector
What this package does
This package integrates the AFAS REST API with Laravel with a minimal setup.
Table of Contents
- Installation
- Usage
- GetConnector
- Filters
- Take
- Skip
- SortOnField
- Where
- orWhere
- Execute
- Inspecting the where filter
- Filters
- UpdateConnector
- Insert & Update records
- Generating URL
- Meta info
- GetConnector
- Credits
- License
Installation
After installation publish the config file
In the config file you can add different connections to the AFAS profitServices. One connection is added by default. If you will be using only one connection use the default connection. If you will be using multiple connections use the default connection for the connection you will be using the most to make things easier.
For each connection in the config file you will have to add the connectors. Each connection contains the getConnectors & updateConnectors array.
Add your connectors to these arrays. The key can be anything you want (you will use this as the name of the connector in your code), the value has to be the id of the connector in AFAS profitService.
Add the following variables to your .env file
Usage
I assume you know how the AFAS profitServices work and what the different connectors do. If not please take a look at the documentation for the AFAS REST API: https://help.afas.nl/help/EN/SE/App_Cnr_Rest_Api.htm?query=rest
This package ships with a facade to access the different connectors easily. After retrieving your connector you can apply filters to it or add data to it and then call the method to make the call to AFAS profitServices.
GetConnector
With the GetConnector you can retrieve data from AFAS profitService. The getConnector supports the simple filter, or the json filter. After configuring your getConnectors for your connection you can use the like this:
Filters
You can apply filters on getConnectors to retrieve more specific data. There is no specific order to apply filters. You can chain as many filters as you want except for the and filter. Those can only be used once per request. By default, this package will use the simple filter to retrieve results. You can enable the jsonFilter when your queries get a bit more advanced. Check out the official documentation about the differences between the simple filter and the jsonFilter: https://help.afas.nl/help/EN/SE/App_Cnr_Rest_GET.htm#o85263
Take
By default, the profitServices return 100 results. You can adjust the amount of results by adding the filter.
Skip
You can skip results by adding the filter.
SortOnField
Sort the results on any field. By default, the results will be ascending but with and extra parameter you can change that. Field names must be exact the same as they are in AFAS profitServices.
Where
If you want to get specific results from the getConnector you can use the filter (records must match all criterion). It is recommended to always use the filter with the getConnector as it enhances the performance and only gives you the results you need.
All AFAS Profit filters for the filter are available. The filters are listed in the config file. You can use them in their symbol form, or their text form.
By default, the getConnector uses the simple filter. To enable the jsonFilter you can pass as second parameter to the getConnector.
orWhere
You can use the filter to add another where clause to the filter (records must match at least one criterion). Please check out the official docs how this works.
Sometimes the simple filter isn't enough to query specific results. Enable the jsonFilter when doing advanced queries. The jsonFilter and the simple filter don't always return the same results!
Execute
The method is used when you have configured the connector accordingly to make the call to the AFAS profitServices.
This package uses Laravel's wrapper around Guzzle to make http calls. That means that after we call the method, we can use the methods Laravel provides to inspect the response. Example:
Check out the documentation for the Laravel http client: https://laravel.com/docs/8.x/http-client#introduction
Inspecting the where filter
If you want to inspect the json from the where filter you can call the method instead of the method after configuring the getConnector.
This method won't return the take, skip and sortOnField filter.
UpdateConnector
With the UpdateConnector you can insert, update or delete records from AFAS profitService. You can use a tool like https://connect.afas.nl to inspect the json object required to manipulate data in AFAS profitService, or you can call the method on the connector to inspect the fields.
Insert & Update records
Generating URL
If you want to inspect the URL that is being generated by the connector you can call the method instead of the method after configuring the connector.
MetaInfo
To inspect the meta info about a connector we can simply call the method.
Credits
Sunil Kisoensingh
License
The MIT License (MIT). Please see License File for more information.