Commit d21d1c39 by lra

sms执行结果记录

parent 09cae40e
...@@ -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)
......
...@@ -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)
SmsSender.info "#{request_params[:method]} request params: #{request_params.inspect}" sender.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
SmsSender.info "#{request_params[:method]} request result: #{data.inspect}" sender.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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment