Class: Lita::Handlers::Glip
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Glip
- Defined in:
- lib/lita/handlers/glip.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
Instance Method Summary collapse
- #callback_oauth(request, response) ⇒ Object
- #callback_webhook(request, response) ⇒ Object
-
#initialize(robot) ⇒ Glip
constructor
A new instance of Glip.
- #log ⇒ Object
Constructor Details
#initialize(robot) ⇒ Glip
Returns a new instance of Glip.
19 20 21 |
# File 'lib/lita/handlers/glip.rb', line 19 def initialize(robot) @robot = robot end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/lita/handlers/glip.rb', line 8 def client @client end |
#robot ⇒ Object (readonly)
Returns the value of attribute robot.
9 10 11 |
# File 'lib/lita/handlers/glip.rb', line 9 def robot @robot end |
Instance Method Details
#callback_oauth(request, response) ⇒ Object
27 28 29 30 31 |
# File 'lib/lita/handlers/glip.rb', line 27 def callback_oauth(request, response) pp request response.finish end |
#callback_webhook(request, response) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/lita/handlers/glip.rb', line 33 def callback_webhook(request, response) Lita.logger.info 'Lita Glip Webhook called' Lita.logger.info "Request Class #{request.class.name}" Lita.logger.info "QSR #{request.query_string}" params = CGI::parse(request.query_string) = {'type' => 'rc-oauth2', 'body' => params } = MultiJson.encode Lita.logger.info "QSJ #{MultiJson.encode(params)}" code = params['code'][0]||'' #Lita.logger.info "QS #{params['code'][0]} #{params['code'][0].length}" Lita.logger.info "QSF #{code} #{code.length}" #source = Lita::Source.new(user: 'rc-oauth2') user = Lita::User.create( 'glip-oauth', name: 'glip-oauth' ) source = Lita::Source.new user: user #user#, room: room = Lita::Message.new(robot, , source) robot.receive() =begin client = RingCentralSdk::REST::Client.new do |config| config.load_env = false config.client_id = ENV['RC_CLIENT_ID'] config.client_secret = ENV['RC_CLIENT_SECRET'] config.server_url = RingCentralSdk::RC_SERVER_PRODUCTION config.username = ENV['RC_USER_USERNAME'] config.extension = ENV['RC_USER_EXTENSION'] config.password = ENV['RC_USER_PASSWORD'] config.logger = log end =end response.finish end |
#log ⇒ Object
23 24 25 |
# File 'lib/lita/handlers/glip.rb', line 23 def log Lita.logger end |