module Aliyun::Dysms

Constants

VERSION

Attributes

configuration[W]
response[R]

Public Class Methods

client() click to toggle source
# File lib/aliyun/dysms.rb, line 52
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 25
def configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source
# File lib/aliyun/dysms.rb, line 29
def configure
  yield(configuration)
end
send(phone_numbers, template_code, template_param, out_id = "") click to toggle source
# File lib/aliyun/dysms.rb, line 33
def send(phone_numbers, template_code, template_param, out_id = "")
  @response = client.request(
    action: configuration.action,
    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