Class: AlidayuSmsSender

Inherits:
Object
  • Object
show all
Defined in:
lib/alidayu_sms.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AlidayuSmsSender

Returns a new instance of AlidayuSmsSender.



22
23
24
25
26
27
28
29
30
# File 'lib/alidayu_sms.rb', line 22

def initialize(options = {})
  if load_config.present? && load_config[:alidayu].present?
    options = load_config[:alidayu].merge(options)
  end
  options = HashWithIndifferentAccess.new(options)
  check_system_params(options)

  @source = AlidayuSms::Alidayu.new(options)
end

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



20
21
22
# File 'lib/alidayu_sms.rb', line 20

def source
  @source
end

#template_codeObject

Returns the value of attribute template_code.



20
21
22
# File 'lib/alidayu_sms.rb', line 20

def template_code
  @template_code
end

Instance Method Details

#batchSendSms(options = {}) ⇒ Object

发送短信



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/alidayu_sms.rb', line 33

def batchSendSms(options = {})
  options = HashWithIndifferentAccess.new(options)

  arr = %w(code product phones extend sms_free_sign_name sms_template_code)
  attr, flag = [], false
  arr.each do |a|
    flag = true unless options[a]
    attr << options[a]
  end

  check_params(flag, options)
  puts "传入参数为:#{attr}"

  @source.standard_send_msg(attr)
end