feishu-api 0.2.0 → 0.3.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 +1 -2
- data/lib/feishu-api/api.rb +34 -27
- data/lib/feishu-api/version.rb +1 -1
- data/lib/feishu-api.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f8a52a4760d626bfb49812f6abc798505af00b137102ab705b638001b2f0816
|
4
|
+
data.tar.gz: c00d49d6647fb9243370793576f3125a34c9ab1535d50587b81f7e5303a0455d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a22fed44aee1d6965bf5aaceba272aeaf4528ac65386e2735f90e862cd680620cafa4364bc15b95104467c457c5ba9a203ee4a0aca0d2cbf78ccba0e5ff83cd8
|
7
|
+
data.tar.gz: 3baaceeab565d0a44aa4451baa930a6ad3067b7bca83dcadc2c85dad31fb09c3ea0063ef616b0ca1725c127e9efbfff9d5af6bebaf0b1c55007745fa24af88d9
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
# FeishuApi
|
2
|
-
|
1
|
+
# FeishuApi
|
3
2
|
|
4
3
|
FeishuApi is an integration of commonly used feishu open platform's APIs, easy to call.
|
5
4
|
|
data/lib/feishu-api/api.rb
CHANGED
@@ -22,7 +22,7 @@ module FeishuApi
|
|
22
22
|
HTTParty.post(api(url),
|
23
23
|
body: data.to_json,
|
24
24
|
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }.merge(headers),
|
25
|
-
timeout:
|
25
|
+
timeout: ,
|
26
26
|
verify: false)
|
27
27
|
end
|
28
28
|
|
@@ -30,70 +30,70 @@ module FeishuApi
|
|
30
30
|
HTTParty.post(api(url),
|
31
31
|
body: data,
|
32
32
|
headers: { Authorization: "Bearer #{tenant_access_token}" }.merge(headers),
|
33
|
-
timeout:
|
33
|
+
timeout: )
|
34
34
|
end
|
35
35
|
|
36
36
|
def post_with_user_token(url, user_access_token, data, headers = {}, timeout = 30)
|
37
37
|
HTTParty.post(api(url),
|
38
38
|
body: data,
|
39
39
|
headers: { Authorization: "Bearer #{user_access_token}" }.merge(headers),
|
40
|
-
timeout:
|
40
|
+
timeout: )
|
41
41
|
end
|
42
42
|
|
43
43
|
def get_with_token(url, data = {}, headers = {}, timeout = 30)
|
44
44
|
HTTParty.get(api(url),
|
45
45
|
body: data,
|
46
46
|
headers: { Authorization: "Bearer #{tenant_access_token}" }.merge(headers),
|
47
|
-
timeout:
|
47
|
+
timeout: )
|
48
48
|
end
|
49
49
|
|
50
50
|
def get_with_user_token(url, user_access_token, data = {}, headers = {}, timeout = 30)
|
51
51
|
HTTParty.get(api(url),
|
52
52
|
body: data,
|
53
53
|
headers: { Authorization: "Bearer #{user_access_token}" }.merge(headers),
|
54
|
-
timeout:
|
54
|
+
timeout: )
|
55
55
|
end
|
56
56
|
|
57
57
|
def put_with_token(url, data = {}, headers = {}, timeout = 30)
|
58
58
|
HTTParty.put(api(url),
|
59
59
|
body: data,
|
60
60
|
headers: { Authorization: "Bearer #{tenant_access_token}" }.merge(headers),
|
61
|
-
timeout:
|
61
|
+
timeout: )
|
62
62
|
end
|
63
63
|
|
64
64
|
def put_with_user_token(url, user_access_token, data = {}, headers = {}, timeout = 30)
|
65
65
|
HTTParty.put(api(url),
|
66
66
|
body: data,
|
67
67
|
headers: { Authorization: "Bearer #{user_access_token}" }.merge(headers),
|
68
|
-
timeout:
|
68
|
+
timeout: )
|
69
69
|
end
|
70
70
|
|
71
71
|
def delete_with_token(url, data = {}, headers = {}, timeout = 30)
|
72
72
|
HTTParty.delete(api(url),
|
73
73
|
body: data,
|
74
74
|
headers: { Authorization: "Bearer #{tenant_access_token}" }.merge(headers),
|
75
|
-
timeout:
|
75
|
+
timeout: )
|
76
76
|
end
|
77
77
|
|
78
78
|
def delete_with_user_token(url, user_access_token, data = {}, headers = {}, timeout = 30)
|
79
79
|
HTTParty.delete(api(url),
|
80
80
|
body: data,
|
81
81
|
headers: { Authorization: "Bearer #{user_access_token}" }.merge(headers),
|
82
|
-
timeout:
|
82
|
+
timeout: )
|
83
83
|
end
|
84
84
|
|
85
85
|
def patch_with_token(url, data = {}, headers = {}, timeout = 30)
|
86
86
|
HTTParty.patch(api(url),
|
87
87
|
body: data,
|
88
88
|
headers: { Authorization: "Bearer #{tenant_access_token}" }.merge(headers),
|
89
|
-
timeout:
|
89
|
+
timeout: )
|
90
90
|
end
|
91
91
|
|
92
92
|
def patch_with_user_token(url, user_access_token, data = {}, headers = {}, timeout = 30)
|
93
93
|
HTTParty.patch(api(url),
|
94
94
|
body: data,
|
95
95
|
headers: { Authorization: "Bearer #{user_access_token}" }.merge(headers),
|
96
|
-
timeout:
|
96
|
+
timeout: )
|
97
97
|
end
|
98
98
|
|
99
99
|
def tenant_access_token
|
@@ -128,7 +128,7 @@ module FeishuApi
|
|
128
128
|
# 发送消息
|
129
129
|
def send_message(receive_type, receive_id, msg_type, content)
|
130
130
|
res = post_with_token("#{API_SEND_MESSAGES}?receive_id_type=#{receive_type}",
|
131
|
-
{ receive_id:
|
131
|
+
{ receive_id: , msg_type: , content: })
|
132
132
|
# p res
|
133
133
|
return nil if res.code != 200
|
134
134
|
|
@@ -142,7 +142,7 @@ module FeishuApi
|
|
142
142
|
|
143
143
|
# 发文本消息到指定群聊
|
144
144
|
def send_text_by_group(receive_id, text)
|
145
|
-
send_message_by_group(receive_id, 'text', JSON.generate({ text:
|
145
|
+
send_message_by_group(receive_id, 'text', JSON.generate({ text: }))
|
146
146
|
end
|
147
147
|
|
148
148
|
# 上传图片
|
@@ -171,7 +171,7 @@ module FeishuApi
|
|
171
171
|
|
172
172
|
# 发文件消息到指定群聊
|
173
173
|
def send_file_by_group(receive_id, file_key)
|
174
|
-
send_message_by_group(receive_id, 'file', JSON.generate({ file_key:
|
174
|
+
send_message_by_group(receive_id, 'file', JSON.generate({ file_key: }))
|
175
175
|
end
|
176
176
|
|
177
177
|
# 撤回消息
|
@@ -186,7 +186,7 @@ module FeishuApi
|
|
186
186
|
|
187
187
|
# 发图片消息到指定群聊
|
188
188
|
def send_image_by_group(receive_id, image_key)
|
189
|
-
send_message_by_group(receive_id, 'image', JSON.generate({ image_key:
|
189
|
+
send_message_by_group(receive_id, 'image', JSON.generate({ image_key: }))
|
190
190
|
end
|
191
191
|
|
192
192
|
# 回复消息
|
@@ -294,13 +294,13 @@ module FeishuApi
|
|
294
294
|
# 将用户或机器人拉入群聊
|
295
295
|
def add_group_member(chat_id, id_list)
|
296
296
|
post_with_token("#{API_CHATS}/#{chat_id}/members",
|
297
|
-
{ id_list:
|
297
|
+
{ id_list: }.to_json, { 'Content-Type' => 'application/json', 'Accept' => 'application/json' })
|
298
298
|
end
|
299
299
|
|
300
300
|
# 将用户或机器人移出群聊
|
301
301
|
def delete_group_member(chat_id, id_list)
|
302
302
|
delete_with_token("#{API_CHATS}/#{chat_id}/members",
|
303
|
-
{ id_list:
|
303
|
+
{ id_list: }.to_json, { 'Content-Type' => 'application/json', 'Accept' => 'application/json' })
|
304
304
|
end
|
305
305
|
|
306
306
|
# 用户或机器人主动加入群聊
|
@@ -317,13 +317,13 @@ module FeishuApi
|
|
317
317
|
# 指定群管理员
|
318
318
|
def add_group_managers(chat_id, manager_ids)
|
319
319
|
post_with_token("#{API_CHATS}/#{chat_id}/managers/add_managers",
|
320
|
-
{ manager_ids:
|
320
|
+
{ manager_ids: }.to_json, { 'Content-Type' => 'application/json' })
|
321
321
|
end
|
322
322
|
|
323
323
|
# 删除群管理员
|
324
324
|
def delete_group_managers(chat_id, manager_ids)
|
325
325
|
post_with_token("#{API_CHATS}/#{chat_id}/managers/delete_managers",
|
326
|
-
{ manager_ids:
|
326
|
+
{ manager_ids: }.to_json, { 'Content-Type' => 'application/json' })
|
327
327
|
end
|
328
328
|
|
329
329
|
# 获取群成员列表
|
@@ -355,8 +355,15 @@ module FeishuApi
|
|
355
355
|
end
|
356
356
|
|
357
357
|
# 自定义机器人接口 发送消息
|
358
|
-
def custom_robot_send(data, hook_id)
|
359
|
-
|
358
|
+
def custom_robot_send(data, hook_id, secret = '')
|
359
|
+
if secret != ''
|
360
|
+
timestamp = Time.now.to_i.to_s
|
361
|
+
string_to_sign = "#{timestamp}\n#{secret}"
|
362
|
+
hmac_code = OpenSSL::HMAC.digest('sha256', string_to_sign, "")
|
363
|
+
sign = Base64.encode64(hmac_code).strip
|
364
|
+
data = {timestamp: , sign: }.merge(data)
|
365
|
+
end
|
366
|
+
res = post("#{API_CUSTOM_BOT_SEND}/#{hook_id}", data)
|
360
367
|
return nil if res.code != 200
|
361
368
|
|
362
369
|
JSON.parse(res.body)
|
@@ -375,7 +382,7 @@ module FeishuApi
|
|
375
382
|
{
|
376
383
|
check_field: 1,
|
377
384
|
check_mode: 1,
|
378
|
-
check_list:
|
385
|
+
check_list:
|
379
386
|
}
|
380
387
|
]
|
381
388
|
}
|
@@ -410,7 +417,7 @@ module FeishuApi
|
|
410
417
|
{
|
411
418
|
check_field: 1,
|
412
419
|
check_mode: 1,
|
413
|
-
check_list:
|
420
|
+
check_list:
|
414
421
|
}
|
415
422
|
]
|
416
423
|
}
|
@@ -470,7 +477,7 @@ module FeishuApi
|
|
470
477
|
[
|
471
478
|
{
|
472
479
|
tag: 'text',
|
473
|
-
text:
|
480
|
+
text:
|
474
481
|
}
|
475
482
|
]
|
476
483
|
]
|
@@ -481,7 +488,7 @@ module FeishuApi
|
|
481
488
|
end
|
482
489
|
|
483
490
|
# 自定义机器人接口 发送卡片消息
|
484
|
-
def custom_robot_send_card(title = '标题', theme = 'blue', elements = [], hook_id = '')
|
491
|
+
def custom_robot_send_card(title = '标题', theme = 'blue', elements = [], hook_id = '', secret = '')
|
485
492
|
custom_robot_send({
|
486
493
|
msg_type: 'interactive',
|
487
494
|
card: {
|
@@ -495,9 +502,9 @@ module FeishuApi
|
|
495
502
|
},
|
496
503
|
template: theme
|
497
504
|
},
|
498
|
-
elements:
|
505
|
+
elements:
|
499
506
|
}
|
500
|
-
}, hook_id)
|
507
|
+
}, hook_id, secret)
|
501
508
|
end
|
502
509
|
end
|
503
510
|
end
|
data/lib/feishu-api/version.rb
CHANGED
data/lib/feishu-api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feishu-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- msk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -43,7 +43,7 @@ homepage: https://github.com/ruilisi/feishu-api
|
|
43
43
|
licenses:
|
44
44
|
- MIT
|
45
45
|
metadata:
|
46
|
-
rubygems_mfa_required: '
|
46
|
+
rubygems_mfa_required: 'true'
|
47
47
|
homepage_uri: https://github.com/ruilisi/feishu-api
|
48
48
|
source_code_uri: https://github.com/ruilisi/feishu-api.git
|
49
49
|
changelog_uri: https://github.com/ruilisi/feishu-api/blob/master/CHANGELOG.md
|