Class: AlidayuSms::Alidayu

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Alidayu

Returns a new instance of Alidayu.



7
8
9
10
11
# File 'lib/alidayu_sms/alidayu.rb', line 7

def initialize(options = {})
  self.app_key = options['app_key']
  self.app_secret = options['app_secret']
  self.post_url = options['post_url']
end

Instance Attribute Details

#app_keyObject

Returns the value of attribute app_key.



5
6
7
# File 'lib/alidayu_sms/alidayu.rb', line 5

def app_key
  @app_key
end

#app_secretObject

Returns the value of attribute app_secret.



5
6
7
# File 'lib/alidayu_sms/alidayu.rb', line 5

def app_secret
  @app_secret
end

#post_urlObject

Returns the value of attribute post_url.



5
6
7
# File 'lib/alidayu_sms/alidayu.rb', line 5

def post_url
  @post_url
end

Instance Method Details

#standard_send_msg(arg = []) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/alidayu_sms/alidayu.rb', line 13

def standard_send_msg(arg = [])
  code, product, _phones, _extend, _sms_free_sign_name, _sms_template_code = arg

  _sms_param = "{'code':'#{code}','product':'#{product}'}"
  _timestamp = Time.now.strftime("%F %T")
  options = {
    app_key: self.app_key,
    format: 'json',
    method: 'alibaba.aliqin.fc.sms.num.send',
    partner_id: 'apidoc',
    sign_method: 'md5',
    timestamp: _timestamp,
    v: '2.0',
    extend: _extend,
    rec_num: _phones,
    sms_free_sign_name: _sms_free_sign_name,
    sms_param: _sms_param,
    sms_template_code: _sms_template_code,
    sms_type: 'normal'
  }

  options = sort_options(options)
  puts "options: #{options}"

  md5_str =