Giter Site home page Giter Site logo

afasprofit's Introduction

Afas Profit API

Build Status

An API to connect to Afas Profit written in PHP.

Features:

  • Getting data from Profit GetConnectors.
  • Insert, update or delete data into Profit using Profit UpdateConnectors.
  • Getting files from Profit using Profit Subjectconnectors.
  • Getting UpdateConnectors XML Schema's using the Profit DataConnector.

Usage

Get data from Profit (GetConnector):

use Afas\Core\Server;

// Initialize server.
$server = new Server('https://12345.afasonlineconnector.nl/profitservices', 'ABCDEFGHIJK1234');

// Get data from GetConnector 'Products', filter by 'sku'.
$products = $server->get('Products')
  ->filter('sku', '2612')
  ->execute()
  ->asArray();

Insert data into Profit (UpdateConnector):

use Afas\Core\Server;

// Initialize server.
$server = new Server('https://12345.afasonlineconnector.nl/profitservices', 'ABCDEFGHIJK1234');

// Insert an order into Profit.
$server->insert('FbSales', [
  'OrNu' => 'test_001',
  'DbId' => 123456,
  'War' => 1,
  'FbSalesLines' => [
    [
      'ItCd' => 1201,
      'QuUn' => 1,
    ],
    [
      'ItCd' => 1202,
      'QuUn' => 1,
    ],
  ],
]);

Update data into Profit (UpdateConnector):

use Afas\Core\Server;

// Initialize server.
$server = new Server('https://12345.afasonlineconnector.nl/profitservices', 'ABCDEFGHIJK1234');

// Update an existing order, change quantity of existing item.
$server->update('FbSales', [
  'OrNu' => 'test_001',
  'FbSalesLines' => [
    [
      'GuLi' => '{6BA270E1-BFA7-4B67-86FF-72391A2CB5E3}',
      'QuUn' => 2,
    ],
  ],
]);

Delete data from Profit (UpdateConnector):

use Afas\Core\Server;

// Initialize server.
$server = new Server('https://12345.afasonlineconnector.nl/profitservices', 'ABCDEFGHIJK1234');

$server->delete('FbSales', [
  'OrNu' => 'test_001',
]);

Get a file from Profit (SubjectConnector):

use Afas\Afas;
use Afas\Core\Connector\SubjectConnector;
use Afas\Core\Server;

// Initialize server.
$server = new Server('https://12345.afasonlineconnector.nl/profitservices', 'ABCDEFGHIJK1234');

// Create Soap client.
/** @var \Afas\Component\Soap\SoapClientInterface $client */
$client = Afas::service('afas.soap_client_factory')->create($server);

// Create SubjectConnector.
$connector = new SubjectConnector($client, $server);

// To get an attachment, pass a subject ID and a file ID.
$attachment = $connector->getAttachment(300001, '8D36870843A516C2514D74BE69F87E15');

Get a XML Schema for a Profit UpdateConnector from Profit (DataConnector):

use Afas\Afas;
use Afas\Core\Connector\DataConnector;
use Afas\Core\Server;

// Initialize server.
$server = new Server('https://12345.afasonlineconnector.nl/profitservices', 'ABCDEFGHIJK1234');

// Create Soap client.
/** @var \Afas\Component\Soap\SoapClientInterface $client */
$client = Afas::service('afas.soap_client_factory')->create($server);

// Create DataConnector.
$connector = new DataConnector($client, $server);

// Get schema.
/** @var \Afas\Core\Result\DataConnectorResult $result */
$result = $connector->getXmlSchema('FbSales');

// Save complete schema.
file_put_contents('FbSales.xsd', $result->asArray()[0]['Schema']);

// Or save without custom fields.
file_put_contents('FbSales.xsd', $result->removeCustomFieldsFromSchema()[0]['Schema']);

afasprofit's People

Contributors

megachriz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.