alidayu_sms 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c00fc6ced4e245d6f7fe70e8206b34f4679133e8
4
- data.tar.gz: c3d7825e83e0abec0e9721b091ec10be319b79d1
3
+ metadata.gz: 337b38f10989c709232c0a4aa7a1d7d3f7ae7035
4
+ data.tar.gz: 00a1e91270ac061c62f1f4665c88fadd5413136b
5
5
  SHA512:
6
- metadata.gz: 5afcecfa24c2edcf2cd8adca78f4982cf4217d2e1b4d72a819db29859d80316d61b2807db57f59e907ff1edd5b01a9a8e20cd078b360961a36441b353ed94441
7
- data.tar.gz: 719a2a22d1d4cbff0a434676c26f597a759fd21c8dd16e61a64716165874b7dcaa950ab37ca69a4a7d74448f3b42edd9c04048fe075a788456c1928e1858aee5
6
+ metadata.gz: abd7a804672a728b5bb49ee804332485f78d4ab5ab19c3d8c4988440a52340e7f8401cf91445b8581ef9060012e07fe4f3462d7a388b966ed8f0345b831cd3b6
7
+ data.tar.gz: 0f277a2c6fded83a7c59c2d8c427c3abdebae216561181c416a7127d347a954b50e4a6905fb1ed2a9b060da92de40a812b518a9412c5632b8644b747d7898ac4
data/README.md CHANGED
@@ -28,13 +28,11 @@ test:
28
28
  production:
29
29
  <<: *defaults
30
30
  ```
31
-
32
- ## hello world!
31
+ # v0.3.0 支持自定义模板了 && hello world!
33
32
  ```ruby
34
33
  options = {
35
- code: 1314520, # 模板的{code}字段
36
- phones: "1520122011,1591251515", # 手机号码
37
- product: "阿里云", # 模板的{product}字段
34
+ sms_param: "'code': '1314520', ,'product':'阿里云'",
35
+ phones: '1520122011,1591251515',
38
36
  extend: '', # 公共回传参数,在“消息返回”中会透传回该参数;举例:用户可以传入自己下级的会员ID,在消息返回时,该会员ID会包含在内,用户可以根据该会员ID识别是哪位会员使用了你的应用
39
37
  sms_free_sign_name: "注册验证", # 短信签名
40
38
  sms_template_code: "SMS_5045503" # 短信模板
@@ -43,9 +41,15 @@ result = AlidayuSmsSender.new.batchSendSms(options)
43
41
 
44
42
  # 返回码参考 阿里大鱼 api文档
45
43
  ```
44
+ # v0.3.0最新用法
45
+ ## 配置文件里的product即为 sms_param = sms_param[:product] = "阿里云", 则可不传这个字段
46
+ ```ruby
47
+ # Alidayu::Sms.send_code_for_{name}( phone, sms_param={code: '1314520', product: '可选'}, extend="") {name}为配置文件sms_templates[:name]
48
+ Alidayu::Sms.send_code_for_sign_up("15921076830", {code: '1314520'}, '')
49
+ ```
46
50
 
47
- # v0.2.0最新用法
48
- ## 配置文件里的product即为 options里的 product: "阿里云", # 模板的{product}字段,配置好之后可以用
51
+ # v0.2.0用法
52
+ ## 配置文件里的product即为 options里的 product: "阿里云", 模板的{product}字段,配置好之后可以用如下方法
49
53
  ```ruby
50
54
  # Alidayu::Sms.send_code_for_{name}(code, phone, extend="") {name}为配置文件sms_templates[:name]
51
55
  Alidayu::Sms.send_code_for_sign_up(1314520, "1520122011")
data/lib/alidayu_sms.rb CHANGED
@@ -28,11 +28,12 @@ class AlidayuSmsSender
28
28
  @source = AlidayuSms::Alidayu.new(options)
29
29
  class_eval do
30
30
  load_config[:alidayu][:sms_templates].each do |sms_template|
31
- define_method("send_code_for_#{sms_template[:name]}") do |code, phone, extend = ""|
31
+ define_method("send_code_for_#{sms_template[:name]}") do |phone, _sms_param = {}, extend = ""|
32
+ _sms_param[:product] ||= load_config[:alidayu][:product]
33
+
32
34
  options = {
33
- code: code, # 模板的{code}字段
35
+ sms_param: _sms_param.to_json,
34
36
  phones: phone, # 手机号码
35
- product: load_config[:alidayu][:product], # 模板的{product}字段
36
37
  extend: extend, # 公共回传参数,在“消息返回”中会透传回该参数;举例:用户可以传入自己下级的会员ID,在消息返回时,该会员ID会包含在内,用户可以根据该会员ID识别是哪位会员使用了你的应用
37
38
  sms_free_sign_name: sms_template[:sms_free_sign_name], # 短信签名
38
39
  sms_template_code: sms_template[:sms_template_code] # 短信模板
@@ -46,8 +47,7 @@ class AlidayuSmsSender
46
47
  # 发送短信
47
48
  def batchSendSms(options = {})
48
49
  options = HashWithIndifferentAccess.new(options)
49
-
50
- arr = %w(code product phones extend sms_free_sign_name sms_template_code)
50
+ arr = %w(sms_param phones extend sms_free_sign_name sms_template_code)
51
51
  attr, flag = [], false
52
52
  arr.each do |a|
53
53
  flag = true unless options[a]
@@ -3,17 +3,18 @@ require 'net/http'
3
3
  module AlidayuSms
4
4
  class Alidayu
5
5
  attr_accessor :app_key, :app_secret, :post_url
6
-
6
+
7
7
  def initialize(options = {})
8
8
  self.app_key = options['app_key']
9
9
  self.app_secret = options['app_secret']
10
10
  self.post_url = options['post_url']
11
11
  end
12
-
12
+
13
13
  def standard_send_msg(arg = [])
14
- code, product, _phones, _extend, _sms_free_sign_name, _sms_template_code = arg
14
+ _sms_param, _phones, _extend, _sms_free_sign_name, _sms_template_code = arg
15
15
 
16
- _sms_param = "{'code':'#{code}','product':'#{product}'}"
16
+ # 改成支持自定义参数
17
+ #_sms_param = "{'code':'#{code}','product':'#{product}'}"
17
18
  _timestamp = Time.now.strftime("%F %T")
18
19
  options = {
19
20
  app_key: self.app_key,
@@ -66,5 +67,3 @@ module AlidayuSms
66
67
  end
67
68
  end
68
69
  end
69
-
70
-
@@ -1,3 +1,3 @@
1
1
  module AlidayuSms
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -6,5 +6,6 @@ namespace :alidayu_sms do
6
6
  unless File.exist?("#{::Rails.root}/config/initializers/alidayu.rb")
7
7
  FileUtils.cp(File.expand_path("../../templates/alidayu.rb", __FILE__), "#{::Rails.root}/config/initializers/alidayu.rb")
8
8
  end
9
+ puts 'ce'
9
10
  end
10
11
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alidayu_sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jack ping
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -118,6 +118,7 @@ files:
118
118
  - lib/templates/alidayu_sms.yml
119
119
  - lib/templates/sms.yml~
120
120
  - pkg/alidayu_sms-0.1.0.gem
121
+ - pkg/alidayu_sms-0.2.0.gem
121
122
  - sms.gemspec~
122
123
  homepage: https://github.com/wangping0105/alidayu_sms
123
124
  licenses: []