Closed TiBianMod closed 5 years ago
This endpoint is not implemented in the SDK at the moment. You can extend the client class and write your own method:
<?php
use BillbeeDe\BillbeeAPI\Client;
use BillbeeDe\BillbeeAPI\Model\Product;
use BillbeeDe\BillbeeAPI\Model\TranslatableText;
use BillbeeDe\BillbeeAPI\Response\BaseResponse;
$user = Config::get('BILLBEE_USER');
$apiPassword = Config::get('BILLBEE_API_PASSWORD');
$apiKey = Config::get('BILLBEE_API_KEY');
class MyClient extends Client
{
public function createProduct(Product $product)
{
return $this->requestPOST(
'products', // Products endpoint
$this->jom->serialize($product), // Serialize the product to json
BaseResponse::class // response class
);
}
}
$myClient = new MyClient($user, $apiPassword, $apiKey);
$myProduct = new Product();
$myProduct->title = [new TranslatableText('Product Title', 'DE')];
$myProduct->vatIndex = 1;
$myProduct->price = 5.29;
$myProduct->stockReduceItemsPerSale = 1.0;
$myProduct->isDigital = false;
$myProduct->isCustomizable = false;
// This fields have wrong values in the current version of the SDK so we need to change them
$myProduct->stocks = [];
$myProduct->weight = 0;
$myProduct->weightNet = 0;
$myProduct->unitsPerItem = 1.0;
$myProduct->soldSumGross = 0.0;
$myProduct->soldSumNet = 0.0;
$myProduct->soldSumNetLast30Days = 0.0;
$myProduct->soldSumGrossLast30Days = 0.0;
$myProduct->soldAmountLast30Days = 0.0;
var_dump($myClient->createProduct($myProduct));
The createProduct call will be available in the next version of the SDK
Very Nice news, Thanks :)
Like the Title indicates, creating new Article/Product result in a 500 Internal Server Error.
Here is the response from the server.
Is ok if i open another issues here?