Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sms
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gems
sms
Commits
d21d1c39
Commit
d21d1c39
authored
Apr 10, 2017
by
lra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sms执行结果记录
parent
09cae40e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
lib/sms.rb
+10
-1
lib/sms/taobao.rb
+8
-8
No files found.
lib/sms.rb
View file @
d21d1c39
...
@@ -30,7 +30,7 @@ class SmsSender
...
@@ -30,7 +30,7 @@ class SmsSender
SOURCES
=
%w(taobao zucp)
SOURCES
=
%w(taobao zucp)
attr_accessor
:source
,
:source_config
,
:template_code
,
:attrs
attr_accessor
:source
,
:source_config
,
:template_code
,
:attrs
,
:result
def
initialize
(
opts
=
{})
def
initialize
(
opts
=
{})
self
.
attrs
=
HashWithIndifferentAccess
.
new
(
opts
)
self
.
attrs
=
HashWithIndifferentAccess
.
new
(
opts
)
...
@@ -40,6 +40,7 @@ class SmsSender
...
@@ -40,6 +40,7 @@ class SmsSender
return
unless
attrs
[
:source
]
return
unless
attrs
[
:source
]
send
(
"
#{
attrs
[
:source
].
to_s
}
_init"
)
send
(
"
#{
attrs
[
:source
].
to_s
}
_init"
)
attrs
[
:sender
]
=
self
@source
=
"Sms/
#{
attrs
[
:source
]
}
"
.
camelize
.
constantize
.
new
(
attrs
)
@source
=
"Sms/
#{
attrs
[
:source
]
}
"
.
camelize
.
constantize
.
new
(
attrs
)
end
end
...
@@ -151,6 +152,14 @@ class SmsSender
...
@@ -151,6 +152,14 @@ class SmsSender
@source
.
dingtalk_call_set_user_list
(
opts
)
@source
.
dingtalk_call_set_user_list
(
opts
)
end
end
# Example:
# sms_sender = SmsSender.new
# sms_sender.info('xxxx')
def
info
(
msg
)
self
.
class
.
info
msg
end
# Example:
# Example:
# SmsSender.info('xxxx')
# SmsSender.info('xxxx')
def
self
.
info
(
msg
)
def
self
.
info
(
msg
)
...
...
lib/sms/taobao.rb
View file @
d21d1c39
...
@@ -5,12 +5,12 @@ require 'net/http'
...
@@ -5,12 +5,12 @@ require 'net/http'
module
Sms
module
Sms
class
Taobao
class
Taobao
attr_accessor
:app_secret
,
:app_key
,
attr_accessor
:app_secret
,
:app_key
:sms_free_sign_name
,
:called_show_verify_nums
,
:called_show_notify_nums
,
attr_accessor
:sms_free_sign_name
,
:called_show_verify_nums
,
:called_show_notify_nums
:template_code
,
:param
,
attr_accessor
:template_code
,
:param
:custom_params
,
:request_params
attr_accessor
:custom_params
,
:request_params
attr_accessor
:staff_id
,
:session
,
:authed_corp_id
,
:authed_staff_id
,
:staff_id_list
attr_accessor
:staff_id
,
:session
,
:authed_corp_id
,
:authed_staff_id
,
:staff_id_list
attr_accessor
:sender
def
initialize
(
options
=
{})
def
initialize
(
options
=
{})
options
.
each
{
|
k
,
v
|
options
.
each
{
|
k
,
v
|
...
@@ -99,13 +99,13 @@ module Sms
...
@@ -99,13 +99,13 @@ module Sms
def
post
def
post
res
=
Net
::
HTTP
.
post_form
(
URI
.
parse
(
'https://eco.taobao.com/router/rest'
),
extend_params
)
res
=
Net
::
HTTP
.
post_form
(
URI
.
parse
(
'https://eco.taobao.com/router/rest'
),
extend_params
)
SmsS
ender
.
info
"
#{
request_params
[
:method
]
}
request params:
#{
request_params
.
inspect
}
"
s
ender
.
info
"
#{
request_params
[
:method
]
}
request params:
#{
request_params
.
inspect
}
"
data
=
res
.
body
data
=
res
.
body
data
=
JSON
.
parse
(
data
)
if
data
.
is_a?
String
data
=
JSON
.
parse
(
data
)
if
data
.
is_a?
String
SmsS
ender
.
info
"
#{
request_params
[
:method
]
}
request result:
#{
data
.
inspect
}
"
s
ender
.
info
"
#{
request_params
[
:method
]
}
request result:
#{
data
.
inspect
}
"
result
=
HashWithIndifferentAccess
.
new
data
sender
.
result
=
result
=
HashWithIndifferentAccess
.
new
data
keys
=
result
.
keys
keys
=
result
.
keys
return
if
'error_response'
.
in?
(
keys
)
return
if
'error_response'
.
in?
(
keys
)
...
...
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