lark-sdk 0.1.3 → 0.1.4

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: 283c15aa793085cf71527bb8247217459cd7e6b9db0d4502ab95f92d9b0c3089
4
- data.tar.gz: bea838de0f1a730e49fbd3eb52409a1ade9aec5f8e27dd45c2df1627bda09d83
3
+ metadata.gz: 3d003559941994a3ad24c337838ee49a4517e179bc2841c2849da6c53a00f7d2
4
+ data.tar.gz: bdf9b9f83de83a3cb9be0d3c72bd08c30bb227649141384c205fc6fe5fe962fb
5
5
  SHA512:
6
- metadata.gz: 5cc0a16e817df19f858ac78de511d92be06a3a26d4d30740e5da46b6638328b27ad1cd0613367244be19850d814e18fde7ae5f83ac193c83e4ff169c98e18db1
7
- data.tar.gz: 5cb27ff877cb16d5214ba101cf38224fc8083528ed8ecbef2776f82fb9f377ef1c7df7a6865c9eb61655caa6111fc1d557abb6928a2ae82f48c7bd9d2f343d1b
6
+ metadata.gz: 9cde1e843859bd25b90b46b432fb37fe8a0425386a481a40ce2015cab8da0765d7689692f51ae8c8e754ec3b4b601ebe1f7a5be418240de0fe0c9dd2cc2fa786
7
+ data.tar.gz: e4515c1340f7a15c48c615cb04a196cd7641d2ef28ebb564f27abf74438813350396ee392dbb740434f52f1d33749cb9057cea90d6e8daaf78b9ee71475b568b
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Unofficial ruby SDKS for lark [飞书](https://www.feishu.cn/)
4
4
 
5
- ## Installation
5
+ ## 安装
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
@@ -18,10 +18,11 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install lark-sdk
20
20
 
21
+ require 'lark/sdk'
21
22
 
22
- ## Usage
23
+ ## 使用说明
23
24
 
24
- Add initialize configure to your project:
25
+ 初始化配置:
25
26
 
26
27
  ```ruby
27
28
  # config/initializers/lark.rb
@@ -32,75 +33,155 @@ Lark.configure do |config|
32
33
  end
33
34
  ```
34
35
 
35
- Create lark API
36
+ 新建 Lark API 接口实例:
36
37
 
37
38
  ```ruby
38
39
  api = Lark::Api.new(
39
40
  app_id: 'xxx',
40
41
  app_secret: 'xxx',
41
42
  tenant_key: 'xxx',
42
- isv: false/true, # Internal app: false, ISV app: true
43
+ isv: false/true, # 自建应用: false, 应用商店应用: true
43
44
  )
44
45
  ```
45
46
 
46
- Invoke lark api, For example:
47
+ 加/解密:
47
48
 
48
49
  ```ruby
49
- # Get chat list
50
- api.chat.list
51
- ```
52
50
 
53
- Decrypt message
51
+ cipher = Lark::Cipher.new(encrypt_key)
54
52
 
55
- ```ruby
56
- Lark::Cipher.new(encrypt_key).decrypt(message)
53
+ # 解密
54
+ cipher.decrypt(message)
57
55
 
58
- # eg:
59
- # encrypt = "P37w+VZImNgPEO1RBhJ6RtKl7n6zymIbEG1pReEzghk="
60
- # Lark::Cipher.new('test key').decrypt encrypt
61
- # => 'hello world'
56
+ # 加密
57
+ cipher.encrypt(message)
62
58
  ```
63
59
 
64
- ## Api List
65
-
66
- ### 授权 (auth)
67
-
68
- 获取 app_access_token
69
-
70
- api.app_access_token
71
-
72
- 获取 tenant_access_token
73
-
74
- api.tenant_access_token
75
-
76
- 重新推送 app_ticket
77
-
78
- api.auth.app_ticket_resend
79
-
80
- 更新 app_ticket
81
-
82
- api.app_ticket = xxxx
83
-
84
- ### 身份验证 (authen)
85
-
86
- 请求身份验证
87
-
88
- api.authen.index(redirect_uri, state)
89
-
90
- 获取登录用户身份
91
-
92
- api.authen.access_token(code)
93
-
94
- 刷新 access_token
95
-
96
- api.authen.refresh_access_token(refresh_token)
97
-
98
- 获取用户信息
99
-
100
- api.user_info(user_access_token)
101
-
102
-
103
- ...
60
+ ## Api 列表
61
+
62
+ ### 授权
63
+ [`lib/lark/apis/auth.rb`](lib/lark/apis/auth.rb)
64
+
65
+ | 名称 | 接口 |
66
+ | --- | --- |
67
+ | [获取 app_access_token](https://open.feishu.cn/document/ukTMukTMukTM/uADN14CM0UjLwQTN) | `api.app_access_token` |
68
+ | [获取 tenant_access_token](https://open.feishu.cn/document/ukTMukTMukTM/uEjNz4SM2MjLxYzM) | `api.tenant_access_token` |
69
+ | 更新 app_ticket | `api.app_ticket=` |
70
+ | 获取 app_ticket | `api.app_ticket` |
71
+ | [重新推送 app_ticket](https://open.feishu.cn/document/ukTMukTMukTM/uQjNz4CN2MjL0YzM) | `api.auth.app_ticket_resend` |
72
+
73
+ ### 身份验证
74
+ [`lib/lark/apis/authen.rb`](lib/lark/apis/authen.rb)
75
+
76
+ | 名称 | 接口 |
77
+ | --- | --- |
78
+ | [请求身份验证](https://open.feishu.cn/document/ukTMukTMukTM/ukzN4UjL5cDO14SO3gTN) | `api.authen.index(redirect_uri, state)` |
79
+ | [获取登录用户身份](https://open.feishu.cn/document/ukTMukTMukTM/uEDO4UjLxgDO14SM4gTN) | `api.authen.access_token(code)` |
80
+ | [刷新 access_token](https://open.feishu.cn/document/ukTMukTMukTM/uQDO4UjL0gDO14CN4gTN) | `api.authen.refresh_access_token(refresh_token)` |
81
+ | [获取用户信息](https://open.feishu.cn/document/ukTMukTMukTM/uIDO4UjLygDO14iM4gTN) | `api.authen.user_info(user_access_token)` |
82
+
83
+
84
+ ### 通讯录
85
+ [`lib/lark/apis/contact.rb`](lib/lark/apis/contact.rb)
86
+
87
+ | 名称 | 接口 |
88
+ | --- | --- |
89
+ | [获取通讯录授权范围](https://open.feishu.cn/document/ukTMukTMukTM/ugjNz4CO2MjL4YzM) | `api.contact.scope_get` |
90
+ | [新增部门](https://open.feishu.cn/document/ukTMukTMukTM/uYzNz4iN3MjL2czM) | `api.contact.department_add` |
91
+ | [批量新增部门](https://open.feishu.cn/document/ukTMukTMukTM/uMDOwUjLzgDM14yM4ATN) | `api.contact.department_batch_add` |
92
+ | [删除部门](https://open.feishu.cn/document/ukTMukTMukTM/ugzNz4CO3MjL4czM) | `api.contact.department_delete` |
93
+ | [更新部门信息](https://open.feishu.cn/document/ukTMukTMukTM/uczNz4yN3MjL3czM) | `api.contact.department_update` |
94
+ | [获取部门详情](https://open.feishu.cn/document/ukTMukTMukTM/uAzNz4CM3MjLwczM) | `api.contact.department_get` |
95
+ | [获取子部门列表](https://open.feishu.cn/document/ukTMukTMukTM/ugzN3QjL4czN04CO3cDN) | `api.contact.department_children` |
96
+ | [获取子部门 ID 列表](https://open.feishu.cn/document/ukTMukTMukTM/ukjNz4SO2MjL5YzM) | `api.contact.department_children_ids` |
97
+ | [批量获取部门详情](https://open.feishu.cn/document/ukTMukTMukTM/uczN3QjL3czN04yN3cDN) | `api.contact.department_batch_get` |
98
+ | [获取部门用户列表](https://open.feishu.cn/document/ukTMukTMukTM/uEzNz4SM3MjLxczM) | `api.contact.department_user_list` |
99
+ | [获取部门用户详情](https://open.feishu.cn/document/ukTMukTMukTM/uYzN3QjL2czN04iN3cDN) | `api.contact.department_user_detail_list` |
100
+ | [新增用户](https://open.feishu.cn/document/ukTMukTMukTM/uMzNz4yM3MjLzczM) | `api.contact.user_add` |
101
+ | [批量新增用户](https://open.feishu.cn/document/ukTMukTMukTM/uIDOwUjLygDM14iM4ATN) | `api.contact.user_batch_add` |
102
+ | [删除用户](https://open.feishu.cn/document/ukTMukTMukTM/uUzNz4SN3MjL1czM) | `api.contact.user_delete` |
103
+ | [更新用户信息](https://open.feishu.cn/document/ukTMukTMukTM/uQzNz4CN3MjL0czM) | `api.contact.user_update` |
104
+ | [批量获取用户信息](https://open.feishu.cn/document/ukTMukTMukTM/uIzNz4iM3MjLyczM) | `api.contact.user_batch_get` |
105
+ | [获取企业自定义用户属性配置](https://open.feishu.cn/document/ukTMukTMukTM/ucTN3QjL3UzN04yN1cDN) | `api.contact.tenant_custom_attr_get` |
106
+ | [查询批量任务执行状态](https://open.feishu.cn/document/ukTMukTMukTM/uUDOwUjL1gDM14SN4ATN) | `api.contact.task_get` |
107
+ | [获取应用管理员管理范围](https://open.feishu.cn/document/ukTMukTMukTM/uMzN3QjLzczN04yM3cDN) | `api.contact.user_admin_scope_get` |
108
+ | [获取角色列表](https://open.feishu.cn/document/ukTMukTMukTM/uYzMwUjL2MDM14iNzATN) | `api.contact.role_list` |
109
+ | [获取角色成员列表](https://open.feishu.cn/document/ukTMukTMukTM/uczMwUjL3MDM14yNzATN) | `api.contact.role_members` |
110
+ | [使用手机号或邮箱获取用户 ID](https://open.feishu.cn/document/ukTMukTMukTM/uUzMyUjL1MjM14SNzITN) | `api.user.batch_get_id` |
111
+
112
+
113
+ ### 用户群组
114
+ [`lib/lark/apis/user.rb`](lib/lark/apis/user.rb)
115
+
116
+ | 名称 | 接口 |
117
+ | --- | --- |
118
+ | [获取用户所在的群列表](https://open.feishu.cn/document/ukTMukTMukTM/uQzMwUjL0MDM14CNzATN) | `api.user.group_list` |
119
+ | [获取群成员列表](https://open.feishu.cn/document/ukTMukTMukTM/uUzMwUjL1MDM14SNzATN) | `api.chat.members` |
120
+ | [搜索用户所在的群列表](https://open.feishu.cn/document/ukTMukTMukTM/uUTOyUjL1kjM14SN5ITN) | `api.chat.search` |
121
+
122
+
123
+ ### 应用管理
124
+ [`lib/lark/apis/application.rb`](lib/lark/apis/application.rb)
125
+
126
+ | 名称 | 接口 |
127
+ | --- | --- |
128
+ | [校验应用管理员](https://open.feishu.cn/document/ukTMukTMukTM/uITN1EjLyUTNx4iM1UTM) | `api.application.is_user_admin` |
129
+ | [获取应用在企业内的可用范围](https://open.feishu.cn/document/ukTMukTMukTM/uIjM3UjLyIzN14iMycTN) | `api.application.app_visibility` |
130
+ | [获取用户可用的应用](https://open.feishu.cn/document/ukTMukTMukTM/uMjM3UjLzIzN14yMycTN) | `api.application.user_visible_apps` |
131
+ | [获取企业安装的应用](https://open.feishu.cn/document/ukTMukTMukTM/uYDN3UjL2QzN14iN0cTN) | `api.application.app_list` |
132
+ | [更新应用可用范围](https://open.feishu.cn/document/ukTMukTMukTM/ucDN3UjL3QzN14yN0cTN) | `api.application.app_update_visibility` |
133
+
134
+
135
+ ### 应用商店
136
+ [`lib/lark/apis/pay.rb`](lib/lark/apis/pay.rb)
137
+
138
+ | 名称 | 接口 |
139
+ | --- | --- |
140
+ | [查询用户是否在应用开通范围](查询用户是否在应用开通范围) | `api.pay.paid_scope_check_user` |
141
+ | [查询租户购买的付费方案](https://open.feishu.cn/document/ukTMukTMukTM/uETNwUjLxUDM14SM1ATN) | `api.pay.order_list` |
142
+ | [查询订单详情](https://open.feishu.cn/document/ukTMukTMukTM/uITNwUjLyUDM14iM1ATN) | `api.pay.order_get` |
143
+
144
+
145
+ ### 机器人 → 群信息和群管理
146
+ [`lib/lark/apis/chat.rb`](lib/lark/apis/chat.rb)
147
+
148
+ | 名称 | 接口 |
149
+ | --- | --- |
150
+ | [创建群](https://open.feishu.cn/document/ukTMukTMukTM/ukDO5QjL5gTO04SO4kDN) | `api.chat.create` |
151
+ | [获取群列表](https://open.feishu.cn/document/ukTMukTMukTM/uITO5QjLykTO04iM5kDN) | `api.chat.list` |
152
+ | [获取群信息](https://open.feishu.cn/document/ukTMukTMukTM/uMTO5QjLzkTO04yM5kDN) | `api.chat.info` |
153
+ | [更新群信息](https://open.feishu.cn/document/ukTMukTMukTM/uYTO5QjL2kTO04iN5kDN) | `api.chat.update` |
154
+ | [拉用户进群](https://open.feishu.cn/document/ukTMukTMukTM/ucTO5QjL3kTO04yN5kDN) | `api.chat.chatter_add` |
155
+ | [移除用户出群](https://open.feishu.cn/document/ukTMukTMukTM/uADMwUjLwADM14CMwATN) | `api.chat.chatter_delete` |
156
+ | [解散群](https://open.feishu.cn/document/ukTMukTMukTM/uUDN5QjL1QTO04SN0kDN) | `api.chat.disband` |
157
+
158
+
159
+ ### 机器人信息和管理
160
+ [`lib/lark/apis/bot.rb`](lib/lark/apis/bot.rb)
161
+
162
+ | 名称 | 接口 |
163
+ | --- | --- |
164
+ | [获取机器人信息](https://open.feishu.cn/document/ukTMukTMukTM/uAjMxEjLwITMx4CMyETM) | `api.bot.info` |
165
+ | [拉机器人进群](https://open.feishu.cn/document/ukTMukTMukTM/uYDO04iN4QjL2gDN) | `api.bot.add` |
166
+ | [将机器人移出群](https://open.feishu.cn/document/ukTMukTMukTM/ucDO04yN4QjL3gDN) | `api.bot.remove` |
167
+
168
+
169
+ ### 消息
170
+ [`lib/lark/apis/message.rb`](lib/lark/apis/message.rb)
171
+
172
+ | 名称 | 接口 |
173
+ | --- | --- |
174
+ | [批量发送消息](https://open.feishu.cn/document/ukTMukTMukTM/ucDO1EjL3gTNx4yN4UTM) | `api.message.batch_send` |
175
+ | [发送消息(文本/图片/富文本/名片/卡片)](https://open.feishu.cn/document/ukTMukTMukTM/uUjNz4SN2MjL1YzM) | `api.message.direct_send` |
176
+
177
+
178
+ ### 图片
179
+ [`lib/lark/apis/image.rb`](lib/lark/apis/image.rb)
180
+
181
+ | 名称 | 接口 |
182
+ | --- | --- |
183
+ | [上传图片](https://open.feishu.cn/document/ukTMukTMukTM/uEDO04SM4QjLxgDN) | `api.image.upload` |
184
+ | [获取图片](https://open.feishu.cn/document/ukTMukTMukTM/uYzN5QjL2cTO04iN3kDN) | `api.image.download` |
104
185
 
105
186
 
106
187
  ## Development
data/lib/lark/api.rb CHANGED
@@ -2,15 +2,20 @@ require 'lark/request'
2
2
 
3
3
  module Lark
4
4
  class Api
5
- include Route
5
+ include Helper
6
6
  include Apis::Message
7
7
  include Apis::Chat
8
8
 
9
- mount :auth
10
- mount :authen
11
- mount :contact
12
- mount :chat
13
- mount :message
9
+ api_mount :auth
10
+ api_mount :authen
11
+ api_mount :contact
12
+ api_mount :user
13
+ api_mount :application
14
+ api_mount :pay
15
+ api_mount :chat
16
+ api_mount :bot
17
+ api_mount :message
18
+ api_mount :image
14
19
 
15
20
  attr_reader :app_id, :app_secret, :tenant_key, :isv, :options
16
21
 
@@ -79,8 +84,11 @@ module Lark
79
84
  end
80
85
 
81
86
  def with_token(headers, tries=2)
82
- via = headers[:via] || 'tenant'
83
- token = send("#{via}_access_token")
87
+ token = headers[:access_token]
88
+ if token.nil?
89
+ via = headers[:via] || 'tenant'
90
+ token = send("#{via}_access_token")
91
+ end
84
92
  yield headers.merge(authorization: "Bearer #{token}")
85
93
  rescue AccessTokenExpiredError
86
94
  send("#{via}_token_store").fetch_token
@@ -0,0 +1,29 @@
1
+ module Lark
2
+ module Apis
3
+ module Application
4
+ def is_user_admin(params={})
5
+ get 'application/v3/is_user_admin', params: params
6
+ end
7
+
8
+ def app_visibility(app_id:, user_page_token: nil, user_page_size: nil)
9
+ get 'application/v1/app/visibility', params: {
10
+ app_id: app_id,
11
+ user_page_token: user_page_token,
12
+ user_page_size: user_page_size
13
+ }.compact
14
+ end
15
+
16
+ def user_visible_apps(params={})
17
+ get 'application/v1/user/visible_apps', params: params
18
+ end
19
+
20
+ def app_list(params={})
21
+ get 'application/v3/app/list', params: params
22
+ end
23
+
24
+ def app_update_visibility(payload={})
25
+ post 'application/v3/app/update_visibility', payload
26
+ end
27
+ end
28
+ end
29
+ end
@@ -25,7 +25,7 @@ module Lark
25
25
  end
26
26
 
27
27
  def user_info(user_access_token)
28
- request.get('authen/v1/user_info', params: {user_access_token: user_access_token})
28
+ request.get('authen/v1/user_info', {access_token: user_access_token}
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,17 @@
1
+ module Lark
2
+ module Apis
3
+ module Bot
4
+ def info
5
+ get 'bot/v3/info/'
6
+ end
7
+
8
+ def add(chat_id)
9
+ post 'bot/v3/add', {chat_id: chat_id}
10
+ end
11
+
12
+ def remove(chat_id)
13
+ post 'bot/v3/remove', {chat_id: chat_id}
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,8 +1,64 @@
1
1
  module Lark
2
2
  module Apis
3
3
  module Chat
4
- def list(params={})
5
- post 'chat/v4/list', params: params
4
+ def members(user_access_token:, chat_id:, page_size: nil, page_token: nil)
5
+ get 'chat/v4/members', {
6
+ access_token: user_access_token,
7
+ params: {
8
+ page_size: page_size,
9
+ page_token: page_token
10
+ }.compact
11
+ end
12
+
13
+ def search(user_access_token:, query:, page_size: nil, page_token: nil)
14
+ get 'chat/v4/members', {
15
+ access_token: user_access_token,
16
+ params: {
17
+ access_token: user_access_token,
18
+ query: query,
19
+ page_size: page_size,
20
+ page_token: page_token
21
+ }
22
+ }.compact
23
+ end
24
+
25
+ def create(payload={})
26
+ post 'chat/v4/create/', payload
27
+ end
28
+
29
+ def list(page_size: nil, page_token: nil)
30
+ get 'chat/v4/list/', params: {
31
+ page_size: page_size,
32
+ page_token: page_token
33
+ }.compact
34
+ end
35
+
36
+ def info(chat_id)
37
+ get 'chat/v4/info/', params: {chat_id: chat_id}
38
+ end
39
+
40
+ def update(payload={})
41
+ get 'chat/v4/update/', payload
42
+ end
43
+
44
+ def chatter_add(chat_id:, user_ids: nil, open_ids: nil)
45
+ post 'chat/v4/chatter/add/', {
46
+ chat_id: chat_id,
47
+ user_ids: user_ids,
48
+ open_ids: open_ids
49
+ }.compact
50
+ end
51
+
52
+ def chatter_delete(chat_id:, user_ids: nil, open_ids: nil)
53
+ post 'chat/v4/chatter/delete/', {
54
+ chat_id: chat_id,
55
+ user_ids: user_ids,
56
+ open_ids: open_ids
57
+ }.compact
58
+ end
59
+
60
+ def disband(chat_id)
61
+ post 'chat/v4/disband', {chat_id: chat_id}
6
62
  end
7
63
  end
8
64
  end
@@ -8,6 +8,101 @@ module Lark
8
8
  def department_add(payload={})
9
9
  post 'contact/v1/department/add', payload
10
10
  end
11
+
12
+ def department_batch_add(payload={})
13
+ post 'contact/v2/department/batch_add', payload
14
+ end
15
+
16
+ def department_delete(department_id)
17
+ post 'contact/v1/department/delete', {id: department_id}
18
+ end
19
+
20
+ def department_update(payload={})
21
+ post 'contact/v1/department/update', payload
22
+ end
23
+
24
+ def department_get(department_id)
25
+ get 'contact/v1/department/info/get', params: {department_id: department_id}
26
+ end
27
+
28
+ def department_children(department_id:, offset:, page_size:, fetch_child: false)
29
+ get 'contact/v1/department/simple/list', params: {
30
+ department_id: department_id,
31
+ offset: offset,
32
+ page_size: page_size,
33
+ fetch_child: fetch_child
34
+ }.compact
35
+ end
36
+
37
+ def department_children_ids(department_id)
38
+ get 'contact/v1/department/list', params: {department_id: department_id}
39
+ end
40
+
41
+ def department_batch_get(department_ids=[])
42
+ get 'contact/v1/department/detail/batch_get', params: {department_id: department_ids}
43
+ end
44
+
45
+ def department_user_list(department_id:, offset:, page_size:, fetch_child: false)
46
+ get 'contact/v1/department/user/list', params: {
47
+ department_id: department_id,
48
+ offset: offset,
49
+ page_size: page_size,
50
+ fetch_child: fetch_child
51
+ }.compact
52
+ end
53
+
54
+ def department_user_detail_list(department_id:, offset:, page_size:, fetch_child: false)
55
+ get 'contact/v1/department/user/detail/list', params: {
56
+ department_id: department_id,
57
+ offset: offset,
58
+ page_size: page_size,
59
+ fetch_child: fetch_child
60
+ }.compact
61
+ end
62
+
63
+ def user_add(payload={})
64
+ post 'contact/v1/user/add', payload
65
+ end
66
+
67
+ def user_batch_add(payload={})
68
+ post 'contact/v2/user/batch_add', payload
69
+ end
70
+
71
+ def user_delete(payload={})
72
+ post 'contact/v1/user/delete', payload
73
+ end
74
+
75
+ def user_update(payload={})
76
+ post 'contact/v1/user/update', payload
77
+ end
78
+
79
+ def user_batch_get(params=[])
80
+ get 'contact/v1/user/batch_get', params: params
81
+ end
82
+
83
+ def tenant_custom_attr_get
84
+ get 'contact/v1/tenant/custom_attr/get'
85
+ end
86
+
87
+ def task_get(task_id)
88
+ get 'contact/v2/task/get', params: {task_id: task_id}
89
+ end
90
+
91
+ def user_admin_scope_get(params)
92
+ get 'contact/v1/user/admin_scope/get', params: params
93
+ end
94
+
95
+ def role_list
96
+ get 'contact/v2/role/list'
97
+ end
98
+
99
+ def role_members(role_id:, page_token: nil, page_size: nil)
100
+ get 'contact/v2/role/members', params: {
101
+ role_id: role_id,
102
+ page_token: page_token,
103
+ page_size: page_size
104
+ }.compact
105
+ end
11
106
  end
12
107
  end
13
108
  end
@@ -0,0 +1,13 @@
1
+ module Lark
2
+ module Apis
3
+ module Image
4
+ def upload(image, image_type)
5
+ post_file 'image/v4/put/', file, params: { image_type: image_type }
6
+ end
7
+
8
+ def download(image_key)
9
+ get 'image/v4/get', params: { image_key: image_key }, as: :file
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,7 +1,11 @@
1
1
  module Lark
2
2
  module Apis
3
3
  module Message
4
- def send_message(payload)
4
+ def batch_send(payload)
5
+ post 'message/v4/batch_send/', payload
6
+ end
7
+
8
+ def direct_send(payload)
5
9
  post 'message/v4/send/', payload
6
10
  end
7
11
  end
@@ -0,0 +1,28 @@
1
+ module Lark
2
+ module Apis
3
+ module Pay
4
+ def paid_scope_check_user(open_id: nil, user_id: nil)
5
+ get 'pay/v1/paid_scope/check_user', params: {
6
+ open_id: open_id,
7
+ user_id: user_id
8
+ }.compact
9
+ end
10
+
11
+ def order_list(params={})
12
+ get 'pay/v1/order/list', {
13
+ via: 'app',
14
+ params: params
15
+ }
16
+ end
17
+
18
+ def order_get(order_id)
19
+ get 'pay/v1/order/get', {
20
+ via: 'app',
21
+ params: {
22
+ order_id: order_id
23
+ }
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ module Lark
2
+ module Apis
3
+ module User
4
+ def group_list(user_access_token:, page_size: nil, page_token: nil)
5
+ get 'user/v4/group_list', {
6
+ access_token: user_access_token,
7
+ params: {
8
+ page_size: page_size,
9
+ page_token: page_token
10
+ }
11
+ }.compact
12
+ end
13
+
14
+ def batch_get_id(emails: nil, mobiles: nil)
15
+ get 'user/v1/batch_get_id', params: {
16
+ emails: emails,
17
+ mobiles: mobiles
18
+ }.compact
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,9 +1,11 @@
1
1
  module Lark
2
- module Route
2
+ module Helper
3
3
  extend ActiveSupport::Concern
4
4
 
5
+ def
6
+
5
7
  module ClassMethods
6
- def mount(name)
8
+ def api_mount(name)
7
9
  class_eval <<-CODE, __FILE__, __LINE__ + 1
8
10
  def #{name}
9
11
  @#{name} ||= Class.new(SimpleDelegator) do
data/lib/lark/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lark
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
data/lib/lark.rb CHANGED
@@ -3,7 +3,7 @@ require 'redis'
3
3
  require 'active_support/all'
4
4
  require 'lark/config'
5
5
  require 'lark/cipher'
6
- require 'lark/route'
6
+ require 'lark/helper'
7
7
 
8
8
  LIB_PATH = "#{File.dirname(__FILE__)}/lark"
9
9
  Dir["#{LIB_PATH}/apis/*.rb", "#{LIB_PATH}/token_store/*.rb"].each { |path| require path }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lark-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Dong
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-17 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -113,15 +113,20 @@ files:
113
113
  - lark.gemspec
114
114
  - lib/lark.rb
115
115
  - lib/lark/api.rb
116
+ - lib/lark/apis/application.rb
116
117
  - lib/lark/apis/auth.rb
117
118
  - lib/lark/apis/authen.rb
119
+ - lib/lark/apis/bot.rb
118
120
  - lib/lark/apis/chat.rb
119
121
  - lib/lark/apis/contact.rb
122
+ - lib/lark/apis/image.rb
120
123
  - lib/lark/apis/message.rb
124
+ - lib/lark/apis/pay.rb
125
+ - lib/lark/apis/user.rb
121
126
  - lib/lark/cipher.rb
122
127
  - lib/lark/config.rb
128
+ - lib/lark/helper.rb
123
129
  - lib/lark/request.rb
124
- - lib/lark/route.rb
125
130
  - lib/lark/sdk.rb
126
131
  - lib/lark/token_store/app_token.rb
127
132
  - lib/lark/token_store/base.rb