Ruby on Rails
Integrate Repull into a Rails application.
1
Prerequisites
Ruby 3.0+ installed on your machine.
You also need a Repull API key. Get one from your dashboard.
2
Install
gem 'repull', path: 'packages/ruby-sdk'
3
Set up environment variables
Add your credentials to a .env file in your project root:
REPULL_API_KEY=sk_test_YOUR_KEY REPULL_WORKSPACE_ID=YOUR_WORKSPACE_ID
Start with sk_test_ keys for sandbox data. Switch to sk_live_ when you are ready for production.
4
Make your first API call
Configure the client with your API key, then call any endpoint. The example below lists properties and fetches reservations.
# config/initializers/repull.rb
require 'repull'
REPULL = Repull::Client.new(
api_key: ENV['REPULL_API_KEY'],
workspace_id: ENV['REPULL_WORKSPACE_ID']
)
# app/controllers/reservations_controller.rb
class ReservationsController < ApplicationController
# How do I list reservations in Rails?
def index
result = REPULL.reservations.list(
status: params[:status],
source: params[:source]
)
render json: result
end
# How do I get Airbnb reservations in Rails?
def airbnb
result = REPULL.reservations.list(source: "AIRBNB")
render json: result
end
# How do I update availability in Rails?
def update_availability
result = REPULL.availability.update(
propertyId: params[:property_id],
updates: params[:updates]
)
render json: result
end
end
# config/routes.rb
Rails.application.routes.draw do
resources :reservations, only: [:index]
get 'reservations/airbnb', to: 'reservations#airbnb'
put 'properties/:property_id/availability', to: 'reservations#update_availability'
end5
Next steps
You are all set. Explore the rest of the platform:
AI