Sha256: 85deb03be763c53a260a9249b6b08ed1b6c2f7cb691675edbb089abc90eba511
Contents?: true
Size: 793 Bytes
Versions: 14
Compression:
Stored size: 793 Bytes
Contents
require 'http' module Airbnb # Service for all Airbnb API calls class AirbnbApi #Setting the URL and parameters Airbnb_URL = 'https://api.airbnb.com/' API_VER = 'v2' Airbnb_API_URL = URI.join(Airbnb_URL, "#{API_VER}/") Search_URL = URI.join(Airbnb_API_URL, "search_results") def self.config=(credentials) @config ? @config.update(credentials) : @config = credentials end def self.config return @config if @config @config = { airbnb_id: ENV['AIRBNB_API'] } end def self.rooms_info(location) rooms_response = HTTP.get(Search_URL, params: { client_id: config[:airbnb_id], location: location }) roomsinfo = JSON.load(rooms_response.to_s)['search_results'] end end end
Version data entries
14 entries across 14 versions & 2 rubygems