rails-ding 1.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +39 -0
- data/Rakefile +40 -0
- data/app/assets/config/rails_ding_manifest.js +2 -0
- data/app/assets/javascripts/rails/ding/application.js +13 -0
- data/app/assets/stylesheets/rails/ding/application.css +15 -0
- data/app/controllers/rails/ding/application_controller.rb +7 -0
- data/app/helpers/rails/ding/application_helper.rb +6 -0
- data/app/jobs/rails/ding/application_job.rb +6 -0
- data/app/mailers/rails/ding/application_mailer.rb +8 -0
- data/app/models/rails/ding/application_record.rb +7 -0
- data/app/views/layouts/rails/ding/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/lib/rails/ding.rb +43 -0
- data/lib/rails/ding/auth_service.rb +63 -0
- data/lib/rails/ding/cache_service.rb +77 -0
- data/lib/rails/ding/chat_service.rb +22 -0
- data/lib/rails/ding/configuration.rb +17 -0
- data/lib/rails/ding/department_service.rb +32 -0
- data/lib/rails/ding/engine.rb +7 -0
- data/lib/rails/ding/http_service.rb +38 -0
- data/lib/rails/ding/log_service.rb +23 -0
- data/lib/rails/ding/message_service.rb +22 -0
- data/lib/rails/ding/user_service.rb +27 -0
- data/lib/rails/ding/version.rb +5 -0
- data/lib/tasks/rails/ding_tasks.rake +4 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d85a0cb2962fa88265088b4a851f3450cd299670640c036ba0911692e2442847
|
4
|
+
data.tar.gz: 53b720fa23471ab3553ef2bd63dff6ff5059b8a03f3f7d863a1b217ed5921e45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e326e241736898447a833481776cedfc06561aca47e65ea0caf20aa894dff4081a7ab3dc711dd7a3e449e2ee8639ffdcae8ec055c5e344a88d92b1823760367a
|
7
|
+
data.tar.gz: 46c6b5d4eef3fb7f4614b54288f4bfe2cf7bac1817b2f97b0a6245730dad736e9761d6225ddb4f8720b9815f122894e5c8ef9095d1ac8136c737901d33def48e
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Rails::Ding
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'rails-ding'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install rails-ding
|
22
|
+
```
|
23
|
+
## 工作记录
|
24
|
+
2019-09-25
|
25
|
+
* 创建项目
|
26
|
+
2019-09-26
|
27
|
+
* 转移auth, cache, http, log等功能块,并做适配gem的修改,其中auth并没有完成
|
28
|
+
2019-09-27
|
29
|
+
* 转移chat, department, message, user; 添加配置
|
30
|
+
## 提醒
|
31
|
+
之前是依赖于5.1.6,现在改成依赖5.1.0
|
32
|
+
## todolist
|
33
|
+
关于文件缓存及日志,要考虑正式使用时保存位置
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
Contribution directions go here.
|
37
|
+
|
38
|
+
## License
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Rails::Ding'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
37
|
+
|
38
|
+
task :console do
|
39
|
+
exec "irb -I ./lib"
|
40
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Rails ding</title>
|
5
|
+
<%= stylesheet_link_tag "rails/ding/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "rails/ding/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/lib/rails/ding.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require "rails/ding/engine"
|
2
|
+
require "rails/ding/configuration"
|
3
|
+
require "rails/ding/http_service"
|
4
|
+
require "rails/ding/log_service"
|
5
|
+
require "rails/ding/cache_service"
|
6
|
+
require "rails/ding/auth_service"
|
7
|
+
require "rails/ding/chat_service"
|
8
|
+
require "rails/ding/department_service"
|
9
|
+
require "rails/ding/message_service"
|
10
|
+
require "rails/ding/user_service"
|
11
|
+
|
12
|
+
begin
|
13
|
+
require "pry"
|
14
|
+
rescue LoadError
|
15
|
+
end
|
16
|
+
|
17
|
+
module Rails
|
18
|
+
module Ding
|
19
|
+
# puts "test"
|
20
|
+
# Rails::Ding::LogService.e("[getConfig] ERR: no corp access token");
|
21
|
+
# Rails::Ding::CacheService::setCorpAccessToken('2222')
|
22
|
+
# puts Rails::Ding::HttpService::get('/gettoken?', {corpid: 'ding4e97ac09cf15a1d2', corpsecret: 'jQOqko0rIUGRSBV4APykM9horY317-7TTtPdmKeyhIjnDPYxkfMMAJnwixllLCBx'})
|
23
|
+
class << self
|
24
|
+
attr_writer :configuration
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.configuration
|
28
|
+
@configuration ||= Rails::Ding::Configuration.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.reset
|
32
|
+
@configuration = Rails::Ding::Configuration.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.configure
|
36
|
+
yield(configuration)
|
37
|
+
end
|
38
|
+
|
39
|
+
# accessToken = AuthService.getAccessToken
|
40
|
+
# l = DepartmentService.listDept(accessToken)
|
41
|
+
# binding.pry
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
class AuthService
|
4
|
+
|
5
|
+
def self.configuration
|
6
|
+
Ding::configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.getAccessToken
|
10
|
+
# 缓存accessToken。accessToken有效期为两小时,需要在失效前请求新的accessToken(注意:以下代码没有在失效前刷新缓存的accessToken)。
|
11
|
+
accessToken = CacheService::getCorpAccessToken()
|
12
|
+
if accessToken.blank?
|
13
|
+
response = HttpService.get('/gettoken?', {corpid: configuration.corpid, corpsecret: configuration.secret})
|
14
|
+
check(response)
|
15
|
+
accessToken = response['access_token']
|
16
|
+
CacheService::setCorpAccessToken(accessToken)
|
17
|
+
end
|
18
|
+
return accessToken
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def self.getTicket(accessToken)
|
23
|
+
jsticket = CacheService::getJsTicket()
|
24
|
+
if jsticket.blank?
|
25
|
+
response = HttpService.get('/get_jsapi_ticket?', {type: 'jsapi', access_token: accessToken})
|
26
|
+
check(response)
|
27
|
+
jsticket = response['ticket']
|
28
|
+
CacheService::setJsTicket(jsticket)
|
29
|
+
end
|
30
|
+
return jsticket
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.getConfig(href)
|
34
|
+
corpId = configuration.corpid
|
35
|
+
agentId = configuration.agentid
|
36
|
+
nonceStr = 'abcdefg'
|
37
|
+
timeStamp = Time.now.to_i
|
38
|
+
url = href
|
39
|
+
corpAccessToken = getAccessToken()
|
40
|
+
if corpAccessToken.blank?
|
41
|
+
LogService.e("[getConfig] ERR: no corp access token")
|
42
|
+
end
|
43
|
+
ticket = getTicket(corpAccessToken)
|
44
|
+
signature = sign(ticket, nonceStr, timeStamp, url)
|
45
|
+
|
46
|
+
config = {'url' => url,'nonceStr' => nonceStr,'agentId' => agentId, 'timeStamp' => timeStamp, 'corpId' => corpId, 'signature' => signature}
|
47
|
+
return config
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.sign(ticket, nonceStr, timeStamp, url)
|
51
|
+
plain = "jsapi_ticket=#{ticket}&noncestr=#{nonceStr}×tamp=#{timeStamp}&url=#{url}"
|
52
|
+
return Digest::SHA1.hexdigest(plain);
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.check(res)
|
56
|
+
if res["errcode"] != 0
|
57
|
+
LogService.e("FAIL: #{res.to_json}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
class CacheService
|
4
|
+
|
5
|
+
def self.setJsTicket(ticket)
|
6
|
+
set("js_ticket", ticket, ex: 7000); # js ticket有效期为7200秒,这里设置为7000秒
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.getJsTicket()
|
10
|
+
return get("js_ticket")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.setCorpAccessToken(accessToken)
|
14
|
+
set("corp_access_token", accessToken, ex: 7000) # corp access token有效期为7200秒,这里设置为7000秒
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.getCorpAccessToken
|
18
|
+
return get("corp_access_token")
|
19
|
+
end
|
20
|
+
|
21
|
+
# 保存变量
|
22
|
+
def self.set_value(name,value)
|
23
|
+
set(name, value)
|
24
|
+
end
|
25
|
+
# 使用变量
|
26
|
+
def self.get_value(name)
|
27
|
+
get(name)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.set(key,value,options = {})
|
31
|
+
ex = options[:ex] ? Time.now.to_i + options[:ex] : 0
|
32
|
+
if key && value
|
33
|
+
data = get_file(Rails.root.to_s + "config/filecache.yml")
|
34
|
+
|
35
|
+
item = {}
|
36
|
+
item["#{key}"] = value
|
37
|
+
item['expire_time'] = ex
|
38
|
+
item['create_time'] = Time.now.to_i
|
39
|
+
data["#{key}"] = item
|
40
|
+
set_file(Rails.root.to_s + "config/filecache.yml",data.to_json)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.get(key)
|
45
|
+
if key.present?
|
46
|
+
data = get_file(Rails.root.to_s + "config/filecache.yml")
|
47
|
+
if data.present? && data.has_key?(key)
|
48
|
+
item = data["#{key}"]
|
49
|
+
return false if !item
|
50
|
+
if item['expire_time']>0 && item['expire_time'] < Time.now.to_i
|
51
|
+
return false;
|
52
|
+
end
|
53
|
+
return item["#{key}"]
|
54
|
+
else
|
55
|
+
return false;
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.get_file(filename)
|
61
|
+
if !File.exist?(filename)
|
62
|
+
file = File.open(filename, "w")
|
63
|
+
file.write("{}")
|
64
|
+
file.close
|
65
|
+
end
|
66
|
+
return YAML.load(File.read(filename))
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.set_file(filename, content)
|
70
|
+
file = File.open(filename, "w")
|
71
|
+
file.write(content)
|
72
|
+
file.close unless file.nil?
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
class ChatService
|
4
|
+
|
5
|
+
def self.createChat(accessToken, chatOpt)
|
6
|
+
response = HttpService.post("/chat/create?", {access_token: accessToken}, chatOpt.to_json)
|
7
|
+
return response
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.bindChat(accessToken, chatid,agentid)
|
11
|
+
response = HttpService.get("/chat/bind?",{access_token: accessToken,chatid: chatid,agentid: agentid})
|
12
|
+
return response
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.sendmsg(accessToken, opt)
|
16
|
+
response = HttpService.post("/chat/send?", {access_token: accessToken}, opt.to_json)
|
17
|
+
return response
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :oapi_host, :corpid, :secret, :agentid, :encoding_aes_key, :token
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@oapi_host = "https://oapi.dingtalk.com"
|
8
|
+
@corpid = ""
|
9
|
+
@secret = ""
|
10
|
+
|
11
|
+
@agentid = "" #必填,在创建微应用的时候会分配
|
12
|
+
@encoding_aes_key = "123456" #加解密需要用到的token,普通企业可以随机填写,例如:123456
|
13
|
+
@token = "111111111111111111111111111111111" #数据加密密钥。用于回调数据的加密,长度固定为43个字符,从a-z, A-Z, 0-9共62个字符中选取,您可以随机生成
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
class DepartmentService
|
4
|
+
|
5
|
+
def self.createDept(accessToken, dept)
|
6
|
+
response = HttpService.post("/department/create?", {access_token: accessToken}, dept.to_json)
|
7
|
+
return response
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.listDept(accessToken)
|
11
|
+
response = HttpService.get("/department/list?", {access_token: accessToken})
|
12
|
+
return response
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.list_ids(accessToken)
|
16
|
+
response = HttpService.get("/department/list_ids?", {access_token: accessToken})
|
17
|
+
return response
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.department_info(accessToken)
|
21
|
+
response = HttpService.get("/department/get?", {access_token: accessToken,id: 66950253})
|
22
|
+
return response
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.deleteDept(accessToken, id)
|
26
|
+
response = HttpService.get("/department/delete?",{access_token: accessToken, id: id})
|
27
|
+
return response
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
|
4
|
+
class HttpService
|
5
|
+
require 'net/https'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
@@oapi_host = 'https://oapi.dingtalk.com'
|
9
|
+
|
10
|
+
def self.get(url,params)
|
11
|
+
uri = URI.parse("#{@@oapi_host}/#{url}?")
|
12
|
+
uri.query = URI.encode_www_form(params)
|
13
|
+
res = Net::HTTP.get_response(uri)
|
14
|
+
if res.code == "200"
|
15
|
+
return resbody = JSON.parse(res.body)
|
16
|
+
end
|
17
|
+
return nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.post(url, params, data)
|
21
|
+
res = RestClient.post joinParams(url, params), data, :content_type => :json, :accept => :json
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.joinParams(path,params)
|
25
|
+
url = "#{@@oapi_host}#{path}"
|
26
|
+
if params.count > 0
|
27
|
+
url = url + "?"
|
28
|
+
params.each do |key,value|
|
29
|
+
url = url + key.to_s + "=" + value.to_s + "&";
|
30
|
+
end
|
31
|
+
url.last == "&" && url.chop!
|
32
|
+
end
|
33
|
+
return url
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
class LogService
|
4
|
+
|
5
|
+
def self.i(msg)
|
6
|
+
write("I",msg)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.e(msg)
|
10
|
+
write("E",msg)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.write(level,msg)
|
14
|
+
# TODO: 日志保存位置要修改
|
15
|
+
filename = Rails.root.to_s + "./log/my.log"
|
16
|
+
file = File.open(filename, "a")
|
17
|
+
file.write("#{level}/#{Time.now} #{msg}\n")
|
18
|
+
file.close
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
class MessageService
|
4
|
+
|
5
|
+
def self.sendToConversation(accessToken, opt)
|
6
|
+
response = HttpService.post("/message/send_to_conversation?", {access_token: accessToken}, opt.to_json)
|
7
|
+
return response
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.send(accessToken, opt)
|
11
|
+
response = HttpService.post("/message/send",{access_token: accessToken}, opt.to_json)
|
12
|
+
return response
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.send_chat(accessToken, opt)
|
16
|
+
response = HttpService.post("/chat/send",{access_token: accessToken}, opt.to_json)
|
17
|
+
return response
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rails
|
2
|
+
module Ding
|
3
|
+
class UserService
|
4
|
+
|
5
|
+
def self.getUserInfo(accessToken, code)
|
6
|
+
response = HttpService.get("/user/getuserinfo", {access_token: accessToken, code: code});
|
7
|
+
return response;
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.get(accessToken, userId)
|
11
|
+
response = HttpService.get("/user/get", {access_token: accessToken, userid: userId});
|
12
|
+
return response;
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.simplelist(accessToken,deptId)
|
16
|
+
response = HttpService.get("/user/simplelist", {access_token: accessToken,department_id: deptId});
|
17
|
+
return response;
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.list(accessToken,deptId)
|
21
|
+
response = HttpService.get("/user/list", {access_token: accessToken,department_id: deptId})
|
22
|
+
return response
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-ding
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ''
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: 提供钉钉开发服务端API
|
70
|
+
email:
|
71
|
+
- ''
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- app/assets/config/rails_ding_manifest.js
|
80
|
+
- app/assets/javascripts/rails/ding/application.js
|
81
|
+
- app/assets/stylesheets/rails/ding/application.css
|
82
|
+
- app/controllers/rails/ding/application_controller.rb
|
83
|
+
- app/helpers/rails/ding/application_helper.rb
|
84
|
+
- app/jobs/rails/ding/application_job.rb
|
85
|
+
- app/mailers/rails/ding/application_mailer.rb
|
86
|
+
- app/models/rails/ding/application_record.rb
|
87
|
+
- app/views/layouts/rails/ding/application.html.erb
|
88
|
+
- config/routes.rb
|
89
|
+
- lib/rails/ding.rb
|
90
|
+
- lib/rails/ding/auth_service.rb
|
91
|
+
- lib/rails/ding/cache_service.rb
|
92
|
+
- lib/rails/ding/chat_service.rb
|
93
|
+
- lib/rails/ding/configuration.rb
|
94
|
+
- lib/rails/ding/department_service.rb
|
95
|
+
- lib/rails/ding/engine.rb
|
96
|
+
- lib/rails/ding/http_service.rb
|
97
|
+
- lib/rails/ding/log_service.rb
|
98
|
+
- lib/rails/ding/message_service.rb
|
99
|
+
- lib/rails/ding/user_service.rb
|
100
|
+
- lib/rails/ding/version.rb
|
101
|
+
- lib/tasks/rails/ding_tasks.rake
|
102
|
+
homepage: http://www.liuxiaodao.top
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubygems_version: 3.0.6
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Ding API
|
125
|
+
test_files: []
|