Class: GoToWebinar::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/go_to_webinar/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token: nil, organizer_key: nil, url: nil) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
10
# File 'lib/go_to_webinar/client.rb', line 5

def initialize(access_token: nil, organizer_key: nil, url: nil)
  config = GoToWebinar.configuration
  @url = url || config.url
  @organizer_key = organizer_key || config.organizer_key
  @access_token = access_token || config.access_token
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



3
4
5
# File 'lib/go_to_webinar/client.rb', line 3

def access_token
  @access_token
end

#organizer_keyObject

Returns the value of attribute organizer_key.



3
4
5
# File 'lib/go_to_webinar/client.rb', line 3

def organizer_key
  @organizer_key
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/go_to_webinar/client.rb', line 3

def url
  @url
end

Instance Method Details

#deleteObject



34
35
36
37
# File 'lib/go_to_webinar/client.rb', line 34

def delete
  response = RestClient.delete(make_path(path), data, headers)
  JSON.parse(response.body)
end

#get(path, data = {}) ⇒ Object



19
20
21
22
# File 'lib/go_to_webinar/client.rb', line 19

def get(path, data = {})
  response = RestClient.get(make_path(path), data.merge(headers))
  JSON.parse(response.body)
end

#headersObject



12
13
14
15
16
17
# File 'lib/go_to_webinar/client.rb', line 12

def headers
  {
    'Accept' => 'application/json',
    'Authorization' => "OAuth oauth_token=#{access_token}"
  }
end

#make_path(path) ⇒ Object



39
40
41
42
# File 'lib/go_to_webinar/client.rb', line 39

def make_path(path)
  path.gsub!(':organizer_key:', organizer_key)
  "#{url}#{path}"
end

#post(path, data) ⇒ Object



24
25
26
27
# File 'lib/go_to_webinar/client.rb', line 24

def post(path, data)
  response = RestClient.post(make_path(path), data, headers)
  JSON.parse(response.body)
end

#put(path, data) ⇒ Object



29
30
31
32
# File 'lib/go_to_webinar/client.rb', line 29

def put(path, data)
  response = RestClient.put(make_path(path), data, headers)
  JSON.parse(response.body)
end