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(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(organizer_key: nil, url: nil) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 |
# File 'lib/go_to_webinar/client.rb', line 5 def initialize(organizer_key: nil, url: nil) config = GoToWebinar.configuration @url = url || config.url @organizer_key = organizer_key || config.organizer_key @g2w_oauth2_client = GoToWebinar::Auth::Client.new @access_token = @g2w_oauth2_client.access_token&.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
32 33 34 |
# File 'lib/go_to_webinar/client.rb', line 32 def delete attempt { parse(RestClient.delete(make_path(path), data, headers)) } end |
#get(path, data = {}) ⇒ Object
20 21 22 |
# File 'lib/go_to_webinar/client.rb', line 20 def get(path, data = {}) attempt { parse(RestClient.get(make_path(path), data.merge(headers))) } end |
#headers ⇒ Object
13 14 15 16 17 18 |
# File 'lib/go_to_webinar/client.rb', line 13 def headers { 'Accept' => 'application/json', 'Authorization' => "OAuth oauth_token=#{access_token}" } end |
#make_path(path) ⇒ Object
36 37 38 39 |
# File 'lib/go_to_webinar/client.rb', line 36 def make_path(path) path.gsub!(':organizer_key:', organizer_key) "#{url}#{path}" end |
#post(path, data) ⇒ Object
24 25 26 |
# File 'lib/go_to_webinar/client.rb', line 24 def post(path, data) attempt { parse(RestClient.post(make_path(path), data, headers)) } end |
#put(path, data) ⇒ Object
28 29 30 |
# File 'lib/go_to_webinar/client.rb', line 28 def put(path, data) attempt { parse(RestClient.put(make_path(path), data, headers)) } end |