-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with updateStock or updateStockMultiple -> "ErrorMessage":"Parameter SKU is empty" but given #78
Comments
+1 |
1 similar comment
+1 |
I confirm, that there is a problem with jms/serializer 3.30 & getPaging(). Here's how I downgraded to 3.29.1:
|
@StanProg Thank you very much for your solution! |
because of no answer of the support i have generate a new sdk without dependencies |
An alternative quick fix solution for the /Model/stock.php issue, without changing the package file is to use a serialized array or object, so instead of using $stockModel = new \stdClass();
$stockModel->sku = $sku;
$stockModel->newQuantity = $quantity;
$client->post(
'products/updatestock',
$this->serialize($stockModel),
Response\UpdateStockResponse::class
); The serlialize method: use JMS\Serializer\Handler\HandlerRegistry;
use JMS\Serializer\SerializerBuilder;
/**
* @param $data
* @return string
* @note Based on BillbeeDe\BillbeeAPI\Endpoint\OrdersEndpoint::serialize() & BillbeeDe\BillbeeAPI\Client::__construct()
*/
private function serialize($data): string
{
$serializer = SerializerBuilder::create()
->addDefaultDeserializationVisitors()
->addDefaultSerializationVisitors()
->addDefaultHandlers()
->addDefaultListeners()
->configureHandlers(
function (HandlerRegistry $registry) {
$registry->registerSubscribingHandler(new DefinitionConfigTransformer());
$registry->registerSubscribingHandler(new AsIsTransformer());
$registry->registerSubscribingHandler(new DefaultDateTimeHandler());
}
)->build();
return $serializer->serialize($data, 'json');
} (for reference) the code that failed with the current SDK was: use BillbeeDe\BillbeeAPI\Model\Stock;
$stockModel = new Stock();
$stockModel->setSku($sku);
$stockModel->setNewQuantity($quantity);
$response = $client->products()->updateStock($stockModel); and it generated the following Client error: `POST https://api.billbee.io/api/v1/products/updatestock` resulted in a `400 Bad Request` response:
{"ErrorMessage":"Parameter SKU is empty","ErrorCode":11,"ErrorDescription":"InvalidData","Data":null} |
Hello,
i have a problem for update stock.... and with newest serializer also paging orders error
using:
php 8.2
billbee/billbee-api 2.2.1
jms/serializer 3.30
guzzlehttp/guzzle 7.8.1
also if i used newest version of jms/serializer i get the error for orders:
PHP Fatal error: Uncaught TypeError: BillbeeDe\BillbeeAPI\Response\BaseResponse::getPaging(): Return value must be of type array, null returned
Here how i fixed the issues and also warnings:
donwgrade jms/serializer to 3.28
/customClient.php on line 41
replace:
$body = $options['body'] ?? null;
with
$body = $options['body'] ?? '';
in file /Model/stock.php
replace all protected with public
example:
protected $sku;
to:public $sku;
in File /Response/UpdateStockResponse.php
i removed line 21
* @var array<array{SKU: ?string, OldStock: ?float, CurrentStock: ?float, UnfulfilledAmount: ?float, Message: string}>
so the response will display corrctly
maybe anyone can check this and update the SDK
The text was updated successfully, but these errors were encountered: