<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
we-simply-code / laravel-afas-rest-connector example snippets
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// This will give you the "contacts" getConnector for the default connection
Afas::getConnector('contacts');
// This will give you the "contacts" getConnector for a different connection
Afas::getConnector('contacts', 'differentConnectionName');
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// This will give you a getConnector instance with the simple filter enabled
Afas::getConnector('contacts');
// This will give you a getConnector instance with the json filter enabled
Afas::getConnector('contacts', true);
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// This will add the take filter to the connector with an amount of 10
Afas::getConnector('contacts')->take(10);
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// This will add the skip filter to the connector with an amount of 10
Afas::getConnector('contacts')->skip(10);
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// This will sort the results ascending by the field 'Name'
Afas::getConnector('contacts')->sortOnField('Name');
// Add true as second parameter to sort the results descending
// This will sort the results descending by the field 'Name'
Afas::getConnector('contacts')->sortOnField('Name', true);
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// The where() filter accepts the field type as first parameter, filter type as second and what the results should be filtered on as third
// Get only the contacts of type Person (simple filter)
Afas::getConnector('contacts')->where('type', '=', 'Person');
// Get only the contacts of type Person (json filter)
Afas::getConnector('contacts', true)->where('type', '=', 'Person');
// You can chain as much where filters as needed
// Get only the contacts from the Netherlands who are organizations
Afas::getConnector('contacts')
->where('country', '=', 'Netherlands')
->where('type', '=', 'Organization');
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// The orWhere() filter accepts the field type as first parameter, filter type as second and what the results should be filtered on as third
// Get the contacts of type Person or Organization
Afas::getConnector('contacts')
->where('type', '=', 'Person')
->orWhere('type', '=', 'Organization');
// Get only the contacts from the Netherlands or Germany who are organizations (json filter)
Afas::getConnector('contacts', true)
->where('type', '=', 'Organization')
->where('country', '=', 'Netherlands')
->orWhere('type', '=', 'organization')
->where('country', '=', 'Germany');
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// Execute the call. This will retrieve 100 contacts from the AFAS profitServices
Afas::getConnector('contacts')->execute();
// Retrieve 10 contacts
Afas::getConnector('contacts')
->take(10)
->execute();
// Retrieve 100 contacts but skip the first
Afas::getConnector('contacts')
->skip(1)
->execute();
// Retrieve 10 contacts and skip the first
Afas::getConnector('contacts')
->skip(1)
->take(10)
->execute();
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// This will return the request status
Afas::getConnector('contacts')
->execute()
->status();
// This will return the response in JSON
Afas::getConnector('contacts')
->execute()
->json();
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// This will return the where filter in a json string
Afas::getConnector('contacts')
->take(10)
->where('Type', '=', 'Person')
->getJsonFilter();
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
$data = [
"KnPerson" => [
"Element" => [
"Fields" => [],
],
],
];
// Create a new record in AFAS profitService
Afas::updateConnector('person')->insert($data);
// Update an existing record in AFAS profitService
Afas::updateConnector('person')->update($data);
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// Both of these will return the generated URL by the connector (you can use this directly to make a call in something like Postman)
Afas::getConnector('contacts')->getUrl();
Afas::getConnector('contacts')
->take(10)
->where('Type', '=', 'Person')
->getUrl();
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;
// Get the meta info from the connector
Afas::getConnector('contacts')->metaInfo();
Afas::updateConnector('person')->metaInfo();
// Get the json representation of the meta info from the connector
Afas::getConnector('contacts')->metaInfo()->json();
Afas::updateConnector('person')->metaInfo()->json();