Module: SleepRoom::Record::API

Defined in:
lib/sleeproom/record/api/api.rb,
lib/sleeproom/record/api/room.rb,
lib/sleeproom/record/api/room_api.rb,
lib/sleeproom/record/api/streaming_api.rb

Defined Under Namespace

Classes: Error, NotFoundError, Room, RoomAPI, StreamingAPI

Constant Summary collapse

ROOM_URL =
"https://www.showroom-live.com"
ROOM_API =
"https://www.showroom-live.com/api/room/status"
STREAMING_API =
"https://www.showroom-live.com/api/live/streaming_url"
USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"

Class Method Summary collapse

Class Method Details

.get(url) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sleeproom/record/api/api.rb', line 20

def self.get(url)
  Async do
    http = Faraday.get(url, nil, {"User-Agent": USER_AGENT})
    if http.status == 200
      @json = JSON.parse(http.body)
    elsif http.status == 404
      raise NotFoundError
    else
      raise Error, "HTTP Error: #{http.status}"
    end
  end
end