Associate a Basket with a Customer

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 RuleResult
ERRORReturn an error and do not make any changes
MERGECopy items from the incoming basket into the existing basket. Return the existing basket and its reference. Discard the incoming basket.
OVERWRITEAssociate the incoming basket with the customer and overwrite any existing basket. Return the basket and its reference.
DISCARDDiscard 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:

ScenarioOutcomeExpected behaviourStatus CodeResponse
1Basket manager service recieves an associate basket customer request with no merge ruleFailReturn an error and do not make any changes500ErrorMessage: Failed to associate basket with customer, outcome (500)

Error:

ScenarioOutcomeExpected behaviourStatus CodeResponse
1Basket manager service recieves an associate basket customer request with the merge Rule of ERROR.FailReturn an error and do not make any changes500ErrorMessage: 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.

ScenarioOutcomeExpected behaviourStatus CodeResponse
1The customer wants to associate a Primary basket (Annoymous primary basket).SuccessCopy items from the incoming basket into the existing basket. Return the existing basket and its reference. Discard the incoming basket.200Return the existing basket (BasketResponse)
2The customer wants to associate a Wishlist basket. (Annoymous wishlist basket). The existing basket already exists.SuccessCopy items from the incoming basket into the existing basket. Return the existing basket and its reference. Discard the incoming basket.200Return the existing basket (BasketResponse)
3The customer wants to associate a Wishlist basket. (Annoymous wishlist basket). The existing basket does not exists.SuccessStored the incoming basket as a new basket against the customer. Return the existing basket and its reference. Discard the incoming basket.200Return the existing basket (BasketResponse)
4The customer wants to associate a Wishlist basket which is already associated with a customerNotAllowedReturn a NotAllowed error and do not make any changes400: Bad RequestErrorMessage: Failed to associate basket with customer. Basket already associated with customer, outcome (500)


Overwrite:

ScenarioOutcomeExpected behaviourStatus CodeResponse
1The customer wants to associate a Primary basket (Annoymous primary basket).SuccessAssociate the incoming basket with the customer and overwrite any existing basket. Return the basket and its reference.200Return the existing basket (BasketResponse)
2The customer wants to associate a Primary basket (Annoymous wishlist basket).SuccessAssociate the incoming basket with the customer and overwrite any existing basket. Return the basket and its reference.200Return the existing basket (BasketResponse)

Discard:

All Scenarios start with: Basket manager service recieves an associate basket customer request with the merge Rule of DISCARD.

ScenarioOutcomeExpected behaviourStatus CodeResponse
1The customer wants discard the incoming wishlist basket.Success200IBasketResponse: basket, basketReference…
2The customer wants discard the incoming primary basketSuccessThe incoming basket is discarded. Returns the customers existing primary basket and its reference.200IBasketResponse: basket, basketReference…
Go to Top