aliyun-email-ruby-sdk 0.0.1.2 → 0.0.1.3
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.md +8 -2
- data/lib/aliyun/email.rb +28 -30
- data/lib/aliyun/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5939d1169cbee54b9254b2a04baa498ba42cc5
|
4
|
+
data.tar.gz: d103f9e6c65e3416d24041599beb36df102cae6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e204bb3accda5eea35e11463172fb9e2446bc31e944bc11181df8d2d193caa15ddc65e10fcaff99d71811201b8da565963eb72c2161aa7020ac09f0a2857d61
|
7
|
+
data.tar.gz: 6072e8fd67e052b6637b071c4892a86b24cc2135596434c02476a4c710fa4623670326d043a1aa8d1cd639c511d7bde2eea30e212c55a57ed8ef1d4caaf3e243
|
data/README.md
CHANGED
@@ -13,7 +13,13 @@ aliyun = Aliyun::Email.new(@config['access_key_id'],@config['access_key_secret']
|
|
13
13
|
aliyun.send(@config['to_address'],
|
14
14
|
from_alias: @config['from_alias'],
|
15
15
|
subject: @config['subject'],
|
16
|
-
|
17
|
-
|
16
|
+
body: @config['textbody'],
|
17
|
+
click_trace: @config['click_trace'])
|
18
|
+
|
19
|
+
aliyun.send(@config['to_address'],
|
20
|
+
from_alias: @config['from_alias'],
|
21
|
+
subject: @config['subject'],
|
22
|
+
body: @config['htmlbody'],
|
23
|
+
format: :html,
|
18
24
|
click_trace: @config['click_trace'])
|
19
25
|
```
|
data/lib/aliyun/email.rb
CHANGED
@@ -9,16 +9,16 @@ include ERB::Util
|
|
9
9
|
module Aliyun
|
10
10
|
class Email
|
11
11
|
attr_accessor :access_key_secret,
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
:access_key_id,
|
13
|
+
:action,
|
14
|
+
:format,
|
15
|
+
:region_id,
|
16
|
+
:account_name,
|
17
|
+
:signature_method,
|
18
|
+
:reply_to_address,
|
19
|
+
:address_type,
|
20
|
+
:signature_version,
|
21
|
+
:version
|
22
22
|
def initialize(access_key_id, access_key_secret, account_name)
|
23
23
|
# public args
|
24
24
|
@access_key_secret = access_key_secret
|
@@ -39,26 +39,26 @@ module Aliyun
|
|
39
39
|
def create_params(to_address)
|
40
40
|
{
|
41
41
|
# public args
|
42
|
-
'AccessKeyId'
|
43
|
-
'Format'
|
44
|
-
'RegionId'
|
45
|
-
'SignatureMethod'
|
46
|
-
'SignatureVersion'
|
47
|
-
'Version'
|
42
|
+
'AccessKeyId' => access_key_id,
|
43
|
+
'Format' => format,
|
44
|
+
'RegionId' => region_id,
|
45
|
+
'SignatureMethod' => signature_method,
|
46
|
+
'SignatureVersion' => signature_version,
|
47
|
+
'Version' => version,
|
48
48
|
|
49
|
-
'SignatureNonce'
|
50
|
-
'Timestamp'
|
49
|
+
'SignatureNonce' => seed_signature_nonce,
|
50
|
+
'Timestamp' => seed_timestamp,
|
51
51
|
|
52
52
|
# function args
|
53
|
-
'Action'
|
54
|
-
'AccountName'
|
55
|
-
'ReplyToAddress'
|
56
|
-
'AddressType'
|
57
|
-
'ToAddress'
|
53
|
+
'Action' => action,
|
54
|
+
'AccountName' => account_name,
|
55
|
+
'ReplyToAddress' => reply_to_address,
|
56
|
+
'AddressType' => address_type,
|
57
|
+
'ToAddress' => to_address
|
58
58
|
}
|
59
59
|
end
|
60
60
|
|
61
|
-
def send(to_address
|
61
|
+
def send(to_address:, subject:, body:, from_alias: nil, click_trace: nil, format: :text)
|
62
62
|
begin
|
63
63
|
uri = URI("https://dm.aliyuncs.com")
|
64
64
|
header = {"Content-Type": "application/x-www-form-urlencoded"}
|
@@ -68,8 +68,7 @@ module Aliyun
|
|
68
68
|
params = create_params(to_address)
|
69
69
|
params['FromAlias'] = from_alias unless from_alias.nil?
|
70
70
|
params['Subject'] = subject unless subject.nil?
|
71
|
-
params['HtmlBody'] =
|
72
|
-
params['TextBody'] = textbody unless textbody.nil?
|
71
|
+
params[format == :text ? 'TextBody' : 'HtmlBody'] = body
|
73
72
|
params['ClickTrace'] = click_trace unless click_trace.nil?
|
74
73
|
req.body = sign_result(access_key_secret, params)
|
75
74
|
response = http.request(req)
|
@@ -97,7 +96,7 @@ module Aliyun
|
|
97
96
|
end
|
98
97
|
|
99
98
|
|
100
|
-
def compute_signature access_key_secret,canonicalized_query_string
|
99
|
+
def compute_signature access_key_secret, canonicalized_query_string
|
101
100
|
string_to_sign = 'POST' + '&' + safe_encode('/') + '&' + safe_encode(canonicalized_query_string)
|
102
101
|
signature = calculate_signature access_key_secret+"&", string_to_sign
|
103
102
|
end
|
@@ -107,8 +106,7 @@ module Aliyun
|
|
107
106
|
end
|
108
107
|
|
109
108
|
def safe_encode value
|
110
|
-
URI.encode_www_form_component(value).gsub(/\+/,'%20').gsub(/\*/,'%2A').gsub(/%7E/,'~')
|
109
|
+
URI.encode_www_form_component(value).gsub(/\+/, '%20').gsub(/\*/, '%2A').gsub(/%7E/, '~')
|
111
110
|
end
|
112
111
|
end
|
113
|
-
end
|
114
|
-
|
112
|
+
end
|
data/lib/aliyun/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliyun-email-ruby-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xbw
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.6.
|
95
|
+
rubygems_version: 2.6.14
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Use aliyun-email to send email.
|