{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/emporix/main/json-schema/emporix-basic-delivery-time-schema.json",
  "title": "Delivery Time",
  "x-generated": "2026-10-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/emporix-shipping-openapi.yml#/components/schemas/BasicDeliveryTime",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Delivery Time ID: Autogenerated (if not provided in request) or User-Defined"
    },
    "name": {
      "type": "string",
      "description": "Optional name for Delivery Time"
    },
    "siteCode": {
      "type": "string",
      "description": "Site code for which the Delivery Time is assigned"
    },
    "isDeliveryDay": {
      "type": "boolean",
      "description": "`true` indicates that the Delivery Time holds delivery date information, whereas `false` represents that the Delivery Time configuration has disabled delivery for a specific date or time period."
    },
    "zoneId": {
      "type": "string",
      "description": "ID of the delivery zone for which the Delivery Time is valid"
    },
    "day": {
      "$ref": "#/$defs/DeliveryDay"
    },
    "slots": {
      "type": "array",
      "description": "This attribute holds information about the established timeslots and cut-off times that are set up for a specific Delivery Time",
      "items": {
        "$ref": "#/$defs/SlotCreation"
      }
    },
    "isForAllZones": {
      "type": "boolean",
      "description": "Flag which indicates if the non-delivery time is defined for the same day, period or weekday for all zones of the site"
    },
    "timeZoneId": {
      "type": "string",
      "description": "Id of the time zone for which the Delivery Time should be created (e.g. Europe/Warsaw)."
    },
    "deliveryDayShift": {
      "type": "integer",
      "minimum": 0,
      "default": 0,
      "description": "Indicates in how many days the order has been delivered when the order has been completed before cut-off time."
    }
  },
  "required": [
    "siteCode",
    "isDeliveryDay",
    "day",
    "timeZoneId"
  ],
  "$defs": {
    "CutOffTIme": {
      "title": "Cut-Off Time",
      "description": "This denotes the latest point in time by which an action (such as an order or request) must be completed for a specific Delivery Time. This attribute is key in determining the end of a time window for certain operations and helps maintain efficiency in the delivery process.",
      "type": "object",
      "properties": {
        "time": {
          "type": "string",
          "description": "The cut-off time refers to the deadline by which an order must be placed to be eligible for same-day processing and shipping. Date is compliant with the ISO 8601 standard, but only time is taking into account."
        },
        "cutOffDayShift": {
          "type": "integer",
          "minimum": 0,
          "default": 0,
          "description": "Indicates in how many days the order has been delivered when the order has been completed before cut-off time. Property is only available for delivery times of weekday type."
        },
        "deliveryCycleName": {
          "type": "string",
          "description": "An optional suffix that is added to delivery cycle name"
        }
      },
      "required": [
        "time"
      ]
    },
    "DeliveryDay": {
      "title": "Delivery Day",
      "type": "object",
      "description": "This attribute holds the time configuration for which the Delivery Time is valid. Only a single attribute can be set at any given moment.",
      "properties": {
        "weekday": {
          "description": "Enum containing names of weekdays, possible values: `MONDAY`, `TUESDAY`, `WEDNESDAY`, `THURSDAY`, `FRIDAY`, `SATURDAY`, `SUNDAY`",
          "type": "string"
        },
        "singleDate": {
          "type": "string",
          "description": "Date for which the delivery time is valid, compliant with the ISO 8601 standard. Dates should be provided at 12:00:00 local time and send in ISO 8601 standard (e.g. For Europe/Warsaw timezone, the 10:00 should be sent - 2023-06-12T10:00:00.000Z)."
        },
        "datePeriod": {
          "type": "object",
          "description": "Date period for which the Delivery Time is valid. Dates should be provided at 12:00:00 local time and send in ISO 8601 standard (e.g. For Europe/Warsaw timezone, the 10:00 should be sent - 2023-06-12T10:00:00.000Z).",
          "properties": {
            "dateFrom": {
              "type": "string",
              "description": "Date from which the delivery time is valid, compliant with the ISO 8601 standard."
            },
            "dateTo": {
              "type": "string",
              "description": "Date to which the delivery time is valid, compliant with the ISO 8601 standard."
            }
          },
          "required": [
            "dateFrom",
            "dateTo"
          ]
        }
      }
    },
    "DeliveryTimeRange": {
      "title": "Time range",
      "description": "A `from` to `to` time range for which the object is valid",
      "type": "object",
      "properties": {
        "timeFrom": {
          "pattern": "^(2[0-3]|[01]?[0-9]):([0-5]?[0-9])$",
          "type": "string",
          "description": "Time from which the object is valid, provided in local time (e.g. 10:00)"
        },
        "timeTo": {
          "pattern": "^(2[0-4]|[01]?[0-9]):([0-5]?[0-9])$",
          "type": "string",
          "description": "Time to which the object is valid, provided in local time (e.g. 10:00)."
        }
      },
      "required": [
        "timeFrom",
        "timeTo"
      ]
    },
    "SlotCreation": {
      "title": "Slot",
      "description": "",
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Delivery Time Slot ID: Autogenerated (if not provided in request) or User-Defined"
        },
        "shippingMethod": {
          "description": "Selected shipping method which is available for the Delivery Time in the given Time Slot",
          "type": "string"
        },
        "deliveryTimeRange": {
          "$ref": "#/$defs/DeliveryTimeRange"
        },
        "cutOffTime": {
          "$ref": "#/$defs/CutOffTIme"
        },
        "capacity": {
          "type": "integer",
          "description": "A capacity determines how many orders the given Delivery Time Slot can handle"
        }
      },
      "required": [
        "shippingMethod",
        "deliveryTimeRange",
        "cutOffTime",
        "capacity"
      ]
    }
  }
}