{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://openbeautystandard.org/schema/0.9/common.schema.json",
 "title": "OBS common definitions",
 "$defs": {
  "obs_version": {
   "type": "string",
   "description": "informational: the OBS version the sender speaks (0.9); any value is accepted"
  },
  "code": {
   "type": "string",
   "pattern": "^(0[1-9]|[1-9][0-9])(\\.(0[1-9]|[1-9][0-9])){0,2}$",
   "description": "An OBS code: two digits per level, 00 reserved; a string, never a number."
  },
  "local_code": {
   "type": "string",
   "pattern": "^(0[1-9]|[1-9][0-9])$"
  },
  "facets": {
   "type": "object",
   "additionalProperties": {
    "type": "string"
   },
   "description": "Facet values the line states. A facet left out is unstated, never a wildcard. Unknown facets or values are ignored, never an error.",
   "properties": {
    "line": {
     "type": "string",
     "description": "Kind of line; known values: service, add_on, combo, package, membership, consultation, product, gift_card, fee, class"
    },
    "visit": {
     "type": "string",
     "description": "Visit; known values: full, fill, removal, repair, trial, follow_up"
    },
    "audience": {
     "type": "string",
     "description": "For; known values: any, women, men, kids, teens, seniors"
    },
    "client": {
     "type": "string",
     "description": "Client; known values: any, new, returning"
    },
    "extent": {
     "type": "string",
     "description": "How much; known values: unstated, full, partial, single"
    },
    "length": {
     "type": "string",
     "description": "Hair or nail length; known values: unstated, short, medium, long, extra_long"
    },
    "area": {
     "type": "string",
     "description": "Area; known values: unstated, brows, lip, chin, face, underarms, arms, legs, bikini, brazilian, back, chest, body"
    },
    "level": {
     "type": "string",
     "description": "Professional's level; known values: unstated, junior, stylist, senior, master"
    },
    "basis": {
     "type": "string",
     "description": "Price is; known values: fixed, from, range, per_unit, hourly, free, on_request"
    }
   }
  },
  "currency": {
   "type": "string",
   "pattern": "^[A-Z]{3}$",
   "description": "ISO 4217"
  },
  "price": {
   "type": "object",
   "required": [
    "currency"
   ],
   "properties": {
    "amount": {
     "type": "number",
     "minimum": 0,
     "description": "fixed: the price; from: the lowest; per_unit / hourly: per unit or hour"
    },
    "max": {
     "type": "number",
     "minimum": 0,
     "description": "range: the highest"
    },
    "currency": {
     "$ref": "#/$defs/currency"
    },
    "basis": {
     "enum": [
      "fixed",
      "from",
      "range",
      "per_unit",
      "hourly",
      "free",
      "on_request",
      "unstated"
     ]
    },
    "unit": {
     "type": "string",
     "description": "per_unit: what one unit is (unit, strand, area, syringe...); hourly: hour"
    },
    "quantity": {
     "type": "integer",
     "minimum": 1,
     "description": "package: how many visits or sessions"
    },
    "promotional": {
     "type": "boolean",
     "description": "a promotional or introductory price"
    },
    "additional_charges": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "label",
       "amount"
      ],
      "properties": {
       "label": {
        "type": "string"
       },
       "amount": {
        "type": "number",
        "minimum": 0
       },
       "mandatory": {
        "type": "boolean"
       }
      }
     }
    }
   }
  },
  "provider_extension": {
   "type": "object",
   "required": [
    "namespace",
    "code",
    "label"
   ],
   "description": "A provider's own offering under a canonical code. Its identity is (namespace, service_code, code); it never redefines the concept, and a client that doesn't know it uses service_code.",
   "properties": {
    "namespace": {
     "type": "string",
     "format": "uri",
     "pattern": "^https://[^/]+",
     "description": "An https address on a domain the provider controls"
    },
    "code": {
     "$ref": "#/$defs/local_code"
    },
    "label": {
     "type": "string",
     "minLength": 1
    }
   }
  },
  "evidence": {
   "type": "object",
   "required": [
    "source_type",
    "scope",
    "observed_at"
   ],
   "properties": {
    "source_type": {
     "enum": [
      "provider_menu",
      "booking_page",
      "professional_page",
      "salon_page",
      "professional_statement",
      "provider_api",
      "other"
     ]
    },
    "scope": {
     "enum": [
      "business",
      "professional"
     ],
     "description": "business: what the business offers; professional: a named person's own claim"
    },
    "professional_id": {
     "type": "string"
    },
    "source_url": {
     "type": "string",
     "format": "uri"
    },
    "observed_at": {
     "type": "string",
     "format": "date"
    },
    "text": {
     "type": "string",
     "description": "the words as written"
    },
    "claim": {
     "type": "string",
     "description": "explicit (the source says it) or inferred (read from context, such as a heading)"
    }
   }
  },
  "error": {
   "type": "object",
   "required": [
    "code",
    "message"
   ],
   "properties": {
    "code": {
     "type": "string",
     "description": "invalid_request (no usable service_code) or internal; anything else is a note, not an error"
    },
    "message": {
     "type": "string"
    },
    "replaced_by": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/code"
     }
    },
    "supported_versions": {
     "type": "array",
     "items": {
      "type": "string"
     }
    }
   }
  }
 }
}
