module AliyunDysms
Constants
- VERSION
Attributes
configuration[W]
Public Class Methods
client()
click to toggle source
# File lib/aliyun_dysms.rb, line 73 def client @client ||= RPCClient.new( access_key_id: configuration.access_key_id, access_key_secret: configuration.access_key_secret, api_version: configuration.api_version, endpoint: "https://dysmsapi.aliyuncs.com", ) end
configuration()
click to toggle source
# File lib/aliyun_dysms.rb, line 27 def configuration @configuration ||= Configuration.new end
configure() { |configuration| ... }
click to toggle source
# File lib/aliyun_dysms.rb, line 31 def configure yield(configuration) end
direct_send(phone_numbers, template_code, template_param, out_id = "")
click to toggle source
# File lib/aliyun_dysms.rb, line 38 def direct_send(phone_numbers, template_code, template_param, out_id = "") @response = client.request( action: "SendSms", params: { "RegionId": configuration.region_id, "SignName": configuration.sign_name, "PhoneNumbers": phone_numbers, "TemplateCode": template_code, "TemplateParam": template_param, "OutId": out_id, }, opts: { method: "POST" }, ) rescue StandardError => e { Code: "BadRequest", Message: "Request failed: #<#{e.class}: #{e.message}>" } end
global_send(phone_numbers, country_code, template_code, template_param, out_id = "")
click to toggle source
# File lib/aliyun_dysms.rb, line 55 def global_send(phone_numbers, country_code, template_code, template_param, out_id = "") @response = client.request( action: "SendInterSms", params: { "RegionId": configuration.region_id, "SignName": configuration.sign_name, "PhoneNumbers": phone_numbers, "countryCode": country_code, "TemplateCode": template_code, "TemplateParam": template_param, "OutId": out_id, }, opts: { method: "POST" }, ) rescue StandardError => e { Code: "BadRequest", Message: "Request failed: #<#{e.class}: #{e.message}>" } end
send()
click to toggle source
TODO: 自动解析手机号判断国内国外短信
# File lib/aliyun_dysms.rb, line 36 def send; end