Class: Aliyun::CloudSms::Request::MessageSend

Inherits:
Base
  • Object
show all
Defined in:
lib/aliyun/cloud_sms/request/message_send.rb

Constant Summary

Constants inherited from Base

Base::SERVICE_URL

Instance Attribute Summary collapse

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#get_params, #send_request

Constructor Details

#initialize(mobile, template_code, template_param, optional_params = nil) ⇒ MessageSend

Returns a new instance of MessageSend.



10
11
12
13
14
15
# File 'lib/aliyun/cloud_sms/request/message_send.rb', line 10

def initialize(mobile, template_code, template_param, optional_params = nil)
  self.mobile = mobile
  self.template_code = template_code
  self.template_param = template_param
  self.optional_params = optional_params || {}
end

Instance Attribute Details

#mobileObject

Returns the value of attribute mobile.



8
9
10
# File 'lib/aliyun/cloud_sms/request/message_send.rb', line 8

def mobile
  @mobile
end

#optional_paramsObject

Returns the value of attribute optional_params.



8
9
10
# File 'lib/aliyun/cloud_sms/request/message_send.rb', line 8

def optional_params
  @optional_params
end

#template_codeObject

Returns the value of attribute template_code.



8
9
10
# File 'lib/aliyun/cloud_sms/request/message_send.rb', line 8

def template_code
  @template_code
end

#template_paramObject

Returns the value of attribute template_param.



8
9
10
# File 'lib/aliyun/cloud_sms/request/message_send.rb', line 8

def template_param
  @template_param
end

Instance Method Details

#actionObject



17
18
19
# File 'lib/aliyun/cloud_sms/request/message_send.rb', line 17

def action
  "SendSms".freeze
end

#custom_paramsObject



21
22
23
24
25
26
27
28
29
# File 'lib/aliyun/cloud_sms/request/message_send.rb', line 21

def custom_params
  self.template_param = self.template_param.to_json if self.template_param.is_a?(Hash)

  {
    :PhoneNumbers => self.mobile,
    :TemplateCode => self.template_code,
    :TemplateParam => self.template_param.to_s,
  }.merge!(self.optional_params)
end