Class: Joinme2::Client
- Inherits:
-
Object
- Object
- Joinme2::Client
- Includes:
- HTTParty
- Defined in:
- lib/joinme2/client.rb
Instance Method Summary collapse
-
#authorize_url(options = {}) ⇒ Object
Public: Generates Joinme authorization url based on client_id, auth_uri redirect_uri and scopes.
- #delete_meeting(id) ⇒ Object
- #get_scheduled_meeting(id) ⇒ Object
- #get_scheduled_meetings(end_date = nil) ⇒ Object
- #get_user ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #schedule_new_meeting(name, participants = [], start_date, end_date) ⇒ Object
-
#start_new_meeting(body = { "startWithPersonalUrl": false }) ⇒ Object
Public: Connects to Joinme API and starts new meeting.
- #start_sheduled_meeting(id) ⇒ Object
- #update_meeting(id, name = nil, participant = nil, start_date = nil, end_date = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/joinme2/client.rb', line 12 def initialize( = {}) oauth_token = [:oauth_token] = Joinme2..merge() Configuration::VALID_ACCESSORS.each do |accessor| send("#{accessor}=", [accessor]) end self.class.base_uri base_uri @options = { headers: { "Authorization" => "Bearer #{oauth_token}", "Content-Type" => "application/json", "User-Agent" => 'X-JOINME-CLIENT' } } end |
Instance Method Details
#authorize_url(options = {}) ⇒ Object
Public: Generates Joinme authorization url based on client_id, auth_uri redirect_uri and scopes. Redirect URI has to match configured Joinme Application callback URL.
Examples:
(redirect_uri: 'http://example.com/',
scope: "user_info scheduler start_meeting",
client_id: "XXXXX")
# =>
"https://secure.join.me/api/public/v1/auth/oauth2..."
Returns authorization url as a string.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/joinme2/client.rb', line 43 def ( = {}) params = {} params[:scope] = [:scope] || default_scopes params[:redirect_uri] = [:redirect_uri] || redirect_uri params[:client_id] = [:client_id] || client_id params[:response_type] = [:response_type] || response_type URI.parse(auth_uri).tap do |uri| uri.query = URI.encode_www_form params end.to_s end |
#delete_meeting(id) ⇒ Object
100 101 102 |
# File 'lib/joinme2/client.rb', line 100 def delete_meeting(id) self.class.delete("/meetings/#{id}", @options) end |
#get_scheduled_meeting(id) ⇒ Object
67 68 69 |
# File 'lib/joinme2/client.rb', line 67 def get_scheduled_meeting(id) self.class.get("/meetings/#{id}", @options) end |
#get_scheduled_meetings(end_date = nil) ⇒ Object
71 72 73 74 75 |
# File 'lib/joinme2/client.rb', line 71 def get_scheduled_meetings(end_date = nil) payload = @options.dup payload[:headers][:endDate] = end_date if end_date self.class.get('/meetings', @options) end |
#get_user ⇒ Object
104 105 106 |
# File 'lib/joinme2/client.rb', line 104 def get_user self.class.get('/user', @options) end |
#schedule_new_meeting(name, participants = [], start_date, end_date) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/joinme2/client.rb', line 77 def schedule_new_meeting(name, participants = [], start_date, end_date) body = {} body[:startWithPersonalUrl] = false body[:meetingStart] = iso_date!(start_date) body[:meetingEnd] = iso_date!(end_date) body[:meetingName] = name body[:participants] = participants payload = @options.dup payload[:body] = body.to_json self.class.post('/meetings', payload) end |
#start_new_meeting(body = { "startWithPersonalUrl": false }) ⇒ Object
Public: Connects to Joinme API and starts new meeting.
Returns Hashie::Mash representation of API response.
57 58 59 60 61 |
# File 'lib/joinme2/client.rb', line 57 def start_new_meeting(body = { "startWithPersonalUrl": false }) payload = @options.dup payload[:body] = body.to_json self.class.post('/meetings/start', payload) end |
#start_sheduled_meeting(id) ⇒ Object
63 64 65 |
# File 'lib/joinme2/client.rb', line 63 def start_sheduled_meeting(id) self.class.post("/meetings/#{id}/start", @options) end |
#update_meeting(id, name = nil, participant = nil, start_date = nil, end_date = nil) ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/joinme2/client.rb', line 89 def update_meeting(id, name = nil, participant = nil, start_date = nil, end_date = nil) body = {} body[:meetingStart] = iso_date(start_date) body[:meetingEnd] = iso_date(end_datee) body[:meetingName] = name body[:participants] = participants payload = @options.dup payload[:body] = body.to_json self.class.patch("/meetings/#{id}", payload) end |