See all articles

How we used Ruby to deliver integration layer with reservation systems - case study

Ruby is long known for its versatility and reliability. One of Ruby’s many use cases and something we can find in most of the projects is integration with external services via a provided API. In this case study, we’ll go through the details of a project where we built an external API integration for a camping platform.

The challenge

Our client provides web and mobile apps that help travelers find campsites around the US. Our task was to enable real estate owners who had already been using a Property Management System to list their estates for rent in the client’s app.

In order to achieve that we needed to integrate the client’s application with Property Management Systems. In technical terms, our job was to enable storing certain properties in our database and using them to make reservations of properties.

At first sight, the task sounded clear and pretty straightforward. We’d have to fetch the data, apply some operations, and add push requests to external APIs to claim reservations. However, we also realized that we’d have to find a way to keep static data on our side and ensure consistency between our database and the external service.

Storing static data in our database

We had to encode the data that was sent to and received from API endpoints. The static data consisted of predefined dictionary values used by PMSs, such as _a list of property types, amenities,_ etc. But apart from fetching this data, we had to bear in mind that it will change and therefore be updated.

Even though storing the data in the database and updating it regularly may seem like the best and simplest solution, in this case, we decided to cache the data in Redis. Why? The speed – of processing data in the cache memory is much more time-effective than processing the same data from other storage solutions.

At the same time, the documentation suggests updating static data every 3 months, and we wanted to have the possibility to adjust the data expiration time based on our client’s business needs.

Keeping consistency between our and the external databases

The second challenge we were facing – the one related to ensuring data consistency between the databases – was more interesting for our team. The business requirement for the application was to have information about a campsite’s availability in a requested date range and the price for a selected period. The information in our database had to match the corresponding data in the PMS.

Theoretically, we could schedule some workers to check for updates regularly, for example, every hour, and that way we would keep our database updated – but that’s not enough. The reality of the travel industry is much more dynamic than that. In one hour, a property could be double-booked, the price could have changed, etc. Therefore, providing updated information and double-checking it right before substantial operations, such as booking a cabin or an RV, was essential.

The Property Management Systems we were working with, provided live notification systems. We implemented a feature based on these PMS updates. After subscribing to them, our app received messages about whether the data was up to the minute or it had changed. We saved each message that came to our system and then called Sidekiq workers that consumed that message and updated or created records based on the data from the relevant message.

External API implementation - 3 things to consider

API integrations help drive revenue across many high-performance businesses by keeping data in sync, enhancing productivity, and enabling revenue generation. Based on our experience in this and our other projects, we came up with a list of three important aspects to consider when dealing with an external API implementation:

1. Get familiar with the API documentation and carefully assess its possibilities. Well-written documentation should answer most of your questions and provide you with the information you need to make decisions about whether it’s the right choice for your need.

2. Prepare a data parsing mechanism to make sure that the received data strings get converted into the right type of data.

3. Think which data could be stored in the cache.

Need a hand in an API integration?

At iRonin.IT, we have a number of years under our belt integrating our client’s products with external services via APIs as well as Ruby development services. Contact us to cut down your software development time and budget by integrating with external API systems.

Read Similar Articles