aliyun-cloud_sms 0.2.0 → 0.2.1
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 +4 -4
- data/README-CN.md +71 -0
- data/README.md +16 -14
- data/lib/aliyun/cloud_sms/version.rb +1 -1
- data/lib/aliyun/cloud_sms.rb +4 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d801f060e22842e6726d6f755f13f289b0114bff
|
4
|
+
data.tar.gz: b9f615593957ea58f0201cdc7692c5101f3ffa69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 702d40bfee904899db53dab5fa07407e0edfb62476789beedf1d42919df8e28f9539e0ca4e5f9eccc389fad14af4cf3bb304eae25c5dd901167e34d5bcc45d7c
|
7
|
+
data.tar.gz: 1b30f86058602e632c30dc88684a06f078e5c830aaf0074d9fdb0d10b87f5f4f94d837b3149399d10af08cdb913d9524968c5ac1c9854ae9c3e8776e920f531d
|
data/README-CN.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Aliyun::CloudSms
|
2
|
+
|
3
|
+
基于阿里短信服务接口,支持短信发送与状态查询。
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
在项目的Gemfile里添加下面一行
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'aliyun-cloud_sms'
|
11
|
+
```
|
12
|
+
|
13
|
+
执行
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
或者你也可以
|
18
|
+
|
19
|
+
$ gem install aliyun-cloud_sms
|
20
|
+
|
21
|
+
## 构建客户端
|
22
|
+
|
23
|
+
### 全局客户端
|
24
|
+
在config/initializers目录添加一个文件`aliyun-cloud_sms.rb`
|
25
|
+
|
26
|
+
``` ruby
|
27
|
+
Aliyun::CloudSms.configure do |config|
|
28
|
+
config.access_key_secret = 'your key secret'
|
29
|
+
config.access_key_id = 'your key id'
|
30
|
+
config.sign_name = 'your sign name'
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
### 多账户支持
|
35
|
+
有的服务可能会需要给不同的应用发送。
|
36
|
+
```ruby
|
37
|
+
client = Aliyun::CloudSms.new('your_access_key_id', 'your_access_key_secret', 'your_sign_name')
|
38
|
+
|
39
|
+
client.send_msg('13800000000', 'SMS_80190090', {"customer": "jere"} )
|
40
|
+
```
|
41
|
+
|
42
|
+
## 接口
|
43
|
+
|
44
|
+
### 短信发送
|
45
|
+
如果是全局客户端, 可以使用:
|
46
|
+
```ruby
|
47
|
+
Aliyun::CloudSms.send_msg('13800000000', 'SMS_80190090', {"customer": "jere"} )
|
48
|
+
```
|
49
|
+
|
50
|
+
`template_params`可以传字符串,以多账户支持为例:
|
51
|
+
```ruby
|
52
|
+
client.send_msg('13800000000', 'SMS_80190090', "{\"customer\":\"jeremy\"}" )
|
53
|
+
```
|
54
|
+
### 状态查询
|
55
|
+
```ruby
|
56
|
+
client.query_status(mobile, send_date = "#{Time.now.strftime('%Y%m%d')}", biz_id = nil, page_size = 1, current_page = 1)
|
57
|
+
|
58
|
+
# e.g.
|
59
|
+
client.query_status '13800000000'
|
60
|
+
client.query_status '13800000000', '20170806'
|
61
|
+
client.query_status '13800000000', '20170806', '109177619494^4112265203597'
|
62
|
+
client.query_status '13800000000', '20170806', nil, 10
|
63
|
+
client.query_status '13800000000', '20170806', nil, 10, 2
|
64
|
+
```
|
65
|
+
## 贡献
|
66
|
+
|
67
|
+
欢迎PR。
|
68
|
+
|
69
|
+
|
70
|
+
## License
|
71
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Aliyun::CloudSms
|
2
2
|
|
3
3
|
This gem is used for sending sms via aliyun sms service, and querying the message status as well.
|
4
|
+
[中文文档 Chinese document](https://github.com/jerecui/aliyun-cloud_sms/blob/master/README-CN.md)
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -18,9 +19,9 @@ Or install it yourself as:
|
|
18
19
|
|
19
20
|
$ gem install aliyun-cloud_sms
|
20
21
|
|
21
|
-
##
|
22
|
+
## Construct a client
|
22
23
|
|
23
|
-
### Global
|
24
|
+
### Global account
|
24
25
|
Create file aliyun-cloud_sms.rb to your config/initializers.
|
25
26
|
``` ruby
|
26
27
|
Aliyun::CloudSms.configure do |config|
|
@@ -28,29 +29,29 @@ Aliyun::CloudSms.configure do |config|
|
|
28
29
|
config.access_key_id = 'your key id'
|
29
30
|
config.sign_name = 'your sign name'
|
30
31
|
end
|
31
|
-
|
32
|
-
```
|
33
|
-
If you want to send message, Aliyun::CloudSms.send_msg(mobile, template_code, template_param).
|
34
|
-
e.g.
|
35
|
-
```ruby
|
36
|
-
Aliyun::CloudSms.send_msg('13800000000', 'SMS_80190090', {"customer": "jere"} )
|
37
32
|
```
|
38
|
-
The param is not a string, is a hash instead.
|
39
|
-
|
40
33
|
### Multiple account support
|
41
34
|
If you want to send message with multiple sign name, you can build your own message sender client.
|
42
35
|
```ruby
|
43
36
|
client = Aliyun::CloudSms.new('your_access_key_id', 'your_access_key_secret', 'your_sign_name')
|
44
37
|
|
45
|
-
|
38
|
+
## API
|
39
|
+
### Message send
|
40
|
+
```ruby
|
41
|
+
Aliyun::CloudSms.send_msg(mobile, template_code, template_param).
|
42
|
+
```
|
43
|
+
e.g.
|
44
|
+
```ruby
|
45
|
+
Aliyun::CloudSms.send_msg('13800000000', 'SMS_80190090', {"customer": "jere"} )
|
46
46
|
```
|
47
47
|
|
48
|
-
`template_params`
|
48
|
+
`template_params` could be a string.
|
49
49
|
```ruby
|
50
50
|
client.send_msg('13800000000', 'SMS_80190090', "{\"customer\":\"jeremy\"}" )
|
51
51
|
```
|
52
52
|
|
53
|
-
|
53
|
+
### Status query
|
54
|
+
|
54
55
|
```ruby
|
55
56
|
client.query_status(mobile, send_date = "#{Time.now.strftime('%Y%m%d')}", biz_id = nil, page_size = 1, current_page = 1)
|
56
57
|
|
@@ -69,7 +70,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
69
70
|
|
70
71
|
## Contributing
|
71
72
|
|
72
|
-
|
73
|
+
Welcome pull request.
|
74
|
+
Hope help.
|
73
75
|
|
74
76
|
|
75
77
|
## License
|
data/lib/aliyun/cloud_sms.rb
CHANGED
@@ -10,6 +10,10 @@ module Aliyun
|
|
10
10
|
default_client.send_msg mobile, template_code, template_param
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.query_status(mobile, send_date = "#{Time.now.strftime('%Y%m%d')}", biz_id = nil, page_size = 1, current_page = 1)
|
14
|
+
default_client.query_status mobile, send_date, biz_id, page_size, current_page
|
15
|
+
end
|
16
|
+
|
13
17
|
def self.client(access_key_id, access_key_secret, sign_name)
|
14
18
|
Aliyun::Client.new access_key_id, access_key_secret, sign_name
|
15
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliyun-cloud_sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Cui
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- CODE_OF_CONDUCT.md
|
106
106
|
- Gemfile
|
107
107
|
- LICENSE.txt
|
108
|
+
- README-CN.md
|
108
109
|
- README.md
|
109
110
|
- Rakefile
|
110
111
|
- aliyun-cloud_sms.gemspec
|