|
...
|
...
|
@@ -5,31 +5,24 @@ namespace Lackoxygen\TopWarehouse; |
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
use Lackoxygen\TopWarehouse\Contracts\ResponseInterface;
|
|
|
|
use Lackoxygen\TopWarehouse\Contracts\TopWarehouseInterface;
|
|
|
|
use Lackoxygen\TopWarehouse\Request\GetStockInventoryRequest;
|
|
|
|
use Lackoxygen\TopWarehouse\Request\OrdersB2cAddRequest;
|
|
|
|
use Lackoxygen\TopWarehouse\Exception\Exception;
|
|
|
|
use Lackoxygen\TopWarehouse\Request\RequestProxy;
|
|
|
|
use Lackoxygen\TopWarehouse\Utils\SignatureUtil;
|
|
|
|
use Closure;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @method ResponseInterface ordersB2cAdd(Closure $callback)
|
|
|
|
* @method ResponseInterface getStockInventory(Closure $callback)
|
|
|
|
* @method ResponseInterface orderEntryStatus(Closure $callback)
|
|
|
|
* @method ResponseInterface loadDelivery(Closure $callback)
|
|
|
|
*
|
|
|
|
* @package Lackoxygen\TopWarehouse
|
|
|
|
*/
|
|
|
|
class TopWarehouse implements TopWarehouseInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function ordersB2cAdd(OrdersB2cAddRequest $ordersB2cAddRequest): ResponseInterface
|
|
|
|
{
|
|
|
|
return Client::make($ordersB2cAddRequest)->send();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getStockInventory(GetStockInventoryRequest $getStockInventoryRequest): ResponseInterface
|
|
|
|
{
|
|
|
|
return Client::make($getStockInventoryRequest)->send();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function verify(array $data): bool
|
|
|
|
{
|
|
|
|
$sign = Arr::get($data, 'sign');
|
|
...
|
...
|
@@ -41,4 +34,22 @@ class TopWarehouse implements TopWarehouseInterface |
|
|
|
|
|
|
|
return $generateSign === $sign;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $name
|
|
|
|
* @param $argv
|
|
|
|
*
|
|
|
|
* @return ResponseInterface
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function __call($name, $argv): ResponseInterface
|
|
|
|
{
|
|
|
|
$closure = Arr::get($argv, 0);
|
|
|
|
$request = RequestProxy::proxy($name);
|
|
|
|
if ($closure instanceof \Closure) {
|
|
|
|
call_user_func($closure, $request);
|
|
|
|
}
|
|
|
|
return Client::make($request)->send();
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|