Set service availability

This topic demonstrates the implementations of the syncStore API for specifying the availability of dine-in, pickup, or delivery services.

Overview

You can make a service unavailable during a specific period. In the food and beverage industry, a store can configure different service types, including:

  • Pickup: Users pick up the food themselves.
  • Dine-in: Users dine in the eatery.
  • Delivery: Users have their food delivered to a specific destination.

Use case

To set service availability, specify the store.bizRules.scene parameter as DELIVERY_SCHEDULE, PICKUP_SCHEDULE, or DINE_IN_SCHEDULE, and the ruleData parameter with specific schedule rules.

Things to know:

  • The startTime and endTime parameters are mandatory.
  • Specify the serviceStatus parameter as OFF, which indicates a service is suspended during a specified time period.

The following demonstrates an example of ruleData before serialization:

copy
{
    "startTime": "2022-10-18T00:00:01+08:00",  //Mandatory
    "endTime": "2022-10-19T23:59:59+08:00",    //Mandatory
    "scheduleType": "DAILY",
    "serviceStatus": "OFF",
    "supportDays": 2,
    "schedules": {
      "FIXED": [
        {
          "startTime": "12:00+08:00",
          "endTime": "13:00+08:00"
        }
      ]
    }
  }

Make sure to include existing service schedules and put the exceptional schedules in the last index, otherwise, the exceptional ones might be overwritten.

See the following example before serialization:

copy
[
    {
        "scheduleType": "DAILY",
        "supportDays": 6,
        "schedules": {
            "FIXED": [
                {
                    "startTime": "11:00+08:00",
                    "endTime": "11:30+08:00"
                },
                {
                    "startTime": "11:30+08:00",
                    "endTime": "12:00+08:00"
                },
                {
                    "startTime": "12:00+08:00",
                    "endTime": "12:30+08:00"
                },
                {
                    "startTime": "12:30+08:00",
                    "endTime": "13:00+08:00"
                }
            ]
        }
    },
    {
        "startTime": "2022-10-18T00:00:01+08:00",
        "endTime": "2022-10-19T23:59:59+08:00",
        "scheduleType": "DAILY",
        "serviceStatus": "OFF",
        "supportDays": 2,
        "schedules": {
            "FIXED": [
                {
                    "startTime": "12:00+08:00",
                    "endTime": "13:00+08:00"
                }
            ]
        }
    }
]

Now, take the delivery service as an example:

  • On regular days, the delivery service is available from 11: 00 to 13: 00.
  • From 2022-10-18T00:00:01+08:00 to 2022-10-19T23:59:59+08:00, the delivery service is turned off from 12:00 to 13:00. Then the delivery service is available from 11:00 to 12:00 during the specified period.
copy
{
    "requestId": "12222211****",
    "appId": "21020101154****",
    "store": {
        "storeId": "20221003delivery_storeid01",
        "bizRules": [
            {
                "scene": "DELIVERY_SCHEDULE",
                "ruleData": "[{\"scheduleType\":\"DAILY\",\"supportDays\":6,\"schedules\":{\"FIXED\":[{\"startTime\":\"11:00+08:00\",\"endTime\":\"11:30+08:00\"},{\"startTime\":\"11:30+08:00\",\"endTime\":\"12:00+08:00\"},{\"startTime\":\"12:00+08:00\",\"endTime\":\"12:30+08:00\"},{\"startTime\":\"12:30+08:00\",\"endTime\":\"13:00+08:00\"}]}},{\"startTime\":\"2022-10-18T00:00:01+08:00\",\"endTime\":\"2022-10-19T23:59:59+08:00\",\"scheduleType\":\"DAILY\",\"serviceStatus\":\"OFF\",\"supportDays\":2,\"schedules\":{\"FIXED\":[{\"startTime\":\"12:00+08:00\",\"endTime\":\"13:00+08:00\"}]}}]"
            },
            {
                "scene": "DELIVERY_DISTANCE",
                "ruleData": "[{\"from\":0,\"to\":5000,\"fee\":{\"currency\":\"SGD\",\"value\":500},\"minimumOrderAmount\":{\"currency\":\"SGD\",\"value\":1000},\"discounts\":[{\"discountType\":\"REDUCE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":1000},\"discountValue\":\"{\\\"currency\\\": \\\"SGD\\\", \\\"value\\\":1000}\"},{\"discountType\":\"PERCENTAGE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":100},\"discountValue\":\"20\"},{\"discountType\":\"EXEMPTION\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":3000}}]},{\"from\":5000,\"to\":10000,\"fee\":{\"currency\":\"SGD\",\"value\":1000},\"minimumOrderAmount\":{\"currency\":\"SGD\",\"value\":2000},\"discounts\":[{\"discountType\":\"REDUCE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":2000},\"discountValue\":\"{\\\"currency\\\": \\\"SGD\\\", \\\"value\\\":1000}\"},{\"discountType\":\"PERCENTAGE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":3000},\"discountValue\":\"20\"},{\"discountType\":\"EXEMPTION\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":4000}}]},{\"from\":10000,\"to\":100000,\"fee\":{\"currency\":\"SGD\",\"value\":2000},\"minimumOrderAmount\":{\"currency\":\"SGD\",\"value\":5000},\"discounts\":[{\"discountType\":\"REDUCE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":5000},\"discountValue\":\"{\\\"currency\\\": \\\"SGD\\\", \\\"value\\\":1000}\"},{\"discountType\":\"PERCENTAGE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":6000},\"discountValue\":\"20\"},{\"discountType\":\"EXEMPTION\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"value\":7000}}]}]"
            }
        ]
    }
}