{
  "type": "object",
  "properties": {
    "cost": {
      "type": ["string", "number"],
      "pattern": "^\\d+(\\.\\d{1,2})?$"
    },
    "is_enabled": {
      "type": ["integer", "string", "boolean"],
      "enum": [0, 1, "0", "1", true, false]
    },
    "calculation_type": {
      "type": "string",
      "enum": ["flat_rate", "price_based_rate", "weight_based_rate", "api"]
    },
    "price_based_cost": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "min_price": {
            "type": ["string", "number"],
            "pattern": "^\\d+(\\.\\d{1,2})?$"
          },
          "cost": {
            "type": ["string", "number"],
            "pattern": "^\\d+(\\.\\d{1,2})?$"
          }
        },
        "additionalProperties": false,
        "required": [
          "min_price",
          "cost"
        ]
      }
    },
    "weight_based_cost": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "min_weight": {
            "type": ["string", "number"],
            "pattern": "^\\d+(\\.\\d{1,2})?$"
          },
          "cost": {
            "type": ["string", "number"],
            "pattern": "^\\d+(\\.\\d{1,2})?$"
          }
        },
        "additionalProperties": false,
        "required": [
          "min_weight",
          "cost"
        ]
      }
    },
    "condition_type": {
      "type": "string",
      "enum": ["weight", "price", "none"]
    },
    "calculate_api": {
      "type": "string"
    },
    "min": {
      "type": ["string", "number"],
      "pattern": "^\\d+(\\.\\d{1,2})?$"
    },
    "max": {
      "type": ["string", "number"],
      "pattern": "^\\d+(\\.\\d{1,2})?$"
    }
  },
  "additionalProperties": true,
  "required": [
    "condition_type",
    "calculation_type"
  ]
}
