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
fe3ee552
Commit
fe3ee552
authored
Sep 03, 2020
by
Francis Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
raise error when errcode in response is not equal 0
parent
1e31ec26
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
dingtalk.rb
lib/dingtalk.rb
+8
-1
core.rb
lib/dingtalk/core.rb
+9
-1
auth_spec.rb
spec/dingtalk/auth_spec.rb
+2
-0
No files found.
lib/dingtalk.rb
View file @
fe3ee552
...
...
@@ -10,7 +10,14 @@ require "dingtalk/access_token"
require
"dingtalk/corp_conversation"
module
Dingtalk
class
Error
<
StandardError
class
Error
<
StandardError
;
end
class
RequestFailedError
<
Error
attr_reader
:code
,
:message
def
initialize
(
code
:,
message
:)
@code
,
@message
,
=
code
,
message
end
end
class
Signature
...
...
lib/dingtalk/core.rb
View file @
fe3ee552
...
...
@@ -122,8 +122,16 @@ module Dingtalk
end
response
=
HTTParty
.
send
(
method
,
url
,
**
request_options
)
symbolized_response
=
JSON
.
parse
(
response
.
body
).
deep_symbolize_keys
JSON
.
parse
(
response
.
body
).
deep_symbolize_keys
if
symbolized_response
[
:errcode
]
!=
0
raise
Dingtalk
::
RequestFailedError
.
new
(
code:
symbolized_response
[
:errcode
],
message:
symbolized_response
[
:errmsg
],
)
end
symbolized_response
end
end
end
...
...
spec/dingtalk/auth_spec.rb
View file @
fe3ee552
...
...
@@ -27,6 +27,8 @@ RSpec.describe Dingtalk::Auth do
# 企业内部免登 响应结果
get_user_info_response_body
=
{}.
tap
do
|
h
|
h
[
:errcode
]
=
0
h
[
:errmsg
]
=
"ok"
h
[
:userid
]
=
@int_user_id
h
[
:is_sys
]
=
false
h
[
:sys_level
]
=
0
...
...
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