lita-glip 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/lita-glip.rb +1 -0
- data/lib/lita/adapters/glip.rb +10 -2
- data/lib/lita/adapters/glip/connector.rb +2 -1
- data/lib/lita/handlers/glip.rb +73 -0
- data/lita-glip.gemspec +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02752fa1df2388a296305359d53f33afa01466b2
|
4
|
+
data.tar.gz: 03ce09fd316e9821a4ef27446541419013e1d64a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dffee319f3e8be376de12252c6ec16a2ee413b06fe5ed88d7ed832f341116615add6cfa46ccae64ea1333cf26bfeb55f60e6945b04e0be957c51a21d9d3bde9b
|
7
|
+
data.tar.gz: b6d672da3b75cb586caacf9f5de05f7077f5a259e63b5506a321762ad0e8461c5a49c951b0154038491c1cc2f78f9f3917db7478bbd80f37e7175e5e113bee6f
|
data/README.md
CHANGED
@@ -12,6 +12,9 @@ Lita Glip Adapter
|
|
12
12
|
[![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
|
13
13
|
[![License][license-svg]][license-link]
|
14
14
|
|
15
|
+
[![Stack Overflow][stackoverflow-svg]][stackoverflow-url]
|
16
|
+
[![Chat][chat-svg]][chat-url]
|
17
|
+
|
15
18
|
`lita-glip` is an adapter for [Lita](https://www.lita.io/) that allows you to use the robot with [Glip](https://glip.com/).
|
16
19
|
|
17
20
|
## Installation
|
@@ -121,3 +124,7 @@ Lita Glip Adapter © 2016-2017 by John Wang
|
|
121
124
|
[docs-rubydoc-link]: http://www.rubydoc.info/gems/lita-glip/
|
122
125
|
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
|
123
126
|
[license-link]: https://github.com/ringcentral-ruby/lita-glip/blob/master/LICENSE.md
|
127
|
+
[chat-svg]: https://img.shields.io/badge/chat-on%20glip-orange.svg
|
128
|
+
[chat-url]: https://glipped.herokuapp.com/
|
129
|
+
[stackoverflow-svg]: https://img.shields.io/badge/Stack%20Overflow-glip-orange.svg
|
130
|
+
[stackoverflow-url]: https://stackoverflow.com/questions/tagged/glip
|
data/lib/lita-glip.rb
CHANGED
data/lib/lita/adapters/glip.rb
CHANGED
@@ -14,11 +14,19 @@ module Lita
|
|
14
14
|
config :app_secret, type: String, required: true
|
15
15
|
config :server_url, type: String, default: 'platform.devtest.ringcentral.com'
|
16
16
|
|
17
|
-
config :username, type: String
|
17
|
+
config :username, type: String
|
18
18
|
config :extension, type: String
|
19
|
-
config :password, type: String
|
19
|
+
config :password, type: String
|
20
20
|
config :token, type: String
|
21
21
|
|
22
|
+
def initialize(robot)
|
23
|
+
@robot = robot
|
24
|
+
end
|
25
|
+
|
26
|
+
def log
|
27
|
+
Lita.logger
|
28
|
+
end
|
29
|
+
|
22
30
|
def initialize(robot)
|
23
31
|
super
|
24
32
|
@connector = Connector.new(
|
@@ -39,7 +39,8 @@ module Lita
|
|
39
39
|
token = MultiJson.encode @rc_sdk.token.to_hash
|
40
40
|
Lita.logger.debug("#{@logger_prefix}Authorized with token: #{token}.")
|
41
41
|
else
|
42
|
-
@
|
42
|
+
Lita.logger.debug("#{@logger_prefix}Loading token: #{@token}.")
|
43
|
+
@rc_sdk.set_token MultiJson.decode @token
|
43
44
|
end
|
44
45
|
|
45
46
|
@glip_sdk = GlipSdk::REST::Client.new @rc_sdk
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'multi_json'
|
3
|
+
require 'ringcentral_sdk'
|
4
|
+
|
5
|
+
module Lita
|
6
|
+
module Handlers
|
7
|
+
class Glip < Handler
|
8
|
+
attr_reader :client
|
9
|
+
attr_reader :robot
|
10
|
+
|
11
|
+
config :app_key, type: String, required: true
|
12
|
+
config :app_secret, type: String, required: true
|
13
|
+
config :server_url, type: String, default: 'platform.devtest.ringcentral.com'
|
14
|
+
|
15
|
+
http.post '/glip/oauth2callback', :callback_oauth
|
16
|
+
http.post '/glip/webhook', :callback_webhook
|
17
|
+
http.get '/glip/webhook', :callback_webhook
|
18
|
+
|
19
|
+
def initialize(robot)
|
20
|
+
@robot = robot
|
21
|
+
end
|
22
|
+
|
23
|
+
def log
|
24
|
+
Lita.logger
|
25
|
+
end
|
26
|
+
|
27
|
+
def callback_oauth(request, response)
|
28
|
+
pp request
|
29
|
+
|
30
|
+
response.finish
|
31
|
+
end
|
32
|
+
|
33
|
+
def callback_webhook(request, response)
|
34
|
+
Lita.logger.info 'Lita Glip Webhook called'
|
35
|
+
Lita.logger.info "Request Class #{request.class.name}"
|
36
|
+
Lita.logger.info "QSR #{request.query_string}"
|
37
|
+
params = CGI::parse(request.query_string)
|
38
|
+
message = {'type' => 'rc-oauth2', 'body' => params }
|
39
|
+
message = MultiJson.encode message
|
40
|
+
Lita.logger.info "QSJ #{MultiJson.encode(params)}"
|
41
|
+
code = params['code'][0]||''
|
42
|
+
#Lita.logger.info "QS #{params['code'][0]} #{params['code'][0].length}"
|
43
|
+
Lita.logger.info "QSF #{code} #{code.length}"
|
44
|
+
|
45
|
+
#source = Lita::Source.new(user: 'rc-oauth2')
|
46
|
+
|
47
|
+
user = Lita::User.create(
|
48
|
+
'glip-oauth',
|
49
|
+
name: 'glip-oauth'
|
50
|
+
)
|
51
|
+
|
52
|
+
source = Lita::Source.new user: user #user#, room: room
|
53
|
+
message = Lita::Message.new(robot, message, source)
|
54
|
+
robot.receive(message)
|
55
|
+
=begin
|
56
|
+
client = RingCentralSdk::REST::Client.new do |config|
|
57
|
+
config.load_env = false
|
58
|
+
config.client_id = ENV['RC_CLIENT_ID']
|
59
|
+
config.client_secret = ENV['RC_CLIENT_SECRET']
|
60
|
+
config.server_url = RingCentralSdk::RC_SERVER_PRODUCTION
|
61
|
+
config.username = ENV['RC_USER_USERNAME']
|
62
|
+
config.extension = ENV['RC_USER_EXTENSION']
|
63
|
+
config.password = ENV['RC_USER_PASSWORD']
|
64
|
+
config.logger = log
|
65
|
+
end
|
66
|
+
=end
|
67
|
+
response.finish
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Lita.register_handler(Glip)
|
72
|
+
end
|
73
|
+
end
|
data/lita-glip.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-glip'
|
3
|
-
spec.date = '2017-
|
4
|
-
spec.version = '0.
|
3
|
+
spec.date = '2017-10-15'
|
4
|
+
spec.version = '0.2.0'
|
5
5
|
spec.authors = ['John Wang']
|
6
6
|
spec.email = ["johncwang@gmail.com"]
|
7
7
|
spec.description = %q{A Glip adapter for Lita.}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-glip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/lita/adapters/glip/message_handler.rb
|
215
215
|
- lib/lita/adapters/glip/room_creator.rb
|
216
216
|
- lib/lita/adapters/glip/user_creator.rb
|
217
|
+
- lib/lita/handlers/glip.rb
|
217
218
|
- lita-glip.gemspec
|
218
219
|
- locales/en.yml
|
219
220
|
homepage: https://github.com/ringcentral-ruby/lita-glip
|
@@ -237,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
238
|
version: '0'
|
238
239
|
requirements: []
|
239
240
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.6.
|
241
|
+
rubygems_version: 2.6.13
|
241
242
|
signing_key:
|
242
243
|
specification_version: 4
|
243
244
|
summary: A Glip adapter for the Lita chat robot.
|