Module: AliyunDysms
- Defined in:
- lib/aliyun_dysms.rb,
lib/aliyun_dysms/version.rb
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- VERSION =
"0.1.1"
Class Attribute Summary collapse
Class Method Summary collapse
- .client ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .direct_send(phone_numbers, template_code, template_param, out_id = "") ⇒ Object
- .global_send(phone_numbers, country_code, template_code, template_param, out_id = "") ⇒ Object
-
.send ⇒ Object
TODO: 自动解析手机号判断国内国外短信.
Class Attribute Details
.configuration ⇒ Object
22 23 24 |
# File 'lib/aliyun_dysms.rb', line 22 def configuration @configuration ||= Configuration.new end |
Class Method Details
.client ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/aliyun_dysms.rb', line 68 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 |
.configure {|configuration| ... } ⇒ Object
26 27 28 |
# File 'lib/aliyun_dysms.rb', line 26 def configure yield(configuration) end |
.direct_send(phone_numbers, template_code, template_param, out_id = "") ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/aliyun_dysms.rb', line 33 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.}>" } end |
.global_send(phone_numbers, country_code, template_code, template_param, out_id = "") ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/aliyun_dysms.rb', line 50 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.}>" } end |
.send ⇒ Object
TODO: 自动解析手机号判断国内国外短信
31 |
# File 'lib/aliyun_dysms.rb', line 31 def send; end |