/**
  * @param Product $product
  * @return \DTS\eBaySDK\Trading\Types\AddFixedPriceItemResponseType
  */
 public function post(Product $product)
 {
     $request = new AddFixedPriceItemRequestType();
     $request = $this->addAuthToRequest($request);
     $item = new ItemType();
     $item->ListingType = ListingTypeCodeType::C_FIXED_PRICE_ITEM;
     // Renew the item every 30 days until the user cancels it
     $item->ListingDuration = ListingDurationCodeType::C_GTC;
     $item->InventoryTrackingMethod = 'SKU';
     $item->Title = $product->getTitle();
     $item->Description = $product->getDescription();
     // Mandatory when InvntoryTrackingMethod is set to SKU
     $item->SKU = $product->getSku();
     $item->HitCounter = HitCounterCodeType::C_HIDDEN_STYLE;
     if ($product->hasVariations()) {
         $this->addVariationsData($item, $product);
     } else {
         $item->StartPrice = new AmountType(['value' => $product->getPrice()]);
         $item->Quantity = $product->getQuantity();
     }
     $item->Country = $this->store->getStoreData('country');
     $item->Location = $this->store->getStoreData('location');
     if ($this->store->hasStoreData('postCode')) {
         $item->PostalCode = $this->store->getStoreData('postCode');
     }
     $item->Currency = $product->getCurrency();
     $item->PrimaryCategory = new CategoryType();
     $item->PrimaryCategory->CategoryID = $product->getCategory();
     $item->CategoryMappingAllowed = true;
     // Condition (should be brand new)
     $item->ConditionID = 1000;
     // Add brand information as item specific information
     $item->ItemSpecifics = new NameValueListArrayType();
     if ($product->getBrand()) {
         $brand = new NameValueListType();
         $brand->Name = 'Brand';
         $brand->Value[] = $product->getBrand();
         $item->ItemSpecifics->NameValueList[] = $brand;
     }
     if ($product->getWeight()) {
         // Add details for the shipping
         // NOTE: doesn't seem to work
         $item->ShippingPackageDetails = new ShipPackageDetailsType();
         $item->ShippingPackageDetails->MeasurementUnit = MeasurementSystemCodeType::C_ENGLISH;
         $totalOz = $product->getWeight() * 0.035274;
         $weightMajor = intval(floor($totalOz / 16));
         $weightMinor = intval(floor($totalOz - $weightMajor * 16));
         $item->ShippingPackageDetails->WeightMajor = new MeasureType(['unit' => 'lbs', 'value' => $weightMajor]);
         $item->ShippingPackageDetails->WeightMinor = new MeasureType(['unit' => 'oz', 'value' => $weightMinor]);
     }
     // Add pictures
     $this->addPictures($item, $product);
     // Add payement
     $item->PaymentMethods = $this->store->getPaymentOptions();
     $item->PayPalEmailAddress = $this->store->getPaypalEmail();
     $item->DispatchTimeMax = $this->store->getStoreData('dispatchTime');
     // Add shipping options and return policy
     $this->addShippingOptions($item, $product->getShippingOptions());
     $this->addReturnPolicy($item, $product->getReturnPolicy());
     $request->Item = $item;
     $response = $this->service->addFixedPriceItem($request);
     if ($response->Ack == 'Failure') {
         $this->handleError($response);
     }
     return $response;
 }
 /**
  * @param $eBayProduct
  * @param Product $product
  * @return \DTS\eBaySDK\Trading\Types\ReviseInventoryStatusResponseType|null
  * @throws EbayErrorException
  * @throws \StoreIntegrator\Exceptions\MissingTokenException
  */
 private function checkAndRevisePriceAndQuantity($eBayProduct, Product $product)
 {
     $inventoryChanges = [];
     if ($product->hasVariations()) {
         foreach ($product->getVariationOptions() as $option) {
             $inventoryChanges[] = ['sku' => $option['sku'], 'quantity' => $option['quantity'], 'price' => $option['price']];
         }
     } else {
         $inventoryChanges[] = ['sku' => $product->getSku(), 'quantity' => $product->getQuantity(), 'price' => $product->getPrice()];
     }
     $chunks = array_chunk($inventoryChanges, 4);
     $response = null;
     foreach ($chunks as $chunk) {
         foreach ($chunk as $inventoryData) {
             $request = new ReviseInventoryStatusRequestType();
             $inventory = new InventoryStatusType();
             $inventory->SKU = $inventoryData['sku'];
             $inventory->Quantity = $inventoryData['quantity'];
             $inventory->StartPrice = new AmountType(array('value' => doubleval($inventoryData['price'])));
             $request->InventoryStatus[] = $inventory;
             $this->addAuthToRequest($request);
             $response = $this->service->reviseInventoryStatus($request);
             if ($response->Ack == 'Failure') {
                 $this->handleError($response);
             }
         }
     }
     return $response;
 }