{
 "openapi": "3.1.0",
 "info": {
  "title": "TotalRig API",
  "version": "1.0.0",
  "description": "Price and request TotalRig RV trailer work in Florida. No authentication. A booking request is not a confirmed appointment and nothing is charged. TotalRig confirms by text or call."
 },
 "servers": [
  {
   "url": "https://totalrig.com"
  }
 ],
 "paths": {
  "/api/catalog": {
   "get": {
    "operationId": "getCatalog",
    "summary": "Services, packages, upgrade options and price rules",
    "responses": {
     "200": {
      "description": "Catalog",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/api/estimate": {
   "post": {
    "operationId": "getEstimate",
    "summary": "Itemized estimate for one service",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "service"
        ],
        "properties": {
         "service": {
          "type": "string",
          "enum": [
           "roof",
           "mobile_response",
           "transport",
           "concierge"
          ]
         },
         "input": {
          "type": "object",
          "description": "Inputs for the service. Option ids are listed at /api/catalog.",
          "properties": {
           "length_ft": {
            "type": "number",
            "description": "roof, transport: overall trailer length in feet"
           },
           "trailer_type": {
            "type": "string",
            "enum": [
             "Bumper pull",
             "Fifth wheel",
             "Toy hauler"
            ]
           },
           "ac": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3,
            "description": "roof: rooftop AC units"
           },
           "vents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5,
            "description": "roof: roof vents"
           },
           "skylights": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3
           },
           "package": {
            "type": "string",
            "enum": [
             "essential",
             "pro",
             "total"
            ]
           },
           "upgrades": {
            "type": "object",
            "description": "roof: {category: option id or 'none'}",
            "additionalProperties": {
             "type": "string"
            }
           },
           "include_roof": {
            "type": "boolean",
            "description": "roof: false prices upgrades only, on a separate visit"
           },
           "compare_packages": {
            "type": "boolean",
            "description": "roof, estimate only: price all three packages"
           },
           "nearest_city": {
            "type": "string",
            "description": "mobile_response: a Florida city from cities_for_mileage"
           },
           "miles_from_hub": {
            "type": "number",
            "description": "mobile_response: miles from New Smyrna Beach, FL"
           },
           "problem": {
            "type": "string",
            "enum": [
             "tire",
             "bearing",
             "brakes",
             "axle",
             "lights",
             "pretrip",
             "other"
            ]
           },
           "response": {
            "type": "string",
            "enum": [
             "onsite",
             "upgrade",
             "haul"
            ]
           },
           "pickup_city": {
            "type": "string"
           },
           "dropoff_city": {
            "type": "string"
           },
           "loaded_miles": {
            "type": "number",
            "description": "transport: miles from pickup to drop-off"
           },
           "option": {
            "type": "string",
            "enum": [
             "haul",
             "haul_setup",
             "haul_setup_site"
            ]
           }
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Estimate with line items and a total, or total_low and total_high",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "errors: what to fix"
     }
    }
   }
  },
  "/api/book": {
   "post": {
    "operationId": "requestBooking",
    "summary": "Send a booking request for a user",
    "description": "Only call after the user has seen the estimate and asked you to send it.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "service",
         "contact"
        ],
        "properties": {
         "service": {
          "type": "string",
          "enum": [
           "roof",
           "mobile_response",
           "transport",
           "concierge"
          ]
         },
         "contact": {
          "type": "object",
          "required": [
           "name",
           "phone"
          ],
          "properties": {
           "name": {
            "type": "string"
           },
           "phone": {
            "type": "string",
            "description": "Mobile number TotalRig can text"
           },
           "email": {
            "type": "string"
           }
          }
         },
         "estimate_input": {
          "type": "object",
          "description": "Inputs for the service. Option ids are listed at /api/catalog.",
          "properties": {
           "length_ft": {
            "type": "number",
            "description": "roof, transport: overall trailer length in feet"
           },
           "trailer_type": {
            "type": "string",
            "enum": [
             "Bumper pull",
             "Fifth wheel",
             "Toy hauler"
            ]
           },
           "ac": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3,
            "description": "roof: rooftop AC units"
           },
           "vents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5,
            "description": "roof: roof vents"
           },
           "skylights": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3
           },
           "package": {
            "type": "string",
            "enum": [
             "essential",
             "pro",
             "total"
            ]
           },
           "upgrades": {
            "type": "object",
            "description": "roof: {category: option id or 'none'}",
            "additionalProperties": {
             "type": "string"
            }
           },
           "include_roof": {
            "type": "boolean",
            "description": "roof: false prices upgrades only, on a separate visit"
           },
           "compare_packages": {
            "type": "boolean",
            "description": "roof, estimate only: price all three packages"
           },
           "nearest_city": {
            "type": "string",
            "description": "mobile_response: a Florida city from cities_for_mileage"
           },
           "miles_from_hub": {
            "type": "number",
            "description": "mobile_response: miles from New Smyrna Beach, FL"
           },
           "problem": {
            "type": "string",
            "enum": [
             "tire",
             "bearing",
             "brakes",
             "axle",
             "lights",
             "pretrip",
             "other"
            ]
           },
           "response": {
            "type": "string",
            "enum": [
             "onsite",
             "upgrade",
             "haul"
            ]
           },
           "pickup_city": {
            "type": "string"
           },
           "dropoff_city": {
            "type": "string"
           },
           "loaded_miles": {
            "type": "number",
            "description": "transport: miles from pickup to drop-off"
           },
           "option": {
            "type": "string",
            "enum": [
             "haul",
             "haul_setup",
             "haul_setup_site"
            ]
           }
          }
         },
         "where": {
          "type": "string",
          "description": "Where the rig is now"
         },
         "when": {
          "type": "string",
          "description": "Preferred date or timing"
         },
         "notes": {
          "type": "string"
         },
         "details": {
          "type": "object",
          "additionalProperties": {
           "type": "string"
          }
         },
         "agent": {
          "type": "string",
          "description": "Name of the assistant sending this"
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "reference, status, estimate, next_step, text_link",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "errors: what to fix"
     }
    }
   }
  }
 }
}