/**
  * Get estimated delivery data if the item is backorderable.
  *
  * @param  Mage_Core_Model_Abstract
  * @return EbayEnterprise_Inventory_Model_Details_Item | null
  */
 public function getOcrBackorderableEddData(Mage_Core_Model_Abstract $item)
 {
     $streetData = $this->getStreetDateForBackorderableItem($item);
     if ($streetData) {
         return $this->detailFactory->createItemDetails(['item_id' => $item->getId(), 'sku' => $item->getSku(), 'delivery_window_from_date' => $streetData->getDeliveryWindowFromDate(), 'delivery_window_to_date' => $streetData->getDeliveryWindowToDate(), 'shipping_window_from_date' => null, 'shipping_window_to_date' => null, 'delivery_estimate_creation_time' => null, 'delivery_estimate_display_flag' => null, 'delivery_estimate_message' => null, 'ship_from_lines' => null, 'ship_from_city' => null, 'ship_from_main_division' => null, 'ship_from_country_code' => null, 'ship_from_postal_code' => null]);
     }
     return null;
 }
 /**
  * fetch inventory details for the quote
  *
  * @param Mage_Sales_Model_Quote
  * @return self
  */
 public function updateDetailsForQuote(Mage_Sales_Model_Quote $quote)
 {
     try {
         $this->factory->createDetailsModel()->fetch($quote);
         $this->handleUnavailableItems();
     } catch (EbayEnterprise_Inventory_Exception_Details_Operation_Exception $e) {
         // nothing to do here
     }
     return $this;
 }
 public function testGetDetailsForItem()
 {
     // stub a detail model to return from the result
     $unavailable = Mage::getModel('ebayenterprise_inventory/details_item', ['item_id' => 5, 'sku' => 'foo']);
     // mock the details model and the factory method to
     // create it
     $detailsModel = $this->getModelMockBuilder('ebayenterprise_inventory/details')->disableOriginalConstructor()->getMock();
     $this->factory->expects($this->once())->method('createDetailsModel')->will($this->returnValue($detailsModel));
     // mock up the result and mock the details model
     // to get back
     $result = $this->getModelMockBuilder('ebayenterprise_inventory/details_result')->disableOriginalConstructor()->setMethods(['lookupDetailsByItemId'])->getMock();
     $result->expects($this->once())->method('lookupDetailsByItemId')->with($this->isType('int'))->will($this->returnValue($unavailable));
     $detailsModel->expects($this->any())->method('fetch')->with($this->isInstanceOf('Mage_Sales_Model_Quote'))->will($this->returnValue($result));
     $quantityService = $this->getModelMock('ebayenterprise_inventory/quantity_service', ['canSendInventoryDetail']);
     $quantityService->expects($this->once())->method('canSendInventoryDetail')->will($this->returnValue(true));
     // start the test
     $detailService = Mage::getModel('ebayenterprise_inventory/details_service', ['factory' => $this->factory, 'logger' => $this->logger, 'log_context' => $this->logContext, 'quantity_service' => $quantityService]);
     $quote = $this->getModelMock('sales/quote');
     $item = $this->getModelMock('sales/quote_item', ['getQuote', 'getId']);
     $item->expects($this->once())->method('getQuote')->will($this->returnValue($quote));
     $item->expects($this->once())->method('getId')->will($this->returnValue(1));
     $detail = $detailService->getDetailsForItem($item);
     $this->assertInstanceOf('EbayEnterprise_Inventory_Model_Details_Item', $detail);
 }
 /**
  * fill out the request payload to send
  */
 protected function prepareRequest(HttpApi $api, Mage_Sales_Model_Quote $quote)
 {
     $request = $api->getRequestBody();
     $builder = $this->factory->createRequestBuilder($request);
     $alternateAddress = $this->getAlternateAddress($quote);
     foreach ($this->selectAddresses($quote) as $address) {
         $isAddressValid = $this->isValidPhysicalAddress($address);
         if (!$isAddressValid && !$alternateAddress) {
             continue;
         } elseif (!$isAddressValid) {
             $address = $alternateAddress;
         }
         $items = $this->selection->selectFrom($address->getAllItems());
         $builder->addItemPayloads($items, $address);
     }
     $api->setRequestBody($request);
     return $request;
 }
 protected function buildItemModel(array $itemData)
 {
     return $this->factory->createItemDetails($itemData);
 }
 /**
  * build a result object with the data from the reply
  *
  * @param IInventoryDetailsReply
  * @return EbayEnterprise_Inventory_Model_Details_Result
  */
 protected function buildResultFromReply(IInventoryDetailsReply $reply)
 {
     return $this->factory->createResult($this->extractDataFromReply($reply->getDetailItems(), [$this->itemHelper, 'extractItemDetails']), $this->extractDataFromReply($reply->getUnavailableItems(), [$this->itemHelper, 'extractItemIdentification']));
 }