Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dingtalk-sdk
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
dingtalk-sdk
Commits
457a1329
Commit
457a1329
authored
Sep 02, 2020
by
Francis Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加工作通知消息发送接口
parent
1cb52522
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
140 additions
and
6 deletions
+140
-6
dingtalk.rb
lib/dingtalk.rb
+6
-0
auth.rb
lib/dingtalk/auth.rb
+1
-1
core.rb
lib/dingtalk/core.rb
+15
-5
corp_conversation.rb
lib/dingtalk/corp_conversation.rb
+48
-0
department.rb
lib/dingtalk/department.rb
+24
-0
request_url.rb
lib/dingtalk/request_url.rb
+29
-0
storage.rb
lib/dingtalk/storage.rb
+17
-0
No files found.
lib/dingtalk.rb
View file @
457a1329
...
@@ -4,7 +4,10 @@ require 'openssl'
...
@@ -4,7 +4,10 @@ require 'openssl'
require
"dingtalk/version"
require
"dingtalk/version"
require
"dingtalk/auth"
require
"dingtalk/auth"
require
"dingtalk/user"
require
"dingtalk/department"
require
"dingtalk/access_token"
require
"dingtalk/access_token"
require
"dingtalk/corp_conversation"
module
Dingtalk
module
Dingtalk
class
Error
<
StandardError
class
Error
<
StandardError
...
@@ -26,7 +29,10 @@ module Dingtalk
...
@@ -26,7 +29,10 @@ module Dingtalk
class
Request
class
Request
include
Auth
include
Auth
include
User
include
Department
include
AccessToken
include
AccessToken
include
CorpConversation
attr_reader
:app_key
,
:app_secret
attr_reader
:app_key
,
:app_secret
...
...
lib/dingtalk/auth.rb
View file @
457a1329
...
@@ -30,7 +30,7 @@ module Dingtalk
...
@@ -30,7 +30,7 @@ module Dingtalk
# 钉钉内免登录第三方网站 个人信息获取
# 钉钉内免登录第三方网站 个人信息获取
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/etaarr
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/etaarr
add_request
:get_3rd_login_free_user_profile
,
:post
,
Dingtalk
::
RequestUrl
::
GET_USER_INFO_SNS
do
|
request
|
add_request
:get_3rd_login_free_user_profile
,
:post
,
Dingtalk
::
RequestUrl
::
GET_USER_INFO_SNS
do
|
request
|
request
.
is_json
=
true
request
.
format
=
:json
request
.
add_arg
:accessKey
,
required:
true
,
in: :query
request
.
add_arg
:accessKey
,
required:
true
,
in: :query
request
.
add_arg
:timestamp
,
required:
true
,
in: :query
request
.
add_arg
:timestamp
,
required:
true
,
in: :query
...
...
lib/dingtalk/core.rb
View file @
457a1329
...
@@ -11,7 +11,7 @@ module Dingtalk
...
@@ -11,7 +11,7 @@ module Dingtalk
attr_reader
:query_args
,
:body_args
,
:query_const
,
:body_const
,
:required_args
attr_reader
:query_args
,
:body_args
,
:query_const
,
:body_const
,
:required_args
def
initialize
def
initialize
@
is_json
=
false
@
format
=
nil
@body_args
=
[]
@body_args
=
[]
@query_args
=
[]
@query_args
=
[]
...
@@ -22,7 +22,15 @@ module Dingtalk
...
@@ -22,7 +22,15 @@ module Dingtalk
end
end
def
is_json?
def
is_json?
@is_json
@format
==
:json
end
def
is_x_form?
@format
==
:x_form
end
def
is_form_data?
@format
==
:form_data
end
end
def
is_arg_required?
(
arg_name
)
def
is_arg_required?
(
arg_name
)
...
@@ -45,8 +53,8 @@ module Dingtalk
...
@@ -45,8 +53,8 @@ module Dingtalk
!
@query_const
.
empty?
!
@query_const
.
empty?
end
end
def
is_json
=
(
b
)
def
format
=
(
format
)
@
is_json
=
b
@
format
=
format
end
end
def
add_arg
(
arg_name
,
option
)
def
add_arg
(
arg_name
,
option
)
...
@@ -105,7 +113,9 @@ module Dingtalk
...
@@ -105,7 +113,9 @@ module Dingtalk
end
end
end
end
if
builder
.
is_json?
if
builder
.
is_form_data?
h
[
:multipart
]
=
true
elsif
builder
.
is_json?
h
[
:body
]
=
h
[
:body
].
to_json
if
Hash
===
h
[
:body
]
h
[
:body
]
=
h
[
:body
].
to_json
if
Hash
===
h
[
:body
]
h
[
:headers
]
=
{
:"Content-Type"
=>
"application/json"
}
h
[
:headers
]
=
{
:"Content-Type"
=>
"application/json"
}
end
end
...
...
lib/dingtalk/corp_conversation.rb
0 → 100644
View file @
457a1329
require
'dingtalk/core'
require
'dingtalk/request_url'
module
Dingtalk
module
CorpConversation
extend
Dingtalk
::
Core
# 发送工作通知消息
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/pgoxpy
add_request
:send_corp_conversation
,
:post
,
SEND_CORP_CONVERSATION
do
|
request
|
request
.
add_arg
:agent_id
,
in: :body
,
required:
true
request
.
add_arg
:userid_list
,
in: :body
request
.
add_arg
:dept_id_list
,
in: :body
request
.
add_arg
:to_all_user
,
in: :body
request
.
add_arg
:msg
,
in: :body
request
.
add_arg
:access_token
,
in: :query
,
required:
true
end
# 查询工作通知消息的发送进度
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/pgoxpy/e2262dad
add_request
:get_corp_conversation_progress
,
:post
,
CORP_CONVERSATION_SEND_PROGRESS
do
|
request
|
request
.
add_arg
:agent_id
,
in: :body
,
required:
true
request
.
add_arg
:task_id
,
in: :body
,
required:
true
request
.
add_arg
:access_token
,
in: :query
,
required:
true
end
# 查询工作通知消息的发送结果
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/pgoxpy/a5920210
add_request
:get_corp_conversation_result
,
:post
,
CORP_CONVERSATION_SEND_RESULT
do
|
request
|
request
.
add_arg
:agent_id
,
in: :body
,
required:
true
request
.
add_arg
:task_id
,
in: :body
,
required:
true
request
.
add_arg
:access_token
,
in: :query
,
required:
true
end
# 工作通知消息撤回
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/pgoxpy/hYyV8
add_request
:recall_corp_conversation
,
:post
,
RECALL_CORP_CONVERSATION
do
|
request
|
request
.
add_arg
:agent_id
,
in: :body
,
required:
true
request
.
add_arg
:msg_task_id
,
in: :body
,
required:
true
request
.
add_arg
:access_token
,
in: :query
,
required:
true
end
end
end
\ No newline at end of file
lib/dingtalk/department.rb
0 → 100644
View file @
457a1329
require
"dingtalk/core"
require
"dingtalk/request_url"
module
Dingtalk
module
Department
extend
Dingtalk
::
Core
# 获取部门列表
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/dubakq/e6e1604e
add_request
:get_department_list
,
:get
,
RequestUrl
::
GET_DEPARTMENT_LIST
do
|
request
|
request
.
add_arg
:id
,
in: :query
# 父部门id(如果不传,默认部门为根部门,根部门ID为1)
request
.
add_arg
:fetch_child
,
in: :query
# 是否递归部门的全部子部门
request
.
add_arg
:access_token
,
required:
true
,
in: :query
end
# 获取部门详情
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/dubakq/5bf960de
add_request
:get_department_profile
,
:get
,
RequestUrl
::
GET_DEPARTMENT_PROFILE
do
|
request
|
request
.
add_arg
:id
,
in: :query
,
required:
true
request
.
add_arg
:access_token
,
in: :query
,
required:
true
end
end
end
\ No newline at end of file
lib/dingtalk/request_url.rb
View file @
457a1329
...
@@ -28,5 +28,33 @@ module Dingtalk
...
@@ -28,5 +28,33 @@ module Dingtalk
# 根据手机号获取 userId
# 根据手机号获取 userId
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/ege851/soV11
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/ege851/soV11
GET_USERID_FROM_MOBILE
=
"https://oapi.dingtalk.com/user/get_by_mobile"
GET_USERID_FROM_MOBILE
=
"https://oapi.dingtalk.com/user/get_by_mobile"
# 获取部门列表
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/dubakq/e6e1604e
GET_DEPARTMENT_LIST
=
"https://oapi.dingtalk.com/department/list"
# 获取部门详情
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/dubakq/5bf960de
GET_DEPARTMENT_PROFILE
=
"https://oapi.dingtalk.com/department/get"
# 发送工作通知消息
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/pgoxpy
SEND_CORP_CONVERSATION
=
"https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2"
# 查询工作通知消息的发送进度
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/pgoxpy/e2262dad
CORP_CONVERSATION_SEND_PROGRESS
=
"https://oapi.dingtalk.com/topapi/message/corpconversation/getsendprogress"
# 查询工作通知消息的发送结果
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/pgoxpy/a5920210
CORP_CONVERSATION_SEND_RESULT
=
"https://oapi.dingtalk.com/topapi/message/corpconversation/getsendresult"
# 工作通知消息撤回
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/pgoxpy/hYyV8
RECALL_CORP_CONVERSATION
=
"https://oapi.dingtalk.com/topapi/message/corpconversation/recall"
# 上传媒体文件
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/bcmg0i/08d5a73b
UPLOAD_MEDIA_FILE
=
"https://oapi.dingtalk.com/media/upload"
end
end
end
end
\ No newline at end of file
lib/dingtalk/storage.rb
0 → 100644
View file @
457a1329
require
'dingtalk/core'
require
'dingtalk/request_url'
module
Dingtalk
module
Storage
extend
Dingtalk
::
Core
# 上传媒体文件
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/bcmg0i/08d5a73b
add_request
:upload_media
,
:post
,
Dingtalk
::
RequestUrl
::
UPLOAD_MEDIA_FILE
do
|
request
|
request
.
add_arg
:type
,
in:
query
,
required:
true
request
.
add_arg
:access_token
,
in: :query
,
required:
true
request
.
add_arg
:media
,
in: :body
,
required:
true
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment