Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Api/Enum/InventoryDocumentType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Baselinker\Api\Enum;

enum InventoryDocumentType: int
{
case GoodsReceived = 0;
case InternalGoodsReceived = 1;
case GoodsIssue = 2;
case InternalGoodsIssue = 3;
case InternalTransfer = 4;
case OpeningBalance = 5;
}
13 changes: 13 additions & 0 deletions src/Api/Enum/InventoryPurchaseOrderStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Baselinker\Api\Enum;

enum InventoryPurchaseOrderStatus: int
{
case Draft = 0;
case Sent = 1;
case Received = 2;
case Completed = 3;
case CompletedPartially = 4;
case Canceled = 5;
}
63 changes: 63 additions & 0 deletions src/Api/Request/InventoryDocuments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Baselinker\Api\Request;

use Baselinker\Api\Client;
use Baselinker\Api\Enum\InventoryDocumentType;
use Baselinker\Api\Response\Response;

class InventoryDocuments extends Client
{
public function addInventoryDocument(int $warehouseId, InventoryDocumentType $documentType, array $data = []): Response
{
$data['warehouse_id'] = $warehouseId;
$data['document_type'] = $documentType->value;

return new Response(
$this->post('addInventoryDocument', $data)
);
}

public function setInventoryDocumentStatusConfirmed(int $documentId): Response
{
return new Response(
$this->post('setInventoryDocumentStatusConfirmed', [
'document_type' => $documentId,
])
);
}

public function getInventoryDocuments(array $filters = []): Response
{
return new Response(
$this->post('getInventoryDocuments', $filters)
);
}

public function getInventoryDocumentItems(int $documentId, ?int $page = null): Response
{
return new Response(
$this->post('getInventoryDocumentItems', [
'document_id' => $documentId,
'page' => $page,
])
);
}

public function addInventoryDocumentItems(int $documentId, array $items): Response
{
return new Response(
$this->post('addInventoryDocumentItems', [
'document_id' => $documentId,
'items' => $items,
])
);
}

public function getInventoryDocumentSeries(): Response
{
return new Response(
$this->post('getInventoryDocumentSeries')
);
}
}
69 changes: 69 additions & 0 deletions src/Api/Request/InventoryPurchaseOrders.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Baselinker\Api\Request;

use Baselinker\Api\Client;
use Baselinker\Api\Enum\InventoryPurchaseOrderStatus;
use Baselinker\Api\Response\Response;

class InventoryPurchaseOrders extends Client
{
public function getInventoryPurchaseOrders(array $data = []): Response
{
return new Response(
$this->post('getInventoryPurchaseOrders', $data),
);
}

public function getInventoryPurchaseOrderItems(int $orderId, ?int $page = null): Response
{
return new Response(
$this->post('getInventoryPurchaseOrderItems', [
'order_id' => $orderId,
'page' => $page,
]),
);
}

public function getInventoryPurchaseOrderSeries(int $warehouseId): Response
{
return new Response(
$this->post('getInventoryPurchaseOrderSeries', [
'warehouse_id' => $warehouseId,
]),
);
}

public function addInventoryPurchaseOrder(int $warehouseId, int $supplierId, int $payerId, string $currency = 'PLN', array $data = []): Response
{
$data['warehouse_id'] = $warehouseId;
$data['supplier_id'] = $supplierId;
$data['payer_id'] = $payerId;
$data['currency'] = $currency;

return new Response(
$this->post('addInventoryPurchaseOrder', $data),
);
}

public function addInventoryPurchaseOrderItems(int $orderId, array $items): Response
{
return new Response(
$this->post('addInventoryPurchaseOrderItems', [
'order_id' => $orderId,
'items' => $items,
]),
);
}

public function setInventoryPurchaseOrderStatus(int $orderId, InventoryPurchaseOrderStatus $status, array $completedItems = []): Response
{
return new Response(
$this->post('setInventoryPurchaseOrderStatus', [
'order_id' => $orderId,
'status' => $status->value,
'completed_items' => $completedItems,
]),
);
}
}
32 changes: 32 additions & 0 deletions src/Api/Request/InventorySuppliers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Baselinker\Api\Request;

use Baselinker\Api\Client;
use Baselinker\Api\Response\Response;

class InventorySuppliers extends Client
{
public function getInventorySuppliers(array $filters = []): Response
{
return new Response(
$this->post('getInventorySuppliers', $filters)
);
}

public function addInventorySupplier(array $data): Response
{
return new Response(
$this->post('addInventorySupplier', $data)
);
}

public function deleteInventorySupplier(int $supplierId): Response
{
return new Response(
$this->post('deleteInventorySupplier', [
'supplier_id' => $supplierId,
])
);
}
}
18 changes: 18 additions & 0 deletions src/Baselinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
use Baselinker\Api\Request\BaselinkerConnect;
use Baselinker\Api\Request\CourierShipments;
use Baselinker\Api\Request\ExternalStorages;
use Baselinker\Api\Request\InventoryDocuments;
use Baselinker\Api\Request\InventoryPayers;
use Baselinker\Api\Request\InventoryPurchaseOrders;
use Baselinker\Api\Request\InventorySuppliers;
use Baselinker\Api\Request\OrderReturns;
use Baselinker\Api\Request\Orders;
use Baselinker\Api\Request\ProductCatalog;
Expand All @@ -26,6 +29,21 @@ public function productCatalog(): ProductCatalog
return new ProductCatalog($this->config);
}

public function inventoryDocuments(): InventoryDocuments
{
return new InventoryDocuments($this->config);
}

public function inventoryPurchaseOrders(): InventoryPurchaseOrders
{
return new InventoryPurchaseOrders($this->config);
}

public function inventorySuppliers(): InventorySuppliers
{
return new InventorySuppliers($this->config);
}

public function warehouseDocuments(): WarehouseDocuments
{
return new WarehouseDocuments($this->config);
Expand Down
30 changes: 30 additions & 0 deletions tests/BaselinkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
use Baselinker\Api\Request\BaselinkerConnect;
use Baselinker\Api\Request\CourierShipments;
use Baselinker\Api\Request\ExternalStorages;
use Baselinker\Api\Request\InventoryDocuments;
use Baselinker\Api\Request\InventoryPayers;
use Baselinker\Api\Request\InventoryPurchaseOrders;
use Baselinker\Api\Request\InventorySuppliers;
use Baselinker\Api\Request\OrderReturns;
use Baselinker\Api\Request\Orders;
use Baselinker\Api\Request\ProductCatalog;
Expand Down Expand Up @@ -43,6 +46,33 @@ public function testWarehousePurchaseOrders(): void
$this->assertInstanceOf(WarehousePurchaseOrders::class, $warehousePurchaseOrders);
}

public function testInventoryDocuments(): void
{
$baselinker = new Baselinker('token');

$inventoryDocuments = $baselinker->inventoryDocuments();

$this->assertInstanceOf(InventoryDocuments::class, $inventoryDocuments);
}

public function testInventoryPurchaseOrders(): void
{
$baselinker = new Baselinker('token');

$inventoryPurchaseOrders = $baselinker->inventoryPurchaseOrders();

$this->assertInstanceOf(InventoryPurchaseOrders::class, $inventoryPurchaseOrders);
}

public function testInventorySuppliers(): void
{
$baselinker = new Baselinker('token');

$inventorySuppliers = $baselinker->inventorySuppliers();

$this->assertInstanceOf(InventorySuppliers::class, $inventorySuppliers);
}

public function testInventoryPayers(): void
{
$baselinker = new Baselinker('token');
Expand Down