Create a Basket

Service URL: POST /baskets

Request Body:

ICreateBasketRequest

basketName – String – The name for the new basket – Optional, generated if not supplied

basketType – String – The type of basket to create – Optional, can be ‘WISHLIST’ or ‘BASKET’. If not supplied it will default to ‘WISHLIST’

basketReference – String – The unique identifier for this basket – Optional, generated if not supplied. If this is supplied, it must be unique

forOrder – Boolean – Should the basket be used to create an order – Optional, defaults to true

deviceId – String – The identifier of the Enactor Device that will represent the “terminal” the basket is being created for. If not supplied a default device will be used (specified using the Enactor configuration files)

customerDetails – CustomerDetails – An object that describes the details of the customer – Optional. If not supplied customer details will be loaded from the local database

Response Headers:

Location: /baskets/{basketReference}

Remarks:

Creates a new empty basket with the given name. The reference for the new basket is returned in the response headers. If the accessToken contains customer details, the basket will be associated with the customer, otherwise the basket is anonymous. 

The type determines what kind of basket to create, can be supplied as ‘WISHLIST’ or ‘BASKET’. 

If the type is ‘BASKET’ the basket can be recalled on the POS as a ‘full’ basket – if the basket type is ‘WISHLIST’ and the basket is recalled on the POS, only the items in the basket will be carried over. Note this does not restrict the capabilities of the Basket Rest API itself

If the name is not supplied, the service will generate one, using a simple incrementing number for the number of wishlists the customer has, or if the customer is anonymous the name will be just set to ‘Wish List’.

If the ‘forOrder’ flag is not supplied, or is true, the basket will default to an ‘order’ – otherwise items in the basket will be regular ‘sale’ items.

The ‘deviceId’ property allows you to control which terminal in the Enactor estate is used to control which terminal/location specific behaviour Enactor will apply – for example this could be use to offer different pricing for different regions. If this is not supplied, it will default based on the Enactor configuration files

Customer details may be supplied when the basket is created – if so, Enactor will not attempt to lookup customer details in its local database

Scenarios:

ScenarioOutcomeExpected behaviourStatus CodeResponse
1Create basket service has been given an empty requestSuccessAnnoymous basket is created and stored as a WISHLIST basket, and with a generated/incremented basket name.201Location Header: BasketReference 
2Create basket service has been given a basket nameSuccessAnnoymous basket is created and stored with the basket name201Location Header: BasketReference 
3Create basket service has not given a basket name.SuccessAnnoymous basket is created and stored with a generated/incremented basket name.201Location Header: BasketReference 
4Create basket service has been given a WISHLIST basket typeSuccessAnnoymous basket is created and stored as a WISHLIST basket201Location Header: BasketReference 
5Create basket service has been given customer detailsSuccessA customer associated basket is created and stored201Location Header: BasketReference 
6Create basket service has been given a PRIMARY basket typeFailThe process checks and basket type for PRIMARY and should fail. 405Error Message: Not Allowed to create basket
7Create Basket Service has recieved a request with a basket name that already existsAlreadyExistsThe basket is not created. An error message of 400 – Bad Request is returned.400Error Message: Bad Request. A customer with that name already exists. outcome Already Exists.
8Create basket service has received a request to create a ANONYMOUS basket SuccessAnonymous basket is create and stored as an ANONYMOUS basket with a generate/incremented basket name (if not supplied)201Location Header: BasketReference

Request:
Example Create Basket Request

POST: http://localhost:8080/WebRestApi/rest/baskets
Content-Type: application/json
 
{
    "basketType": "WISHLIST",
    "basketName": "Xmas Wishlist"
}

Response:

Status: 201 createdLocation: http://localhost:8080/WebRestApi/rest/baskets/MUCFJAIBTVDK3HHNC444ZALMV4

 Full Example

Request:

POST: http://localhost:8080/WebRestApi/rest/baskets
Content-Type: application/json
 
{
    "basketName": "HeadlessExample"
    "basketType": "BASKET",
    "basketReference": "MyRef
    "forOrder": false,
    "deviceId": "pos1@0003.enactor",
    "customerDetails": {
        "name": {
            "forename": "TestForename",
            "surname": "TestSurname"
        },
        "address": {
            "street1": "TestStreet1",
            "street2": "TestStreet2",
            "street3": "TestStreet3",
            "town": "Town"
            "county": "County"
            "province": "Province"
            "country": "Country"
            "countryCode": "CountryCode"
            "postCode": "PostCode"
        },
        "emailAddress": {
            "emailAddress": "test@email.com"
        },
        "phoneNumber": {
            "number": "01992 100 200"
        }
    }
}

Response:

Status: 201 createdLocation: http://localhost:8080/WebRestApi/rest/baskets/MUCFJAIBTVDK3HHNC444ZALMV4
Go to Top