Class: GoToWebinar::Client
- Inherits:
-
Object
- Object
- GoToWebinar::Client
- Defined in:
- lib/go_to_webinar/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#organizer_key ⇒ Object
Returns the value of attribute organizer_key.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #delete ⇒ Object
- #get(path, data = {}) ⇒ Object
- #headers ⇒ Object
-
#initialize(access_token: nil, organizer_key: nil, url: nil) ⇒ Client
constructor
A new instance of Client.
- #make_path(path) ⇒ Object
- #post(path, data) ⇒ Object
- #put(path, data) ⇒ Object
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_token ⇒ Object
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_key ⇒ Object
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 |
#url ⇒ Object
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
#delete ⇒ Object
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 |
#headers ⇒ Object
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 |