Skip to content

Ride Service

Cody Ley-Han edited this page Apr 18, 2018 · 7 revisions

Types

Ride

{
  "id": {
    "description": "Unique identifier",
    "type": "string"
  },
  "driver_id": {
    "description": "Unique identifier related to a user id",
    "type": "string"
  },
  "car_id": {
    "description": "Unique identifier related to a car id",
    "type": "string"
  },
  "seats": {
    "description": "Number of seats available for a ride",
    "type": "integer",
    "exclusiveMinimum": 0
  },
  "start_city": {
    "description": "Where the ride will start",
    "type": "string"
  },
  "end_city": {
    "description": "Where the ride will end",
    "type": "string"
  },
  "start_dest_lat": {
    "description": "Ride starting longitude/latitude",
    "type": "float"
  },
  "start_dest_lon": {
    "description": "Ride starting longitude/latitude",
    "type": "float"
  },
  "end_dest_lat": {
    "description": "Ride final longitude/latitude",
    "type": "float"
  },
  "end_dest_lon": {
    "description": "Ride final longitude/latitude",
    "type": "float"
  },
  "start_date": {
    "description": "Date ride leaves for end destination",
    "type": "string",
    "format": "date-time in RFC3339 format"
  },
  "price_per_seat": {
    "description": "Cost for a seat in a ride",
    "type": "integer",
    "exclusiveMinimum": 0
  },
  "info": {
    "description": "Extra informaton pertaining to the ride",
    "type": "string"
  },
  "created_at": {
    "type": "string",
    "format": "date-time in RFC3339 format"
  },
  "updated_at": {
    "type": "string",
    "format": "date-time in RFC3339 format"
  }
}

Endpoints

List: GET /api/v1/rides/

** Request **

Optional Query params

limit: integer between 1 and 100
last: the id of the last ride
``

**Response**
```json
{
    "data": ["Ride"]
}

Show: GET /api/v1/rides/:id

Response

{
    "data": "Ride"
}

Create: POST /api/v1/rides

Request

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "properties": {
    "car_id": {
      "description": "Unique identifier related to a car id",
      "type": "string"
    },
    "seats": {
      "description": "Number of seats available for a ride",
      "type": "integer",
      "exclusiveMinimum": 0
    },
    "start_city": {
      "description": "Where the ride will start",
      "type": "string"
    },
    "end_city": {
      "description": "Where the ride will end",
      "type": "string"
    },
    "start_dest_lat": {
      "description": "10.10, ingestible by Google Maps API",
      "type": "float",
      "inclusiveMinimum": -90.0,
      "inclusiveMaximum": 90.0
    },
    "start_dest_lon": {
      "description": "10.10, ingestible by Google Maps API",
      "type": "float",
      "inclusiveMinimum": -180.0,
      "inclusiveMaximum": 180.0
    },
    "end_dest_lat": {
      "description": "10.10, ingestible by Google Maps API",
      "type": "float",
      "inclusiveMinimum": -90.0,
      "inclusiveMaximum": 90.0
    },
    "end_dest_lon": {
      "description": "10.10, ingestible by Google Maps API",
      "type": "float",
      "inclusiveMinimum": -180.0,
      "inclusiveMaximum": 180.0
    },
    "start_date": {
      "description": "2018-04-04T15:00:00Z must be greater than the current time",
      "type": "date in format RFC3339"
    },
    "price_per_seat": {
      "description": "15 (dollars)",
      "type": "integer",
      "exclusiveMinimum": 0
    },
    "info": {
      "description": "Extra informaton pertaining to the ride",
      "type": "string"
    }
  },
  "required": [
      "car_id",
      "seats",
      "start_city",
      "end_city",
      "start_dest_lat",
      "start_dest_lon",
      "end_dest_lat",
      "end_dest_lon",
      "start_date",
      "price_per_seat"
  ]
}

Response

Status Code: 201

{
    "data": "Rides"
}

Create: PUT /api/v1/rides

Request

TODO

Response

Status Code: 202

{
    "data": "Ride"
}

Delete: DELETE /api/v1/rides/:id

Status Code: 204