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

Version Path
VIAJERO-0.1.74 lib/VIAJERO/airbnb_api.rb
VIAJERO-0.1.73 lib/VIAJERO/airbnb_api.rb
Time_Traveler-0.1.70 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.60 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.50 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.48 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.47 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.46 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.45 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.4 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.3 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.2 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.1 lib/Time_Traveler/airbnb_api.rb
Time_Traveler-0.1.0 lib/Time_Traveler/airbnb_api.rb