Class: Airbnb::AirbnbApi

Inherits:
Object
  • Object
show all
Defined in:
lib/movlog/airbnb_api.rb

Overview

Service for all Airbnb API calls

Constant Summary collapse

AIRBNB_URL =
'https://api.airbnb.com/v2/search_results'

Class Method Summary collapse

Class Method Details

.configObject



14
15
16
17
18
19
# File 'lib/movlog/airbnb_api.rb', line 14

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

.config=(credentials) ⇒ Object



9
10
11
12
# File 'lib/movlog/airbnb_api.rb', line 9

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

.rooms_result(location) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/movlog/airbnb_api.rb', line 21

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