1. Go to this page and download the library: Download ux2dev/microinvest library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ux2dev / microinvest example snippets
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
use Ux2Dev\Microinvest\Microinvest;
use Ux2Dev\Microinvest\WarehousePro\WarehouseProConfig;
$config = new WarehouseProConfig(
baseUrl: 'http://127.0.0.1:8700', // Utility Center host; trailing slash optional
apiKey: 'your-custom-token', // optional; omit or pass null for anonymous access
);
$factory = new HttpFactory();
$microinvest = Microinvest::warehousePro($config, new Client(), $factory, $factory);
$items = $microinvest->items()->list(name: 'Cola*', pageSize: 200);
foreach ($items as $item) {
echo $item->name . PHP_EOL;
}
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
use Ux2Dev\Microinvest\MicroBg\MicroBgConfig;
use Ux2Dev\Microinvest\Microinvest;
$config = new MicroBgConfig(
apiId: '1821761530712553', // "API Идентификатор" from micro.bg
secretKey: 'a6808173988b...', // "Секретен ключ"; signs the payload, never sent
);
$factory = new HttpFactory();
$microbg = Microinvest::microBg($config, new Client(), $factory, $factory);
foreach ($microbg->items()->each() as $item) {
echo $item->name, ' ', $item->priceOut2, PHP_EOL;
}
use Ux2Dev\Microinvest\Dto\Input\Operations\OperationInput;
use Ux2Dev\Microinvest\Laravel\Facades\Microinvest;
$sale = Microinvest::operations()->create([
new OperationInput(
operationType: 2, // Sale
goodId: '66',
partnerId: 94,
objectId: 2,
qtty: 1.0,
priceOut: 7.29,
date: '2023-04-07',
userId: 2,
),
]);
$documentNumber = $sale->first()->documentNumber;
foreach ($microinvest->partners()->each() as $partner) {
echo $partner->company, PHP_EOL;
}
use Ux2Dev\Microinvest\Dto\Input\Operations\OperationDocumentInput;
use Ux2Dev\Microinvest\Dto\Input\Operations\OperationLineInput;
$microbg->operations()->save(
new OperationDocumentInput(
operationType: 2, // sale
objectId: 6,
lines: [new OperationLineInput(itemId: 8814, qtty: 1.0, price: 12.0)],
partnerId: 2,
extAppDocId: $order->id, // your own order id
),
byExtAppDocId: true, // create on the first call, update afterwards
);