Skip to content

Commit a3509e1

Browse files
committed
Merge pull request #251 from magento-api/MAGETWO-35023-31689-Sales-and-Checkout-APIs
[API] Sprint 47 – Sales & Checkout APIs
2 parents 4cec5b0 + 87eee14 commit a3509e1

File tree

91 files changed

+6035
-464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+6035
-464
lines changed

app/code/Magento/Quote/Api/CartItemRepositoryInterface.php

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,45 @@ public function getList($cartId);
2828
public function save(\Magento\Quote\Api\Data\CartItemInterface $cartItem);
2929

3030
/**
31-
* Remove bundle option
31+
* Removes the specified item from the specified cart.
32+
*
33+
* @param int $cartId The cart ID.
34+
* @param int $itemId The item ID of the item to be removed.
35+
* @return bool
36+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified item or cart does not exist.
37+
* @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be removed.
38+
*/
39+
public function deleteById($cartId, $itemId);
40+
41+
/**
42+
* Lists items that are assigned to a specified cart.
43+
*
44+
* @param int $customerId Customer ID.
45+
* @return \Magento\Quote\Api\Data\CartItemInterface[] Array of items.
46+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
47+
*/
48+
public function getListForCustomer($customerId);
49+
50+
/**
51+
* Adds the specified item to the specified cart.
3252
*
33-
* @param \Magento\Quote\Api\Data\CartItemInterface $cartItem
34-
* @return void
35-
* @throws \Magento\Framework\Exception\CouldNotSaveException
53+
* @param int $customerId Customer ID.
54+
* @param \Magento\Quote\Api\Data\CartItemInterface $cartItem The item.
55+
* @return \Magento\Quote\Api\Data\CartItemInterface Item.
56+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
57+
* @throws \Magento\Framework\Exception\CouldNotSaveException The specified item could not be saved to the cart.
58+
* @throws \Magento\Framework\Exception\InputException The specified item or cart is not valid.
3659
*/
37-
public function delete(\Magento\Quote\Api\Data\CartItemInterface $cartItem);
60+
public function saveForCustomer($customerId, \Magento\Quote\Api\Data\CartItemInterface $cartItem);
3861

3962
/**
4063
* Removes the specified item from the specified cart.
4164
*
42-
* @param int $cartId The cart ID.
65+
* @param int $customerId Customer ID.
4366
* @param int $itemId The item ID of the item to be removed.
4467
* @return bool
4568
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified item or cart does not exist.
4669
* @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be removed.
4770
*/
48-
public function deleteById($cartId, $itemId);
71+
public function deleteByIdForCustomer($customerId, $itemId);
4972
}

app/code/Magento/Quote/Api/CartManagementInterface.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
interface CartManagementInterface
99
{
1010
/**
11-
* Enables an administrative or guest user to create an empty cart and quote for an anonymous customer.
11+
* Creates an empty cart and quote for a guest.
1212
*
13-
* @param int $storeId
13+
* @return int Cart ID.
1414
* @throws \Magento\Framework\Exception\CouldNotSaveException The empty cart and quote could not be created.
15+
*/
16+
public function createEmptyCart();
17+
18+
/**
19+
* Creates an empty cart and quote for a specified customer.
20+
*
21+
* @param int $customerId The customer ID.
1522
* @return int Cart ID.
23+
* @throws \Magento\Framework\Exception\CouldNotSaveException The empty cart and quote could not be created.
1624
*/
17-
public function createEmptyCart($storeId);
25+
public function createEmptyCartForCustomer($customerId);
1826

1927
/**
2028
* Returns information for the cart for a specified customer.

app/code/Magento/Quote/Api/Data/CartItemInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ public function setProductType($productType);
119119
/**
120120
* Returns Quote id.
121121
*
122-
* @return int
122+
* @return string
123123
*/
124124
public function getQuoteId();
125125

126126
/**
127127
* Sets Quote id.
128128
*
129-
* @param int $quoteId
129+
* @param string $quoteId
130130
* @return $this
131131
*/
132132
public function setQuoteId($quoteId);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Api;
7+
8+
/**
9+
* Billing address management interface for guest carts.
10+
*/
11+
interface GuestBillingAddressManagementInterface
12+
{
13+
/**
14+
* Assigns a specified billing address to a specified cart.
15+
*
16+
* @param string $cartId The cart ID.
17+
* @param \Magento\Quote\Api\Data\AddressInterface $address Billing address data.
18+
* @return int Address ID.
19+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
20+
* @throws \Magento\Framework\Exception\InputException The specified cart ID or address data is not valid.
21+
*/
22+
public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address);
23+
24+
/**
25+
* Returns the billing address for a specified quote.
26+
*
27+
* @param string $cartId The cart ID.
28+
* @return \Magento\Quote\Api\Data\AddressInterface Quote billing address object.
29+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
30+
*/
31+
public function get($cartId);
32+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Api;
7+
8+
/**
9+
* Cart Item repository interface for guest carts.
10+
*/
11+
interface GuestCartItemRepositoryInterface
12+
{
13+
/**
14+
* Lists items that are assigned to a specified cart.
15+
*
16+
* @param string $cartId The cart ID.
17+
* @return \Magento\Quote\Api\Data\CartItemInterface[] Array of items.
18+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
19+
*/
20+
public function getList($cartId);
21+
22+
/**
23+
* Adds the specified item to the specified cart.
24+
*
25+
* @param \Magento\Quote\Api\Data\CartItemInterface $cartItem The item.
26+
* @return \Magento\Quote\Api\Data\CartItemInterface Item.
27+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
28+
* @throws \Magento\Framework\Exception\CouldNotSaveException The specified item could not be saved to the cart.
29+
* @throws \Magento\Framework\Exception\InputException The specified item or cart is not valid.
30+
*/
31+
public function save(\Magento\Quote\Api\Data\CartItemInterface $cartItem);
32+
33+
/**
34+
* Removes the specified item from the specified cart.
35+
*
36+
* @param string $cartId The cart ID.
37+
* @param int $itemId The item ID of the item to be removed.
38+
* @return bool
39+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified item or cart does not exist.
40+
* @throws \Magento\Framework\Exception\CouldNotSaveException The item could not be removed.
41+
*/
42+
public function deleteById($cartId, $itemId);
43+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Api;
7+
8+
/**
9+
* Cart Management interface for guest carts.
10+
*/
11+
interface GuestCartManagementInterface
12+
{
13+
/**
14+
* Enables an customer or guest user to create an empty cart and quote for an anonymous customer.
15+
*
16+
* @return string Cart ID.
17+
* @throws \Magento\Framework\Exception\CouldNotSaveException The empty cart and quote could not be created.
18+
*/
19+
public function createEmptyCart();
20+
21+
/**
22+
* Assigns a specified customer to a specified shopping cart.
23+
*
24+
* @param string $cartId The cart ID.
25+
* @param int $customerId The customer ID.
26+
* @param int $storeId
27+
* @return boolean
28+
*/
29+
public function assignCustomer($cartId, $customerId, $storeId);
30+
31+
/**
32+
* Places an order for a specified cart.
33+
*
34+
* @param string $cartId The cart ID.
35+
* @return int Order ID.
36+
*/
37+
public function placeOrder($cartId);
38+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Api;
7+
8+
/**
9+
* Cart Repository interface for guest carts.
10+
*/
11+
interface GuestCartRepositoryInterface
12+
{
13+
/**
14+
* Enables a guest user to return information for a specified cart.
15+
*
16+
* @param string $cartId
17+
* @return \Magento\Quote\Api\Data\CartInterface
18+
* @throws \Magento\Framework\Exception\NoSuchEntityException
19+
*/
20+
public function get($cartId);
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Quote\Api;
8+
9+
/**
10+
* Cart totals repository interface for guest carts.
11+
*/
12+
interface GuestCartTotalRepositoryInterface
13+
{
14+
/**
15+
* Returns quote totals data for a specified cart.
16+
*
17+
* @param string $cartId The cart ID.
18+
* @return \Magento\Quote\Api\Data\TotalsInterface Quote totals data.
19+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
20+
*/
21+
public function get($cartId);
22+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
8+
namespace Magento\Quote\Api;
9+
10+
/**
11+
* Coupon management interface for guest carts.
12+
*/
13+
interface GuestCouponManagementInterface
14+
{
15+
/**
16+
* Returns information for a coupon in a specified cart.
17+
*
18+
* @param string $cartId The cart ID.
19+
* @return string The coupon code data.
20+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
21+
*/
22+
public function get($cartId);
23+
24+
/**
25+
* Adds a coupon by code to a specified cart.
26+
*
27+
* @param string $cartId The cart ID.
28+
* @param string $couponCode The coupon code data.
29+
* @return bool
30+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
31+
* @throws \Magento\Framework\Exception\CouldNotSaveException The specified coupon could not be added.
32+
*/
33+
public function set($cartId, $couponCode);
34+
35+
/**
36+
* Deletes a coupon from a specified cart.
37+
*
38+
* @param string $cartId The cart ID.
39+
* @return bool
40+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
41+
* @throws \Magento\Framework\Exception\CouldNotDeleteException The specified coupon could not be deleted.
42+
*/
43+
public function remove($cartId);
44+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Api;
7+
8+
/**
9+
* Payment method management interface for guest carts.
10+
*/
11+
interface GuestPaymentMethodManagementInterface
12+
{
13+
/**
14+
* Adds a specified payment method to a specified shopping cart.
15+
*
16+
* @param string $cartId The cart ID.
17+
* @param \Magento\Quote\Api\Data\PaymentInterface $method The payment method.
18+
* @return int Payment method ID.
19+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
20+
* @throws \Magento\Framework\Exception\State\InvalidTransitionException The billing or shipping address
21+
* is not set, or the specified payment method is not available.
22+
*/
23+
public function set($cartId, \Magento\Quote\Api\Data\PaymentInterface $method);
24+
25+
/**
26+
* Returns the payment method for a specified shopping cart.
27+
*
28+
* @param string $cartId The cart ID.
29+
* @return \Magento\Quote\Api\Data\PaymentInterface Payment method object.
30+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
31+
*/
32+
public function get($cartId);
33+
34+
/**
35+
* Lists available payment methods for a specified shopping cart.
36+
*
37+
* @param string $cartId The cart ID.
38+
* @return \Magento\Quote\Api\Data\PaymentMethodInterface[] Array of payment methods.
39+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
40+
*/
41+
public function getList($cartId);
42+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Api;
7+
8+
/**
9+
* Shipping address management interface for guest carts.
10+
*/
11+
interface GuestShippingAddressManagementInterface
12+
{
13+
/**
14+
* Assigns a specified shipping address to a specified cart.
15+
*
16+
* @param string $cartId The cart ID.
17+
* @param \Magento\Quote\Api\Data\AddressInterface $address The shipping address data.
18+
* @return int Address ID.
19+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
20+
* @throws \Magento\Framework\Exception\InputException The specified cart ID or address data is not valid.
21+
*/
22+
public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address);
23+
24+
/**
25+
* Returns the shipping address for a specified quote.
26+
*
27+
* @param string $cartId The cart ID.
28+
* @return \Magento\Quote\Api\Data\AddressInterface Shipping address object.
29+
* @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart does not exist.
30+
*/
31+
public function get($cartId);
32+
}

0 commit comments

Comments
 (0)