Skip to content

Commit

Permalink
MAGETWO-39766: [GITHUB] GET /V1/carts/mine/items is returning "cartId…
Browse files Browse the repository at this point in the history
… is a required field" #1443
  • Loading branch information
Olexii Korshenko committed Jul 31, 2015
1 parent 24090ce commit 8719604
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 68 deletions.
32 changes: 0 additions & 32 deletions app/code/Magento/Quote/Api/CartItemRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,4 @@ public function save(\Magento\Quote\Api\Data\CartItemInterface $cartItem);
* @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be removed.
*/
public function deleteById($cartId, $itemId);

/**
* Lists items that are assigned to a specified cart.
*
* @param int $customerId Customer ID.
* @return \Magento\Quote\Api\Data\CartItemInterface[] Array of items.
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
*/
public function getListForCustomer($customerId);

/**
* Adds the specified item to the specified cart.
*
* @param int $customerId Customer ID.
* @param \Magento\Quote\Api\Data\CartItemInterface $cartItem The item.
* @return \Magento\Quote\Api\Data\CartItemInterface Item.
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
* @throws \Magento\Framework\Exception\CouldNotSaveException The specified item could not be saved to the cart.
* @throws \Magento\Framework\Exception\InputException The specified item or cart is not valid.
*/
public function saveForCustomer($customerId, \Magento\Quote\Api\Data\CartItemInterface $cartItem);

/**
* Removes the specified item from the specified cart.
*
* @param int $customerId Customer ID.
* @param int $itemId The item ID of the item to be removed.
* @return bool
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified item or cart does not exist.
* @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be removed.
*/
public function deleteByIdForCustomer($customerId, $itemId);
}
28 changes: 0 additions & 28 deletions app/code/Magento/Quote/Model/Quote/Item/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,32 +132,4 @@ public function deleteById($cartId, $itemId)

return true;
}

/**
* {@inheritdoc}
*/
public function getListForCustomer($customerId)
{
$cart = $this->quoteRepository->getActiveForCustomer($customerId);
return $this->getList($cart->getId());
}

/**
* {@inheritdoc}
*/
public function saveForCustomer($customerId, \Magento\Quote\Api\Data\CartItemInterface $cartItem)
{
$cart = $this->quoteRepository->getActiveForCustomer($customerId);
$cartItem->setQuoteId($cart->getId());
return $this->save($cartItem);
}

/**
* {@inheritdoc}
*/
public function deleteByIdForCustomer($customerId, $itemId)
{
$cart = $this->quoteRepository->getActiveForCustomer($customerId);
return $this->deleteById($cart->getId(), $itemId);
}
}
16 changes: 8 additions & 8 deletions app/code/Magento/Quote/etc/webapi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,39 +244,39 @@

<!-- Managing my Cart Items -->
<route url="/V1/carts/mine/items" method="GET">
<service class="Magento\Quote\Api\CartItemRepositoryInterface" method="getListForCustomer"/>
<service class="Magento\Quote\Api\CartItemRepositoryInterface" method="getList"/>
<resources>
<resource ref="self" />
</resources>
<data>
<parameter name="customerId" force="true">%customer_id%</parameter>
<parameter name="cartId" force="true">%cartId%</parameter>
</data>
</route>
<route url="/V1/carts/mine/items" method="POST">
<service class="Magento\Quote\Api\CartItemRepositoryInterface" method="saveForCustomer"/>
<service class="Magento\Quote\Api\CartItemRepositoryInterface" method="save"/>
<resources>
<resource ref="self" />
</resources>
<data>
<parameter name="customerId" force="true">%customer_id%</parameter>
<parameter name="cartId" force="true">%cartId%</parameter>
</data>
</route>
<route url="/V1/carts/mine/items/:itemId" method="PUT">
<service class="Magento\Quote\Api\CartItemRepositoryInterface" method="saveForCustomer"/>
<service class="Magento\Quote\Api\CartItemRepositoryInterface" method="save"/>
<resources>
<resource ref="self" />
</resources>
<data>
<parameter name="customerId" force="true">%customer_id%</parameter>
<parameter name="cartId" force="true">%cartId%</parameter>
</data>
</route>
<route url="/V1/carts/mine/items/:itemId" method="DELETE">
<service class="Magento\Quote\Api\CartItemRepositoryInterface" method="deleteByIdForCustomer"/>
<service class="Magento\Quote\Api\CartItemRepositoryInterface" method="deleteById"/>
<resources>
<resource ref="self" />
</resources>
<data>
<parameter name="customerId" force="true">%customer_id%</parameter>
<parameter name="cartId" force="true">%cartId%</parameter>
</data>
</route>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2359,4 +2359,10 @@
'Magento\Sales\Model\Order\Address\Validator',
'Magento\Sales\Model\Order\Address\Validator::validateForCustomer'
],
['getListForCustomer', '\Magento\Quote\Api\CartItemRepositoryInterface'],
['saveForCustomer', '\Magento\Quote\Api\CartItemRepositoryInterface'],
['deleteByIdForCustomer', '\Magento\Quote\Api\CartItemRepositoryInterface'],
['getListForCustomer', '\Magento\Quote\Model\Quote\Item\Repository'],
['saveForCustomer', '\Magento\Quote\Model\Quote\Item\Repository'],
['deleteByIdForCustomer', '\Magento\Quote\Model\Quote\Item\Repository'],
];

0 comments on commit 8719604

Please sign in to comment.