Class: Joinme2::Client
- Inherits:
-
Object
- Object
- Joinme2::Client
- Includes:
- HTTParty
- Defined in:
- lib/joinme2/client.rb
Instance Attribute Summary collapse
-
#auth_uri ⇒ Object
Returns the value of attribute auth_uri.
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#default_scopes ⇒ Object
Returns the value of attribute default_scopes.
-
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/joinme2/client.rb', line 16 def initialize( = {}) oauth_token = [:oauth_token] = Joinme2..merge() [:base_uri, :default_scopes, :redirect_uri, :client_id, :auth_uri].each do |accessor| send("#{accessor}=", [accessor]) end self.class.base_uri base_uri = { headers: { "Authorization" => "Bearer #{oauth_token}", "Content-Type" => "application/json", "User-Agent" => 'X-JOINME-CLIENT' } } end |
Instance Attribute Details
#auth_uri ⇒ Object
Returns the value of attribute auth_uri.
6 7 8 |
# File 'lib/joinme2/client.rb', line 6 def auth_uri @auth_uri end |
#base_uri ⇒ Object
Returns the value of attribute base_uri.
6 7 8 |
# File 'lib/joinme2/client.rb', line 6 def base_uri @base_uri end |
#client_id ⇒ Object
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/joinme2/client.rb', line 6 def client_id @client_id end |
#default_scopes ⇒ Object
Returns the value of attribute default_scopes.
6 7 8 |
# File 'lib/joinme2/client.rb', line 6 def default_scopes @default_scopes end |
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
6 7 8 |
# File 'lib/joinme2/client.rb', line 6 def redirect_uri @redirect_uri 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.
47 48 49 50 51 52 53 54 55 |
# File 'lib/joinme2/client.rb', line 47 def ( = {}) params = {} params[:scope] = [:scope] || default_scopes params[:redirect_uri] = [:redirect_uri] || redirect_uri params[:client_id] = [:client_id] || client_id URI.parse(auth_uri).tap do |uri| uri.query = URI.encode_www_form params end.to_s end |
#delete_meeting(id) ⇒ Object
103 104 105 |
# File 'lib/joinme2/client.rb', line 103 def delete_meeting(id) self.class.delete("/meetings/#{id}", ) end |
#get_scheduled_meeting(id) ⇒ Object
70 71 72 |
# File 'lib/joinme2/client.rb', line 70 def get_scheduled_meeting(id) self.class.get("/meetings/#{id}", ) end |
#get_scheduled_meetings(end_date = nil) ⇒ Object
74 75 76 77 78 |
# File 'lib/joinme2/client.rb', line 74 def get_scheduled_meetings(end_date = nil) payload = .dup payload[:headers][:endDate] = end_date if end_date self.class.get('/meetings', ) end |
#get_user ⇒ Object
107 108 109 |
# File 'lib/joinme2/client.rb', line 107 def get_user self.class.get('/user', ) end |
#schedule_new_meeting(name, participants = [], start_date, end_date) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/joinme2/client.rb', line 80 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 = .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.
60 61 62 63 64 |
# File 'lib/joinme2/client.rb', line 60 def start_new_meeting(body = { "startWithPersonalUrl": false }) payload = .dup payload[:body] = body.to_json self.class.post('/meetings/start', payload) end |
#start_sheduled_meeting(id) ⇒ Object
66 67 68 |
# File 'lib/joinme2/client.rb', line 66 def start_sheduled_meeting(id) self.class.post("/meetings/#{id}/start", ) end |
#update_meeting(id, name = nil, participant = nil, start_date = nil, end_date = nil) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/joinme2/client.rb', line 92 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 = .dup payload[:body] = body.to_json self.class.patch("/meetings/#{id}", payload) end |