dingtalktool 1.0.0 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bab772daeafd5d6452b208713111534c455fd08381b6a216af9d706c6ab648e7
4
- data.tar.gz: 32bf9ac444875ad818d039ea698dd8719c1ae4019cfb3b3a678a8d6894d0a4e1
3
+ metadata.gz: f1b9b3942121d0cb7e7bdb65e79d6a1d3a1907cf8bd8b2bc14dd0ef84ecd16af
4
+ data.tar.gz: 8ea670f66c33ea56d1db1cee589df263aadb142fbf6c515c80aa05b56ca85f4e
5
5
  SHA512:
6
- metadata.gz: 235db52a704fbe09fea9429c253773dabfa23df12ad226344d32b56551fd8240dde9f3071166f5e79df18bf186db5e958bfc2e43f9e9f9b8cb9cbb637cd75db4
7
- data.tar.gz: 3f1a583e062a743539795e553a23f9997831f3b8de1714eec4d5876dcd86e5322a9bdaa83ea7365c2931134373519112424b48924d211ef536f7bd36e3b57e70
6
+ metadata.gz: 39f88280cf3f13a7339d770bbe909add4951fed5d7d3734df40af6a01b28605dd8f079aa901897f41ba3e7e99a1e8dba1d9bf6000a47c9fb30e777933dba6835
7
+ data.tar.gz: 11af62d88cce0a5735d5dff9ee98a7b02f2824b08140f4ab3d7a12854c3b3520c306f7c943dcf275a14e2121e5bcd3be28bb56012b9223a5510b1cf25b88e5e1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dingtalktool (1.0.0)
4
+ dingtalktool (1.0.2)
5
5
  rest-client
6
6
 
7
7
  GEM
@@ -15,9 +15,9 @@ GEM
15
15
  http-cookie (1.0.3)
16
16
  domain_name (~> 0.5)
17
17
  method_source (0.9.2)
18
- mime-types (3.3)
18
+ mime-types (3.3.1)
19
19
  mime-types-data (~> 3.2015)
20
- mime-types-data (3.2019.1009)
20
+ mime-types-data (3.2020.0512)
21
21
  netrc (0.11.0)
22
22
  pry (0.11.3)
23
23
  coderay (~> 1.1.0)
@@ -43,7 +43,7 @@ GEM
43
43
  rspec-support (3.7.1)
44
44
  unf (0.1.4)
45
45
  unf_ext
46
- unf_ext (0.0.7.6)
46
+ unf_ext (0.0.7.7)
47
47
 
48
48
  PLATFORMS
49
49
  ruby
data/README.md CHANGED
@@ -1,8 +1,26 @@
1
1
  # Dingtalktool
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dingtalktool`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ 钉钉企业内部应用服务端API,现在已经实现接口:
4
+
5
+ + 获取access_token
6
+ + 通讯录管理
7
+ - 部门管理
8
+ + 创建部门
9
+ + 获取子部门ID列表
10
+ + 获取部门列表
11
+ + 获取部门详情
12
+ + 删除部门
13
+ + 用户管理
14
+ + 获取用户详情
15
+ + 获取部门用户
16
+ + 消息通知
17
+ + 创建会话
18
+ + 发送群消息
19
+ + ~bindChat(钉钉文档中找不到)~
20
+ + 考勤
21
+ + 获取打卡详情
22
+ + 获取打卡结果
4
23
 
5
- TODO: Delete this and the text above, and describe your gem
6
24
 
7
25
  ## Installation
8
26
 
@@ -22,7 +40,170 @@ Or install it yourself as:
22
40
 
23
41
  ## Usage
24
42
 
25
- TODO: Write usage instructions here
43
+ 1.添加config/initializers/dingtalktool.rb
44
+
45
+ ```ruby
46
+ Dingtalktool.configure do |configuration|
47
+ configuration.corpid = "" # 必填, 企业自用账号信息中CorpId
48
+ configuration.secret = "" # 必填, 开发体验账号管理里面的CorpSecret
49
+ configuration.agentid = "" #必填,在创建微应用的时候会分配
50
+ end
51
+ ```
52
+ 2.添加配置之后就能直接使用gem提供的功能
53
+
54
+ + 获取token
55
+ ```ruby
56
+ token = Dingtalktool::AuthService.getAccessToken # 返回token字符串
57
+ ```
58
+ + 获取部门列表
59
+ ```ruby
60
+ department_res = Dingtalktool::DepartmentService.listDept(token)
61
+ ```
62
+ + 获取部门下所有员工
63
+ ```ruby
64
+ # 获取当个部门员工
65
+ department_users = Dingtalktool::UserService.list(token, department_id)
66
+ ```
67
+ + 获取员工打卡详情
68
+ ```ruby
69
+ userIds = User.all.map(&:userid).uniq
70
+ user_ids = Array(userIds.each_slice(50)) # 每次最多查询50位员工,所以这里要把所有员工id分开
71
+ result = []
72
+ user_ids.each do |users|
73
+ data = {
74
+ userIds: users,
75
+ checkDateFrom: Time.now.beginning_of_day.strftime("%Y-%m-%d %H:%M:%S"),
76
+ checkDateTo: Time.now.end_of_day.strftime("%Y-%m-%d %H:%M:%S"),
77
+ isI18n: 'false'
78
+ }
79
+ listRecord = Dingtalktool::AttendanceService.listRecord(token, data)
80
+ if listRecord['errcode'] == 0 && listRecord['errmsg'] == 'ok'
81
+ result += listRecord['recordresult']
82
+ end
83
+ end
84
+ ```
85
+
86
+ 更多方法请查看下面文件结构
87
+
88
+ ## 文件结构, 类, 方法
89
+ ├── dingtalktool
90
+ │        ├── attendance_service.rb
91
+ │        ├── auth_service.rb
92
+ │        ├── cache_service.rb
93
+ │        ├── chat_service.rb
94
+ │        ├── configuration.rb
95
+ │        ├── department_service.rb
96
+ │        ├── http_service.rb
97
+ │        ├── log_service.rb
98
+ │        ├── message_service.rb
99
+ │        ├── user_service.rb
100
+ │        └── version.rb
101
+ └── dingtalktool.rb
102
+
103
+ <table>
104
+ <tr>
105
+ <td>类名</td>
106
+ <td>方法</td>
107
+ <td>备注</td>
108
+ </tr>
109
+ <tr>
110
+ <td rowspan='2'>AttendanceService</td>
111
+ <td>listRecord</td>
112
+ <td></td>
113
+ </tr>
114
+ <tr>
115
+ <td>list</td>
116
+ <td></td>
117
+ </tr>
118
+ <tr>
119
+ <td rowspan='2'>AuthService</td>
120
+ <td>getAccessToken</td>
121
+ <td></td>
122
+ </tr>
123
+ <tr>
124
+ <td>getTicket</td>
125
+ <td></td>
126
+ </tr>
127
+ <tr>
128
+ <td rowspan='3'>ChatService</td>
129
+ <td>createChat</td>
130
+ <td></td>
131
+ </tr>
132
+ <tr>
133
+ <td>bindChat</td>
134
+ <td></td>
135
+ </tr>
136
+ <tr>
137
+ <td>sendmsg</td>
138
+ <td></td>
139
+ </tr>
140
+ <tr>
141
+ <td rowspan='5'>DepartmentService</td>
142
+ <td>createDept</td>
143
+ <td></td>
144
+ </tr>
145
+ <tr>
146
+ <td>listDept</td>
147
+ <td></td>
148
+ </tr>
149
+ <tr>
150
+ <td>list_ids</td>
151
+ <td></td>
152
+ </tr>
153
+ <tr>
154
+ <td>department_info</td>
155
+ <td></td>
156
+ </tr>
157
+ <tr>
158
+ <td>deleteDept</td>
159
+ <td></td>
160
+ </tr>
161
+ <tr>
162
+ <td rowspan='3'>MessageService</td>
163
+ <td>sendToConversation</td>
164
+ <td></td>
165
+ </tr>
166
+ <tr>
167
+ <td>send</td>
168
+ <td></td>
169
+ </tr>
170
+ <tr>
171
+ <td>send_chat</td>
172
+ <td></td>
173
+ </tr>
174
+ <tr>
175
+ <td rowspan='4'>UserService</td>
176
+ <td>getUserInfo</td>
177
+ <td></td>
178
+ </tr>
179
+ <tr>
180
+ <td>get</td>
181
+ <td></td>
182
+ </tr>
183
+ <tr>
184
+ <td>simplelist</td>
185
+ <td></td>
186
+ </tr>
187
+ <tr>
188
+ <td>list</td>
189
+ <td></td>
190
+ </tr>
191
+ </table>
192
+
193
+ ## 未完待续
194
+ + 添加所有服务端API
195
+ + 优化调用方式
196
+
197
+ ## 联系方式
198
+ 有任何问题都联系我
199
+ + 邮箱: liu_xiaodao@163.com
200
+ + 微信/QQ: 957419420
201
+
202
+ ## 修改记录
203
+ 1.0.2 缓存文件和日至文件位置修改
204
+
205
+ ## 其他
206
+ 以上功能是为了满足我自己一个项目写的,所以只包含了钉钉服务端API的一小部分,后面我会持续优化,谢谢,这也是我写的第一个正式的gem
26
207
 
27
208
  ## Development
28
209
 
@@ -32,7 +213,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
213
 
33
214
  ## Contributing
34
215
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dingtalktool. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
216
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Liu-XiaoDao/dingtalktool. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
217
 
37
218
  ## License
38
219
 
@@ -40,4 +221,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
221
 
41
222
  ## Code of Conduct
42
223
 
43
- Everyone interacting in the Dingtalktool project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/dingtalktool/blob/master/CODE_OF_CONDUCT.md).
224
+ Everyone interacting in the Dingtalktool project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Liu-XiaoDao/dingtalktool/blob/master/CODE_OF_CONDUCT.md).
@@ -1,7 +1,6 @@
1
1
  require 'yaml'
2
2
  module Dingtalktool
3
3
  class CacheService
4
-
5
4
  def self.setJsTicket(ticket)
6
5
  set("js_ticket", ticket, ex: 7000); # js ticket有效期为7200秒,这里设置为7000秒
7
6
  end
@@ -30,7 +29,7 @@ module Dingtalktool
30
29
  def self.set(key,value,options = {})
31
30
  ex = options[:ex] ? Time.now.to_i + options[:ex] : 0
32
31
  if key && value
33
- data = get_file("./filecache.yml")
32
+ data = get_file("tmp/cache/filecache.yml")
34
33
 
35
34
  item = {}
36
35
  item["#{key}"] = value
@@ -43,7 +42,7 @@ module Dingtalktool
43
42
 
44
43
  def self.get(key)
45
44
  if key && key.is_a?(String)
46
- data = get_file("./filecache.yml")
45
+ data = get_file("tmp/cache/filecache.yml")
47
46
  if !data.empty? && data.has_key?(key)
48
47
  item = data["#{key}"]
49
48
  return false if !item
@@ -71,6 +70,5 @@ module Dingtalktool
71
70
  file.write(content)
72
71
  file.close unless file.nil?
73
72
  end
74
-
75
73
  end
76
74
  end
@@ -10,7 +10,7 @@ module Dingtalktool
10
10
 
11
11
  def self.write(level,msg)
12
12
  # TODO: 日志保存位置要修改
13
- filename = "./my.log"
13
+ filename = "log/dingtalktool.log"
14
14
  file = File.open(filename, "a")
15
15
  file.write("#{level}/#{Time.now} #{msg}\n")
16
16
  file.close
@@ -1,3 +1,3 @@
1
1
  module Dingtalktool
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dingtalktool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - liuchunliang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-17 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,7 +99,6 @@ files:
99
99
  - bin/console
100
100
  - bin/setup
101
101
  - dingtalktool.gemspec
102
- - filecache.yml
103
102
  - lib/dingtalktool.rb
104
103
  - lib/dingtalktool/attendance_service.rb
105
104
  - lib/dingtalktool/auth_service.rb
@@ -112,7 +111,6 @@ files:
112
111
  - lib/dingtalktool/message_service.rb
113
112
  - lib/dingtalktool/user_service.rb
114
113
  - lib/dingtalktool/version.rb
115
- - my.log
116
114
  homepage: http://www.liuxiaodao.top
117
115
  licenses:
118
116
  - MIT
@@ -1 +0,0 @@
1
- {"corp_access_token":{"corp_access_token":"8190da179494368db97e76265852856b","expire_time":1571198008,"create_time":1571191008}}
data/my.log DELETED
@@ -1 +0,0 @@
1
- E/2019-10-15 12:43:17 +0800 FAIL: {"errcode":40035,"errmsg":"缺少参数 corpid or appkey"}