aliyun_sms_ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04b9443bcc94bde6a6a76a53b3514396f5534dbfa7d8d6b4a1fd92d63979d922
4
- data.tar.gz: 31e66adb1673f8408487bc9abda71c289aae370a017b1d917e0323cc8df69f36
3
+ metadata.gz: 7fd197eeee2199a24d181857c325458664f00da977c3613064eb6804384a6543
4
+ data.tar.gz: f15bea60e663b7c6410f8d8423d11ae5c4ca4f80ac6aa24e3931821b0464c3a7
5
5
  SHA512:
6
- metadata.gz: dc0ec467f5bd494f7b721d2e84be02642576334282fa5e379746f74c050d836f2af5ac937f22c2fb870d200408865ea8132ae303da042fb26fe723f102fea4c6
7
- data.tar.gz: b6c0db9d718bb6f52bf71f3b6492e728219994ae6803a1b486d418085f10010689078b75da6e477da5ded671ed0979dda6ac93657e43a9d94228393830f515fb
6
+ metadata.gz: f0f26a9128ac5db19534fabd4abd5ad91b0a842ee826964aa2cc2912dea010e32ed395132a59361c3aafced6c3ee05d900bb0dc09c7238ac5c6c76767f961d1d
7
+ data.tar.gz: a7cb468c7dde07529de0579272ee1cc8dec9a54a7069e9c9ff257eb0cdbbc2c50d973a818289d2a281991ba5dd268bfe6e1209ccb1c434f8606b171f1d745b4c
data/README.md CHANGED
@@ -0,0 +1,64 @@
1
+ # AliyunSmsRuby
2
+ This gem use for Aliyun message send and status query.
3
+
4
+ Add 10DLC support
5
+
6
+ ## Installation
7
+
8
+ ```ruby
9
+ gem 'aliyun_sms_ruby'
10
+ ```
11
+
12
+ ## Config
13
+ Add aliyun_sms_ruby.rb to config/initializers.
14
+
15
+ ```ruby
16
+ AliyunSmsRuby.configure do |config|
17
+ config.access_key_secret = ENV['ALIYUN_SMS_ACCESS_KEY_SECRET']
18
+ config.access_key_id = ENV['ALIYUN_SMS_ACCESS_KEY_ID']
19
+ config.sign_name = ENV['ALIYUN_SMS_SIGN_NAME']
20
+ end
21
+ ```
22
+
23
+ ## Use
24
+
25
+ ### Message send
26
+ Aliyun doc: https://next.api.aliyun.com/document/Dysmsapi/2017-05-25/SendSms
27
+
28
+ ``` ruby
29
+ phone_number = '151********'
30
+ template_code = 'SMS_182823232'
31
+ template_param = { code: "10001" }
32
+ AliyunSmsRuby.send_message(phone_number, template_code, template_param)
33
+ ```
34
+
35
+ ### Global message send(can not query message send status)
36
+ **Important: After register the 10 DLC number, you need ask the Aliyun support team add your account to their white list. Or you will receive a forbidden error.**
37
+
38
+ ```
39
+ {
40
+ "Code": "Forbidden.Operation",
41
+ "Message":"You are not authorized to perform the operation."
42
+ }
43
+ ```
44
+
45
+ Aliyun doc: https://help.aliyun.com/document_detail/164194.html
46
+
47
+ ``` ruby
48
+ phone_number = '151********'
49
+ text = 'code is 19384'
50
+ type = 'OTP'
51
+ # need register from Aliyun support
52
+ from = '18884060817'
53
+ AliyunSmsRuby.send_global_message(phone_number, text, from, type)
54
+ ```
55
+
56
+ ### Message status query
57
+ Aliyun doc: https://next.api.aliyun.com/document/Dysmsapi/2017-05-25/QuerySendDetails
58
+
59
+ ``` ruby
60
+ phone_number = '151********'
61
+ send_date = Time.now.strftime('%Y%m%d')
62
+ biz_id = '940902739667766114^0'
63
+ AliyunSmsRuby.send_query_request(phone_number, send_date, biz_id, page_size = 1, current_page = 1)
64
+ ```
data/README.zh-CN.md ADDED
@@ -0,0 +1,62 @@
1
+ # AliyunSmsRuby
2
+ 阿里云的短信服务,支持短信发送状态查询,10DLC
3
+
4
+ ## 安装
5
+
6
+ ```ruby
7
+ gem 'aliyun_sms_ruby'
8
+ ```
9
+
10
+ ## 配置
11
+ 添加文件 aliyun_sms_ruby.rb 到 config/initializers.
12
+
13
+ ```ruby
14
+ AliyunSmsRuby.configure do |config|
15
+ config.access_key_secret = ENV['ALIYUN_SMS_ACCESS_KEY_SECRET']
16
+ config.access_key_id = ENV['ALIYUN_SMS_ACCESS_KEY_ID']
17
+ config.sign_name = ENV['ALIYUN_SMS_SIGN_NAME']
18
+ end
19
+ ```
20
+
21
+ ## 使用
22
+
23
+ ### 短信发送
24
+ 文档地址: https://next.api.aliyun.com/document/Dysmsapi/2017-05-25/SendSms
25
+
26
+ ``` ruby
27
+ phone_number = '151********'
28
+ template_code = 'SMS_182823232'
29
+ template_param = { code: "10001" }
30
+ AliyunSmsRuby.send_message(phone_number, template_code, template_param)
31
+ ```
32
+
33
+ ### 国际短信发送(不可查询发送状态)
34
+ **重要: 注册完10DLC 后需要找阿里云的工单支持把当前的账号加入到阿里云的白名单里才行, 不然就会收到下面的错误**
35
+
36
+ ```
37
+ {
38
+ "Code": "Forbidden.Operation",
39
+ "Message":"You are not authorized to perform the operation."
40
+ }
41
+ ```
42
+
43
+ 文档地址: https://help.aliyun.com/document_detail/164194.html
44
+
45
+ ``` ruby
46
+ phone_number = '151********'
47
+ text = 'code is 19384'
48
+ type = 'OTP'
49
+ # need register from Aliyun support
50
+ from = '18884060817'
51
+ AliyunSmsRuby.send_global_message(phone_number, text, from, type)
52
+ ```
53
+
54
+ ### 短信状态查询
55
+ 文档地址: https://next.api.aliyun.com/document/Dysmsapi/2017-05-25/QuerySendDetails
56
+
57
+ ``` ruby
58
+ phone_number = '151********'
59
+ send_date = Time.now.strftime('%Y%m%d')
60
+ biz_id = '940902739667766114^0'
61
+ AliyunSmsRuby.send_query_request(phone_number, send_date, biz_id, page_size = 1, current_page = 1)
62
+ ```
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{Aliyun sms ruby sdk}
13
13
  spec.description = %q{Aliyun sms ruby sdk}
14
- spec.homepage = ""
14
+ spec.homepage = "https://github.com/Zkuns/aliyun_sms_ruby"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -6,12 +6,12 @@ module AliyunSmsRuby
6
6
  def initialize
7
7
  @access_key_secret = ''
8
8
  @access_key_id = ''
9
- @format = ''
10
- @region_id = ''
9
+ @format = 'JSON'
10
+ @region_id = 'cn-hangzhou'
11
11
  @sign_name = ''
12
- @signature_method = ''
13
- @signature_version = ''
14
- @version = ''
12
+ @signature_method = 'HMAC-SHA1'
13
+ @signature_version = '1.0'
14
+ @version = '2017-05-25'
15
15
  end
16
16
  end
17
17
  end
@@ -3,6 +3,32 @@ require 'aliyun_sms_ruby/request/base_request'
3
3
  module AliyunSmsRuby
4
4
  module Request
5
5
  class QueryRequest < BaseRequest
6
+ attr_accessor :mobile, :send_date, :biz_id, :page_size, :current_page
7
+
8
+ def initialize(mobile, send_date, biz_id, page_size, current_page)
9
+ self.mobile = mobile
10
+ self.send_date = send_date
11
+ self.biz_id = biz_id
12
+ self.page_size = page_size
13
+ self.current_page = current_page
14
+ end
15
+
16
+ def action
17
+ "QuerySendDetails".freeze
18
+ end
19
+
20
+ def custom_params
21
+ params = {
22
+ :PhoneNumber => mobile,
23
+ :SendDate => send_date,
24
+ :PageSize => page_size,
25
+ :CurrentPage => current_page
26
+ }
27
+
28
+ params.merge!({:BizId => biz_id}) if biz_id
29
+
30
+ params
31
+ end
6
32
  end
7
33
  end
8
34
  end
@@ -1,3 +1,3 @@
1
1
  module AliyunSmsRuby
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,6 +2,7 @@ require 'aliyun_sms_ruby/configuration'
2
2
  require 'aliyun_sms_ruby/client'
3
3
  require 'aliyun_sms_ruby/request/message_request'
4
4
  require 'aliyun_sms_ruby/request/message_global_request'
5
+ require 'aliyun_sms_ruby/request/query_request'
5
6
 
6
7
  module AliyunSmsRuby
7
8
  class << self
@@ -25,6 +26,11 @@ module AliyunSmsRuby
25
26
  client.send_request request
26
27
  end
27
28
 
29
+ def send_query_request(mobile, send_date, biz_id, page_size, current_page)
30
+ request = AliyunSmsRuby::Request::QueryRequest.new(mobile, send_date, biz_id, page_size, current_page)
31
+ client.send_request request
32
+ end
33
+
28
34
  private
29
35
  def client
30
36
  @client ||= AliyunSmsRuby::Client.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliyun_sms_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zkun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2021-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuid
@@ -88,6 +88,7 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - README.md
91
+ - README.zh-CN.md
91
92
  - aliyun_sms_ruby.gemspec
92
93
  - lib/aliyun_sms_ruby.rb
93
94
  - lib/aliyun_sms_ruby/client.rb
@@ -97,7 +98,7 @@ files:
97
98
  - lib/aliyun_sms_ruby/request/message_request.rb
98
99
  - lib/aliyun_sms_ruby/request/query_request.rb
99
100
  - lib/aliyun_sms_ruby/version.rb
100
- homepage: ''
101
+ homepage: https://github.com/Zkuns/aliyun_sms_ruby
101
102
  licenses:
102
103
  - MIT
103
104
  metadata: {}