NAV
shell

Introduction

You can use our API to access Letom API endpoints, which can get information on various motels, room types, make reservations and more.

Authentication

To authorize, you must send an Authorization header containing a valid access_token in your request as in the following piece of code:

# With shell, you can just pass the correct header with each request
curl "https://api-letom.herokuapp.com/v1"
  -H "Authorization: SUPER-COOL-ACCESS-TOKEN"
  -H "Accept: application/vnd.letom.v1"

Make sure to replace SUPER-COOL-ACCESS-TOKEN with your access token.

Letom uses access tokens to allow access to the API.

Letom expects for the access tokens to be included in all API requests to the server in a header that looks like the following:

Authorization: SUPER-COOL-ACCESS-TOKEN

If you do not send a valid Authorization header you’ll get a not_authenticated error message:

{
  "errors": "Not authenticated"
}

Base URL

This is the main fragment all requests URLs are based from.

The base URL for API version 1 is

https://letom-st.herokuapp.com/v1

Note on Base URL

This project API is intended to have a custom subdomain api however, when this is deployed to Heroku in the free tier, it is not possible because the platform already provides a subdomain.

Errors

The Letom API uses the following error codes:

Error Code Meaning
401 Unauthorized – Your access token is invalid
404 Not Found – The specified kitten could not be found
500 Internal Server Error – We had a problem with our server. Try again later

Motels

Get All Motels

curl "https://letom-st.herokuapp.com/v1/consumer/motels"
  -H "Authorization: SUPER-COOL-ACCESS-TOKEN"
  -H "Accept: application/vnd.letom.v1"

The above command returns JSON structured like this:

{
  "motels": [
    {
      "id": 1,
      "name": "Vásquez e Hijos",
      "address": "Arrabal Berta Gallegos, 14 Esc. 592",
      "email": "terrill_zulauf@hamillthiel.com",
      "phone": "68-217-1923",
      "profile_pic": "https://robohash.org/expeditaquivoluptates.png?size=300x300&set=set1",
      "cover_pic": "https://robohash.org/autetmolestiae.png?size=300x300&set=set1"
    },
    {
      "id": 2,
      "name": "Pulido, Rivas y Llamas Asociados",
      "address": "Caserio Horacio Camarillo, 2 Esc. 195",
      "email": "hollie.purdy@reinger.info",
      "phone": "28-009-4243",
      "profile_pic": "https://robohash.org/placeataniminemo.png?size=300x300&set=set1",
      "cover_pic": "https://robohash.org/inciduntbeataeimpedit.png?size=300x300&set=set1"
    }
  ]
}

This endpoint retrieves all available letoms.

HTTP Request

GET https://letom-st.herokuapp.com/v1/consumer/motels

Get a Specific Letom

curl "https://letom-st.herokuapp.com/v1/consumer/motels/1"
  -H "Authorization: SUPER-COOL-ACCESS-TOKEN"
  -H "Accept: application/vnd.letom.v1"

The above command returns JSON structured like this:

{
  "motel": {
    "id": 1,
    "name": "Vásquez e Hijos",
    "address": "Arrabal Berta Gallegos, 14 Esc. 592",
    "email": "terrill_zulauf@hamillthiel.com",
    "phone": "68-217-1923",
    "cover_pic": "https://robohash.org/autetmolestiae.png?size=300x300&set=set1",
    "room_types": [
      {
        "id": 1,
        "name": "chimeras",
        "price": "1336",
        "description": "Church-key heirloom retro dreamcatcher. Mlkshk offal mumblecore direct trade street neutra hella. Venmo gastropub asymmetrical jean shorts flexitarian sustainable twee. Austin meh meditation tacos.",
        "cover": "https://robohash.org/autemrecusandaedoloribus.png?size=300x300&set=set1"
      },
      {
        "id": 2,
        "name": "conspirators",
        "price": "4635",
        "description": "Cronut chicharrones food truck vinyl skateboard intelligentsia you probably haven't heard of them. Selvage stumptown letterpress next level intelligentsia pitchfork authentic. Chartreuse irony godard. Pickled health cornhole ennui park drinking twee gastropub. Bicycle rights roof chartreuse.",
        "cover": "https://robohash.org/optiodoloreipsa.png?size=300x300&set=set1"
      }
    ]
  }
}

This endpoint retrieves a specific letom and its RoomTypes.

HTTP Request

GET https://letom-st.herokuapp.com/v1/consumer/motels/<ID>

URL Parameters

Parameter Description
ID The ID of the letom to retrieve

Room Types

Get a Specific Room Type

curl "https://letom-st.herokuapp.com/v1/consumer/room_types/1"
  -H "Authorization: SUPER-COOL-ACCESS-TOKEN"
  -H "Accept: application/vnd.letom.v1"

The above request returns a JSON structured like this:

{
  "room_type": {
    "id": 1,
    "name": "fishes",
    "price": "5556",
    "description": "Swag cred pabst yuccie literally 8-bit kombucha. Umami health whatever jean shorts keffiyeh chicharrones. Scenester vegan normcore disrupt small batch tofu sustainable. Humblebrag pop-up franzen.",
    "available_rooms": 4,
    "room_type_pictures": [
      {
        "id": 16,
        "pic": "https://robohash.org/asperiorespariaturmagni.png?size=300x300&set=set1"
      },
      {
        "id": 17,
        "pic": "https://robohash.org/autdignissimosnihil.png?size=300x300&set=set1"
      }
    ]
  }
}

Get the information of a room type and all its pictures.

HTTP Request

GET "https://letom-st.herokuapp.com/v1/consumer/room_types/<ID>"

URL Parameters

Parameter Description
ID The ID of the room type to retrieve

Reservations

Get a Consumer’s Reservations

curl "https://letom-st.herokuapp.com/v1/consumer/reservations/?email=someemail@address.com"
  -H "Authorization: SUPER-COOL-ACCESS-TOKEN"
  -H "Accept: application/vnd.letom.v1"

The above request returns a JSON structured in following manner:

{
  "reservations": [
    {
      "id": 1,
      "status": "canceled",
      "date_requested": "12 de 09",
      "motel_name": "Vásquez e Hijos",
      "room": {
        "id": 1,
        "name": "giants",
        "description": "Cold-pressed narwhal post-ironic mixtape asymmetrical thundercats put a bird on it. Intelligentsia gluten-free put a bird on it. Ethical gluten-free fingerstache bitters diy. Microdosing messenger bag chicharrones skateboard post-ironic pitchfork."
      }
    },
    {
      "id": 2,
      "status": "canceled",
      "date_requested": "02 de 10",
      "motel_name": "Vásquez e Hijos",
      "room": {
        "id": 5,
        "name": "worshipers",
        "description": "Offal swag vice put a bird on it bespoke. 3 wolf moon paleo squid bitters direct trade intelligentsia flannel vegan. Gluten-free sartorial tattooed blog. Trust fund try-hard swag aesthetic humblebrag blog brooklyn yolo."
      }
    }
  ]
}

Get a consumer’s all reservations made in Letom. The reservation includes the room type reserved.

HTTP Request

GET "https://letom-st.herokuapp.com/v1/consumer/reservations/?email=<CONSUMER-EMAIL-ADDRESS>"

URL Parameters

Parameter Description
email (string) The email address of the current consumer

Create a Reservation

curl -X POST "https://letom-st.herokuapp.com/v1/consumer/reservations"
  -H "Authorization: SUPER-COOL-ACCESS-TOKEN"
  -H "Accept: application/vnd.letom.v1"
  -d '{ "reservation": {
        "room_type_id": 5,
        "email": "c2@email.com" }
      }'

The previous POST request creates a reservations and returns a JSON like this:

{
  "reservation": {
    "id": 9,
    "status": "pending",
    "consumer": {
      "id": 1,
      "name": null,
      "last_name": null,
      "email": "c2@email.com",
      "device_id": "string"
    },
    "room": {
      "id": 5,
      "name": "worshipers",
      "status": "active",
      "available": true
    }
  },
  "meta": {
    "message": "Reserva completada"
  }
}

This endpoint creates a reservation for the current user. The resulting JSON gives information about the reservation’s status, additional data of the consumer and the room type and a custom success message.

HTTP Request

POST https://letom-st.herokuapp.com/v1/consumer/reservations/

Request Parameters

Parameter Description
reservation (hash) A hash containing the room_type_id and the email for creating the reservation
room_type_id (integer) The ID of the room type to be reserved
email (string) The current user’s email address

Get Last User’s Reservation

curl "https://letom-st.herokuapp.com/v1/consumer/reservations/last/?email=someemail@address.com"
  -H "Authorization: SUPER-COOL-ACCESS-TOKEN"
  -H "Accept: application/vnd.letom.v1"

The previoous request returns a JSON structured like this:

{
  "reservation": {
    "id": 9,
    "status": "pending",
    "consumer": {
      "id": 1,
      "name": null,
      "last_name": null,
      "email": "c2@email.com",
      "device_id": "string"
    },
    "room": {
      "id": 5,
      "name": "worshipers",
      "status": "active",
      "available": false
    }
  }
}

Get the current user’s last reservation. The reservation includes the room type reserved and the user’s data.

HTTP Request

GET "https://letom-st.herokuapp.com/v1/consumer/reservations/last/?email=<CONSUMER-EMAIL-ADDRESS>"

URL Parameters

Parameter Description
email (string) The email address of the current consumer

Cancel a Reservation

curl -X PUT "https://letom-st.herokuapp.com/v1/consumer/reservations/?email=someemail@address.com"
  -H "Authorization: SUPER-COOL-ACCESS-TOKEN"
  -H "Accept: application/vnd.letom.v1"

The above request returns a JSON structured in following manner:

{
  "reservation": {
    "id": 9,
    "status": "canceled",
    "consumer": {
      "id": 1,
      "name": null,
      "last_name": null,
      "email": "c2@email.com",
      "device_id": "string"
    },
    "room": {
      "id": 5,
      "name": "worshipers",
      "status": "active",
      "available": false
    }
  }
}

This endpoint finds and cancels the most recent pending reservation a user has made.

HTTP Request

PUT "https://letom-st.herokuapp.com/v1/consumer/reservations/cancel/?email=<CONSUMER-EMAIL-ADDRESS>"

URL Parameters

Parameter Description
email (string) The email address of the current consumer

Consumers

Create Consumer

curl -X POST "https://letom-st.herokuapp.com/v1/consumer/consumers"
  -H "Authorization: meowmeowmeow"
  -H "Accept: application/vnd.letom.v1"
  -d '{ "consumer": {
        "device_id": "somedeviceidstring" }
      }'

The previous request returns a consumer JSON as follows:

{
  "consumer": {
    "id": 2,
    "name": null,
    "last_name": null,
    "email": null,
    "device_id": "somedeviceidstring"
  }
}

Creates a new consumer that will be able to make reservations.

HTTP Request

POST "https://letom-st.herokuapp.com/v1/consumer/consumers"

URL Parameters

Parameter Description
consumer (hash) A hash containing the device_id for registering the user in the databse
device_id (string) String obtained from the current user’s mobile phone