Sha256: f91973f25a1ab80ccfbdab7b3c03e93c290e32b3bcccd0e7923cfa09304495cd

Contents?: true

Size: 699 Bytes

Versions: 33

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true
require 'http'

module Airbnb
  # Service for all Airbnb API calls
  class AirbnbApi
    AIRBNB_URL = 'https://api.airbnb.com/v2/search_results'

    def self.config=(credentials)
      @config = {} unless @config
      @config.update(credentials)
    end

    def self.config
      return @config if @config
      @config = {
        client_id: ENV['AIRBNB_CLIENT_ID']
      }
    end

    def self.rooms_result(location)
      airbnb_rooms_response = HTTP.get(
        AIRBNB_URL,
        params: {
          client_id: config[:client_id],
          location: location
        }
      )
      JSON.load(airbnb_rooms_response.to_s)['search_results']
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
movlog-0.2.11 lib/movlog/airbnb_api.rb
movlog-0.2.10 lib/movlog/airbnb_api.rb
movlog-0.2.9 lib/movlog/airbnb_api.rb
movlog-0.2.8 lib/movlog/airbnb_api.rb
movlog-0.2.7 lib/movlog/airbnb_api.rb
movlog-0.2.6 lib/movlog/airbnb_api.rb
movlog-0.2.5 lib/movlog/airbnb_api.rb
movlog-0.2.4 lib/movlog/airbnb_api.rb
movlog-0.2.3 lib/movlog/airbnb_api.rb
movlog-0.2.2 lib/movlog/airbnb_api.rb
movlog-0.2.1 lib/movlog/airbnb_api.rb
movlog-0.2.0 lib/movlog/airbnb_api.rb
movlog-0.1.0 lib/movlog/airbnb_api.rb