{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nogpets-com/json-schema/nogpets-com-times-schema.json",
  "title": "Times",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nogpets-com-openapi.json#/components/schemas/Times",
  "type": "object",
  "required": [
    "durationMin",
    "quote",
    "days"
  ],
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "NO_AVAILABILITY"
      ]
    },
    "reason": {
      "type": "string",
      "enum": [
        "OUTSIDE_HOURS",
        "CLOSED_DAY",
        "FULLY_BOOKED"
      ],
      "description": "NO_AVAILABILITY: why nothing is open then. OUTSIDE_HOURS: the service can't fit inside working hours or the window asked; CLOSED_DAY: nobody works that day; FULLY_BOOKED: it fits but every time is taken."
    },
    "alternatives": {
      "type": "array",
      "description": "NO_AVAILABILITY: the next open times (up to 5, within 14 days). Offer these; book with start and resourceId unchanged.",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "date": {
            "$ref": "#/$defs/Date"
          },
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "resourceId": {
            "type": "string"
          }
        }
      }
    },
    "next": {
      "type": "string",
      "description": "NO_AVAILABILITY: what to do next."
    },
    "leadId": {
      "type": [
        "string",
        "null"
      ],
      "description": "NO_AVAILABILITY with no alternatives: the request is kept so our team or a partner can come back to the person."
    },
    "message": {
      "type": "string",
      "description": "NO_AVAILABILITY: what to tell the person: the real reason and the next open times, or (none in 14 days) that we'll find someone."
    },
    "durationMin": {
      "type": "integer"
    },
    "quote": {
      "$ref": "#/$defs/Quote"
    },
    "days": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Day"
      }
    },
    "mode": {
      "type": "string",
      "enum": [
        "SLOT",
        "STAY"
      ],
      "description": "STAY: an overnight service; book it with `stay`, not a start time."
    },
    "multiDay": {
      "type": "boolean",
      "description": "The service can also be booked as visits over several days (`visits`)."
    },
    "windows": {
      "type": [
        "object",
        "null"
      ],
      "description": "The windows to offer: STAY {evening, morning}, multiDay {visit}; each [{id, label, start, end, text}]."
    },
    "plan": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/Plan"
        }
      ]
    }
  },
  "$defs": {
    "Date": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
      "description": "A local date, YYYY-MM-DD."
    },
    "Day": {
      "type": "object",
      "required": [
        "date",
        "label",
        "slots"
      ],
      "properties": {
        "date": {
          "$ref": "#/$defs/Date"
        },
        "label": {
          "type": "string"
        },
        "slots": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Slot"
          }
        }
      }
    },
    "Discount": {
      "type": "object",
      "required": [
        "code",
        "amountCents"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "amountCents": {
          "type": "integer",
          "description": "What came off the price (never the card fee)."
        },
        "auto": {
          "type": "boolean"
        }
      }
    },
    "Item": {
      "type": "object",
      "required": [
        "serviceId",
        "name",
        "kind",
        "priceCents",
        "durationMin"
      ],
      "properties": {
        "serviceId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "PRIMARY",
            "EXTRA"
          ]
        },
        "priceCents": {
          "type": "integer"
        },
        "durationMin": {
          "type": "integer"
        }
      }
    },
    "Plan": {
      "type": "object",
      "required": [
        "mode",
        "label",
        "ok",
        "spans"
      ],
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "STAY",
            "MULTI_VISIT"
          ]
        },
        "label": {
          "type": "string"
        },
        "ok": {
          "type": "boolean",
          "description": "Every night or visit has a free sitter."
        },
        "spans": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "date": {
                "$ref": "#/$defs/Date"
              },
              "start": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "end": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "window": {
                "type": "string"
              },
              "free": {
                "type": "boolean"
              }
            }
          }
        }
      }
    },
    "Quote": {
      "type": "object",
      "required": [
        "category",
        "durationMin",
        "pets",
        "subtotalCents",
        "cardFeeCents",
        "cardTotalCents",
        "acceptsCash",
        "summary"
      ],
      "properties": {
        "category": {
          "type": "string"
        },
        "durationMin": {
          "type": "integer"
        },
        "pets": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "items"
            ],
            "properties": {
              "petId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/Item"
                }
              },
              "package": {
                "type": "object",
                "description": "The package chosen; items are its parts at list price and savingCents comes off.",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "savingCents": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "subtotalCents": {
          "type": "integer"
        },
        "cardFeeCents": {
          "type": "integer"
        },
        "cardTotalCents": {
          "type": "integer"
        },
        "cashTotalCents": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Null when cash isn't taken. After the discount."
        },
        "discount": {
          "description": "The promo code applied (cardTotalCents and cashTotalCents are after it). `auto` when it came from the person's claimed offer.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/Discount"
            }
          ]
        },
        "discountError": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "UNKNOWN",
            "INACTIVE",
            "NOT_STARTED",
            "EXPIRED",
            "USED_UP",
            "NOT_APPLICABLE",
            "NOT_FIRST",
            "LIMIT_REACHED",
            "MIN_SUBTOTAL",
            null
          ],
          "description": "Why promoCode can't be used. The quote is then without it."
        },
        "acceptsCash": {
          "type": "boolean"
        },
        "group": {
          "type": [
            "object",
            "null"
          ],
          "description": "A group walk: {serviceId, size, dogs}."
        },
        "summary": {
          "type": "string"
        }
      }
    },
    "Slot": {
      "type": "object",
      "required": [
        "start",
        "time",
        "resourceId"
      ],
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time"
        },
        "time": {
          "type": "string",
          "description": "Local HH:MM."
        },
        "resourceId": {
          "type": "string"
        }
      }
    }
  }
}