Service URL: PATCH /baskets/{basketReference}/customer
Tokens:
basketReference – The basket reference of the basket to add the items to, or can be ‘PRIMARY’ to add to the PRIMARY basket.
Parameters:
mergeRule – String – Determines how to behave if there is a merge conflict – Optional, defaults to ERROR
returnBasket – Boolean – If true the updated basket is returned – Optional, defaults to true
Response:
BasketResponse – The updated basket, if returnBasket is true
basket – IBasket – The basket associated with the given reference
basketReference – String – the reference of the basket
basketType – String – the type of the basket
basketDescription – String – the description of the basket
basketResponseCode – String – A specific basket code to indict whether the basket was implicitly created by the server.
basketStatus – String – the status of the basket. Fresh baskets have the status NEW. Baskets in progress have the status of IN_PROGRESS. Baskets will have been submitted to retail processing have the status SUBMITTED.
Remarks:
Updates the basket so it is associated with the customer using the accessToken to determine the customer id. Note that this does not set the ‘CustomerRetailDetails’ on the basket.
When the basket is associated with the customer this may result in a conflict:
i. If the basket is a primary basket, but the customer already has a primary basket, or
ii. If the basket is a wishlist and the customer already has a wishlist with the same name.
In these cases the following table determines how the system should behave, as controlled by the mergeRule parameter:
Merge Rule | Result |
---|---|
ERROR | Return an error and do not make any changes |
MERGE | Copy items from the incoming basket into the existing basket. Return the existing basket and its reference. Discard the incoming basket. |
OVERWRITE | Associate the incoming basket with the customer and overwrite any existing basket. Return the basket and its reference. |
DISCARD | Discard the incoming basket. Return the existing basket and its reference. |
Notes:
The service checks for an existing wishlist basket by looking for a stored basket with a basket type of WISHLIST, and matches the basket description of the incoming baskets.
Merge Rule Scenarios:
No Merge Rule:
Scenario | Outcome | Expected behaviour | Status Code | Response | |
---|---|---|---|---|---|
1 | Basket manager service recieves an associate basket customer request with no merge rule | Fail | Return an error and do not make any changes | 500 | ErrorMessage: Failed to associate basket with customer, outcome (500) |
Error:
Scenario | Outcome | Expected behaviour | Status Code | Response | |
---|---|---|---|---|---|
1 | Basket manager service recieves an associate basket customer request with the merge Rule of ERROR. | Fail | Return an error and do not make any changes | 500 | ErrorMessage: Failed to associate basket with customer, outcome (500) |
Merge:
All Scenarios start with: Basket manager service recieves an associate basket customer request with the merge Rule of MERGE.
Scenario | Outcome | Expected behaviour | Status Code | Response | |
---|---|---|---|---|---|
1 | The customer wants to associate a Primary basket (Annoymous primary basket). | Success | Copy items from the incoming basket into the existing basket. Return the existing basket and its reference. Discard the incoming basket. | 200 | Return the existing basket (BasketResponse) |
2 | The customer wants to associate a Wishlist basket. (Annoymous wishlist basket). The existing basket already exists. | Success | Copy items from the incoming basket into the existing basket. Return the existing basket and its reference. Discard the incoming basket. | 200 | Return the existing basket (BasketResponse) |
3 | The customer wants to associate a Wishlist basket. (Annoymous wishlist basket). The existing basket does not exists. | Success | Stored the incoming basket as a new basket against the customer. Return the existing basket and its reference. Discard the incoming basket. | 200 | Return the existing basket (BasketResponse) |
4 | The customer wants to associate a Wishlist basket which is already associated with a customer | NotAllowed | Return a NotAllowed error and do not make any changes | 400: Bad Request | ErrorMessage: Failed to associate basket with customer. Basket already associated with customer, outcome (500) |
Overwrite:
Scenario | Outcome | Expected behaviour | Status Code | Response | |
---|---|---|---|---|---|
1 | The customer wants to associate a Primary basket (Annoymous primary basket). | Success | Associate the incoming basket with the customer and overwrite any existing basket. Return the basket and its reference. | 200 | Return the existing basket (BasketResponse) |
2 | The customer wants to associate a Primary basket (Annoymous wishlist basket). | Success | Associate the incoming basket with the customer and overwrite any existing basket. Return the basket and its reference. | 200 | Return the existing basket (BasketResponse) |
Discard:
All Scenarios start with: Basket manager service recieves an associate basket customer request with the merge Rule of DISCARD.
Scenario | Outcome | Expected behaviour | Status Code | Response | |
---|---|---|---|---|---|
1 | The customer wants discard the incoming wishlist basket. | Success | 200 | IBasketResponse: basket, basketReference… | |
2 | The customer wants discard the incoming primary basket | Success | The incoming basket is discarded. Returns the customers existing primary basket and its reference. | 200 | IBasketResponse: basket, basketReference… |