Commit d21d1c39 by lra

sms执行结果记录

parent 09cae40e
......@@ -30,7 +30,7 @@ class SmsSender
SOURCES = %w(taobao zucp)
attr_accessor :source, :source_config, :template_code, :attrs
attr_accessor :source, :source_config, :template_code, :attrs, :result
def initialize(opts = {})
self.attrs = HashWithIndifferentAccess.new(opts)
......@@ -40,6 +40,7 @@ class SmsSender
return unless attrs[:source]
send("#{attrs[:source].to_s}_init")
attrs[:sender] = self
@source = "Sms/#{attrs[:source]}".camelize.constantize.new(attrs)
end
......@@ -151,6 +152,14 @@ class SmsSender
@source.dingtalk_call_set_user_list(opts)
end
# Example:
# sms_sender = SmsSender.new
# sms_sender.info('xxxx')
def info(msg)
self.class.info msg
end
# Example:
# SmsSender.info('xxxx')
def self.info(msg)
......
......@@ -5,12 +5,12 @@ require 'net/http'
module Sms
class Taobao
attr_accessor :app_secret, :app_key,
:sms_free_sign_name, :called_show_verify_nums, :called_show_notify_nums,
:template_code, :param,
:custom_params, :request_params
attr_accessor :app_secret, :app_key
attr_accessor :sms_free_sign_name, :called_show_verify_nums, :called_show_notify_nums
attr_accessor :template_code, :param
attr_accessor :custom_params, :request_params
attr_accessor :staff_id, :session, :authed_corp_id, :authed_staff_id, :staff_id_list
attr_accessor :sender
def initialize(options = {})
options.each{|k, v|
......@@ -99,13 +99,13 @@ module Sms
def post
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 = JSON.parse(data) if data.is_a? String
SmsSender.info "#{request_params[:method]} request result: #{data.inspect}"
result = HashWithIndifferentAccess.new data
sender.info "#{request_params[:method]} request result: #{data.inspect}"
sender.result = result = HashWithIndifferentAccess.new data
keys = result.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