{
  "openapi": "3.0.3",
  "info": {
    "description": "Compaction API",
    "version": "1.0.0",
    "title": "Compaction API"
  },
  "servers": [
    {
      "url": "https://iris.trackunit.com/api/compaction/v1/compactions",
      "description": "Production Server"
    }
  ],
  "paths": {
    "/searches": {
      "get": {
        "tags": ["Searches"],
        "summary": "Get all saved searches",
        "description": "",
        "operationId": "getAllSavedSearches",
        "parameters": [],
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Searches"],
        "summary": "Create new saved search",
        "description": "",
        "operationId": "createSavedSearch",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/SearchRequest" }
            }
          }
        },
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          }
        }
      }
    },
    "/searches/{searchUUID}": {
      "get": {
        "summary": "Get single saved search",
        "description": "",
        "operationId": "getSavedSearch",
        "parameters": [
          {
            "name": "searchUUID",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Update a saved search",
        "description": "",
        "operationId": "updateSavedSearch",
        "parameters": [
          {
            "name": "searchUUID",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/SearchRequest" }
            }
          }
        },
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Delete a saved search",
        "description": "",
        "operationId": "deleteSavedSearch",
        "parameters": [
          {
            "name": "searchUUID",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchRepresentation"
                }
              }
            }
          }
        }
      }
    },
    "/trips": {
      "post": {
        "summary": "Get a list of trips for given set of assetIds within selected date",
        "description": "",
        "operationId": "getCompactionTrips",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompactionTripsRequest"
              }
            }
          }
        },
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              },
              "application/hal+json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              },
              "application/hal+json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              },
              "application/hal+json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              }
            }
          },
          "404": {
            "description": "Assets not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              },
              "application/hal+json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              },
              "application/hal+json": {
                "schema": { "$ref": "#/components/schemas/TripsRepresentation" }
              }
            }
          }
        }
      }
    },
    "/trips/{tripId}": {
      "get": {
        "summary": "Get single trip",
        "description": "",
        "operationId": "getCompactionTrip",
        "parameters": [
          {
            "name": "tripId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Delete single trip",
        "description": "",
        "operationId": "deleteCompactionTrip",
        "parameters": [
          {
            "name": "tripId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "security": [{ "Authorization": [] }],
        "responses": {
          "204": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionTripRepresentation"
                }
              }
            }
          }
        }
      }
    },
    "/trips/{tripId}/compactions": {
      "get": {
        "summary": "Get a dataset of compaction values for a single trip",
        "description": "",
        "operationId": "getCompactionDataPoints",
        "parameters": [
          {
            "name": "tripId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "format": "date-time" }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "format": "date-time" }
          },
          {
            "name": "offsetlat",
            "in": "query",
            "required": false,
            "schema": { "type": "number", "format": "double" }
          },
          {
            "name": "offsetlon",
            "in": "query",
            "required": false,
            "schema": { "type": "number", "format": "double" }
          }
        ],
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionsRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionsRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionsRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionsRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompactionsRepresentation"
                }
              }
            }
          }
        }
      }
    },
    "/trips/{tripId}/compactions/summarized": {
      "get": {
        "summary": "Get a dataset of summarized compaction values for a single trip",
        "description": "",
        "operationId": "getSummarizedCompaction",
        "parameters": [
          {
            "name": "tripId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "format": "date-time" }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "format": "date-time" }
          },
          {
            "name": "offsetlat",
            "in": "query",
            "required": false,
            "schema": { "type": "number", "format": "double" }
          },
          {
            "name": "offsetlon",
            "in": "query",
            "required": false,
            "schema": { "type": "number", "format": "double" }
          },
          {
            "name": "bucketsizeseconds",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "format": "int32" }
          }
        ],
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SummarizedCompactionsRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SummarizedCompactionsRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SummarizedCompactionsRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SummarizedCompactionsRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SummarizedCompactionsRepresentation"
                }
              }
            }
          }
        }
      }
    },
    "/trips/{tripId}/filter": {
      "get": {
        "summary": "Get filter settings for a single trip",
        "description": "",
        "operationId": "getTripFilter",
        "parameters": [
          {
            "name": "tripId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TripFilterRepresentation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TripFilterRepresentation"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TripFilterRepresentation"
                }
              }
            }
          },
          "404": {
            "description": "Machines not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TripFilterRepresentation"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TripFilterRepresentation"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Update filter settings for a single trip",
        "description": "",
        "operationId": "updateTripFilter",
        "parameters": [
          {
            "name": "tripId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/FilterRepresentation" }
            }
          }
        },
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": { "description": "Success" },
          "400": { "description": "Bad request" },
          "401": { "description": "Unauthorized" },
          "404": { "description": "Machines not found" },
          "500": { "description": "Internal server error" }
        }
      },
      "delete": {
        "summary": "Delete filter settings for a single trip",
        "description": "",
        "operationId": "deleteTripFilter",
        "parameters": [
          {
            "name": "tripId",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "format": "uuid" }
          }
        ],
        "security": [{ "Authorization": [] }],
        "responses": {
          "200": { "description": "Success" },
          "400": { "description": "Bad request" },
          "401": { "description": "Unauthorized" },
          "404": { "description": "Machines not found" },
          "500": { "description": "Internal server error" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "Authorization": {
        "type": "apiKey",
        "name": "Authorization",
        "in": "header"
      }
    },
    "schemas": {
      "CompactionTripRepresentation": {
        "type": "object",
        "properties": {
          "assetId": { "type": "string", "format": "uuid" },
          "machineId": { "type": "integer", "format": "int32" },
          "start": { "type": "string", "format": "date-time" },
          "end": { "type": "string", "format": "date-time" },
          "datapoints": { "type": "integer", "format": "int32" },
          "maxCompaction": { "type": "integer", "format": "int32" },
          "minCompaction": { "type": "integer", "format": "int32" },
          "overCompaction": { "type": "number", "format": "double" },
          "tripId": { "type": "string", "format": "uuid" },
          "width": { "type": "integer", "format": "int32" },
          "plateCount": { "type": "integer", "format": "int32" }
        }
      },
      "CompactionTripsRequest": {
        "type": "object",
        "properties": {
          "assetIds": {
            "type": "array",
            "items": { "type": "string", "format": "uuid" }
          },
          "from": { "type": "string", "format": "date-time" },
          "to": { "type": "string", "format": "date-time" }
        }
      },
      "CompactionsRepresentation": {
        "type": "object",
        "properties": {
          "tripId": { "type": "string", "format": "uuid" },
          "dataPoints": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/DataPointRepresentation" }
          }
        }
      },
      "DataPointRepresentation": {
        "type": "object",
        "properties": {
          "timestamp": { "type": "string", "format": "date-time" },
          "latitude": { "type": "number", "format": "double" },
          "longitude": { "type": "number", "format": "double" },
          "heading": { "type": "number", "format": "double" },
          "compactionValue": { "type": "integer", "format": "int32" },
          "gpsPosValid": { "type": "boolean" },
          "fullThrottle": { "type": "boolean" },
          "powerReduction": { "type": "boolean" },
          "sensorError": { "type": "boolean" },
          "vibrationStatus": { "type": "boolean" }
        }
      },
      "FilterEditRepresentation": {
        "type": "object",
        "properties": {
          "customerId": { "type": "integer", "format": "int32" },
          "customerName": { "type": "string" },
          "userId": { "type": "integer", "format": "int32" },
          "userName": { "type": "string" },
          "editTime": { "type": "string", "format": "date-time" }
        }
      },
      "FilterRepresentation": {
        "type": "object",
        "properties": {
          "from": { "type": "string", "format": "date-time" },
          "to": { "type": "string", "format": "date-time" },
          "offsetLat": { "type": "number", "format": "double" },
          "offsetLon": { "type": "number", "format": "double" },
          "lastEdit": {
            "$ref": "#/components/schemas/FilterEditRepresentation"
          }
        }
      },
      "SearchRepresentation": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "name": { "type": "string" },
          "from": { "type": "string", "format": "date-time" },
          "to": { "type": "string", "format": "date-time" },
          "tripIds": {
            "type": "array",
            "items": { "type": "string", "format": "uuid" }
          }
        }
      },
      "SearchRequest": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "from": { "type": "string", "format": "date-time" },
          "to": { "type": "string", "format": "date-time" },
          "tripIds": {
            "type": "array",
            "items": { "type": "string", "format": "uuid" }
          }
        }
      },
      "SummarizedCompactionsRepresentation": {
        "type": "object",
        "properties": {
          "tripId": { "type": "string", "format": "uuid" },
          "dataPoints": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SummarizedDataPointRepresentation"
            }
          }
        }
      },
      "SummarizedDataPointRepresentation": {
        "type": "object",
        "properties": {
          "timestamp": { "type": "string", "format": "date-time" },
          "compactionValue": { "type": "integer", "format": "int32" },
          "coordinates": {
            "type": "array",
            "items": {
              "type": "array",
              "items": { "type": "number", "format": "double" }
            }
          },
          "centerCoordinates": {
            "type": "array",
            "items": { "type": "number", "format": "double" }
          },
          "gpsPosValid": { "type": "boolean" },
          "fullThrottle": { "type": "boolean" },
          "powerReduction": { "type": "boolean" },
          "sensorError": { "type": "boolean" },
          "vibrationStatus": { "type": "boolean" }
        }
      },
      "TripFilterRepresentation": {
        "type": "object",
        "properties": {
          "tripId": { "type": "string", "format": "uuid" },
          "filter": { "$ref": "#/components/schemas/FilterRepresentation" }
        }
      },
      "TripsRepresentation": {
        "type": "object",
        "properties": {
          "trips": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompactionTripRepresentation"
            }
          }
        }
      }
    }
  },
  "x-readme": { "explorer-enabled": true, "proxy-enabled": true }
}
