Module: Eyeson

Defined in:
lib/eyeson.rb,
lib/eyeson/room.rb,
lib/eyeson/layer.rb,
lib/eyeson/config.rb,
lib/eyeson/account.rb,
lib/eyeson/message.rb,
lib/eyeson/version.rb,
lib/eyeson/webhook.rb,
lib/eyeson/requests.rb,
lib/eyeson/snapshot.rb,
lib/eyeson/broadcast.rb,
lib/eyeson/recording.rb,
lib/eyeson/file_upload.rb

Overview

Provides REST methods

Defined Under Namespace

Classes: Account, Broadcast, Configuration, FileUpload, Layer, Message, Recording, Room, Snapshot, Webhook

Constant Summary collapse

VERSION =
'2.6.4'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



9
10
11
# File 'lib/eyeson.rb', line 9

def self.configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



13
14
15
# File 'lib/eyeson.rb', line 13

def self.configure
  yield(configuration)
end

.delete(path, params = {}) ⇒ Object



15
16
17
# File 'lib/eyeson/requests.rb', line 15

def delete(path, params = {})
  request(:delete, path, params)
end

.get(path, params = {}) ⇒ Object



5
6
7
# File 'lib/eyeson/requests.rb', line 5

def get(path, params = {})
  request(:get, path, params)
end

.post(path, params = {}) ⇒ Object



10
11
12
# File 'lib/eyeson/requests.rb', line 10

def post(path, params = {})
  request(:post, path, params)
end

.request(method, path, params) ⇒ Object



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

def request(method, path, params)
  response_for RestClient::Request.new(
    method: method,
    url: configuration.api_endpoint + path,
    payload: params.compact,
    headers: {
      authorization: configuration.api_key,
      accept: 'application/json',
      user_agent: 'eyeson-ruby'
    }
  )
end

.response_for(req) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/eyeson/requests.rb', line 34

def response_for(req)
  res = begin
    req.execute
  rescue RestClient::ExceptionWithResponse => e
    e.response
  end
  return {} if !res.body || res.body.empty?
  JSON.parse(res.body)
end