module Dingxin::Vms
Constants
- VERSION
Attributes
configuration[W]
Public Class Methods
canonicalized_query_string(params)
click to toggle source
规范化参数
# File lib/dingxin/vms.rb, line 50 def canonicalized_query_string(params) cqstring = '' params.sort_by{|key, val| key}.each do |key, value| if cqstring.empty? cqstring += "#{encode(key)}=#{encode(value)}" else cqstring += "&#{encode(key)}=#{encode(value)}" end end cqstring end
configuration()
click to toggle source
# File lib/dingxin/vms.rb, line 21 def configuration @configuration ||= Configuration.new end
configure() { |configuration| ... }
click to toggle source
# File lib/dingxin/vms.rb, line 25 def configure yield(configuration) end
encode(input)
click to toggle source
对字符串进行 PERCENT 编码 apidock.com/ruby/ERB/Util/url_encode
# File lib/dingxin/vms.rb, line 45 def encode(input) output = url_encode(input) end
get_url(params)
click to toggle source
# File lib/dingxin/vms.rb, line 38 def get_url(params) coded_params = canonicalized_query_string(params) url = 'http://yuyin2.market.alicloudapi.com/dx/voice_notice?' + coded_params end
send(phone, tpl_id, param)
click to toggle source
# File lib/dingxin/vms.rb, line 29 def send(phone, tpl_id, param) Typhoeus.post(get_url({ 'phone' => phone, 'tpl_id' => tpl_id, 'param' => param }), headers: { "Authorization" => "APPCODE #{configuration.app_code}" }) end