RequestProxy.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Lackoxygen\TopWarehouse\Request;
use Illuminate\Support\Arr;
use Lackoxygen\TopWarehouse\Exception\Exception;
use Lackoxygen\TopWarehouse\Request\Inventory\GetStockInventoryRequest;
use Lackoxygen\TopWarehouse\Request\Order\OrdersB2cAddRequest;
use Lackoxygen\TopWarehouse\Request\Order\OrderEntryStatusRequest;
use Lackoxygen\TopWarehouse\Request\Order\OrderLoadingDeliveryRequest;
class RequestProxy
{
/**
* @var string[]
*/
protected static $proxies = [
'ordersB2cAdd' => OrdersB2cAddRequest::class,
'getStockInventory' => GetStockInventoryRequest::class,
'orderEntryStatus' => OrderEntryStatusRequest::class,
'loadDelivery' => OrderLoadingDeliveryRequest::class,
];
/**
* @param string $name
*
* @return Request
* @throws Exception
*/
public static function proxy(string $name): Request
{
if (!Arr::exists(self::$proxies, $name)) {
throw new Exception('Method not supported');
}
return new self::$proxies[$name];
}
}