aliyun-rails 0.1.0 → 0.1.4

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: 8fc1dbec7b764f807056f0f18e0f1f39bf8e2cc22292bd22d9c961d1a5946bea
4
- data.tar.gz: 33574a813a8df2ef5bfd073fb0de6741edf2850690bce64f5941b5ed0b228adf
3
+ metadata.gz: a056069a71f1de1a699f72849e47bda0eb5c552985295ed6a6e381b99623fdde
4
+ data.tar.gz: 5b8e1bfaedfcdfa818d66da2a2753cdf3c97c10f0d9adbcec1b62a0aafcb4582
5
5
  SHA512:
6
- metadata.gz: 19c2df4717e7c95c83348b31ab98b8fa6225e8d0c67e44367071c778615a681284fd6aba5393e8b92630d4ca8236c957521046fa7a6011885a2104727ed55554
7
- data.tar.gz: c387845817a3214c0576fda0b0d367d03c0fdad3b3d09eda8507a6e658ee36333f1c5623cc5b575be62f1ee305f03caec35b0613581f0f6ea6cb2e91e19630b7
6
+ metadata.gz: d98f80bf57213f499e4c2f364fcb25b7ccbb31fbc02896fea9611930844d1c37abf45e0aaa12406e84ec627381a40064c1cc8e10806636827868fa715dcec5dc
7
+ data.tar.gz: 352ca1465ed2f06725bf8180dec2a1e8457785c80cf93f144714c31b633118ab6a5beefd346521d47dcdb878d912cc460072b0dd5ffe86f0ff7c83385c5aea5c
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "faraday"
2
4
  require "securerandom"
3
5
  require "active_support/all"
@@ -14,7 +16,6 @@ module Aliyun
14
16
  module Rails
15
17
  module Connector
16
18
  class ROAClient
17
-
18
19
  attr_accessor :endpoint, :api_version, :access_key_id,
19
20
  :access_key_secret, :security_token, :hostname, :opts
20
21
 
@@ -161,7 +162,6 @@ module Aliyun
161
162
  super("#{message} host_id: #{host_id}, request_id: #{request_id}")
162
163
  end
163
164
  end
164
-
165
165
  end
166
166
  end
167
167
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "set"
2
4
  require "openssl"
3
5
  require "faraday"
@@ -11,13 +13,12 @@ module Aliyun
11
13
  attr_accessor :endpoint, :api_version, :access_key_id, :access_key_secret,
12
14
  :security_token, :codes, :opts, :verbose
13
15
 
14
- def configure
16
+ def init_params
15
17
  yield self
16
18
  end
17
19
 
18
20
  # 对象初始化属性
19
- def initialize(config = configure, verbose = false)
20
-
21
+ def initialize(config = init_params, verbose = false)
21
22
  validate config
22
23
 
23
24
  self.endpoint = config[:endpoint]
@@ -1,26 +1,28 @@
1
- module Aliyun::Rails
2
- class Dysms < Aliyun::Rails::Connector::RPCClient
1
+ # frozen_string_literal: true
3
2
 
4
- # 本产品(Dysmsapi/2017-05-25)的OpenAPI采用RPC签名风格,签名细节参见签名机制说明。
5
- # 我们已经为开发者封装了常见编程语言的SDK,开发者可通过下载SDK直接调用本产品OpenAPI而无需关心技术细节。
6
- def initialize(config, verbose = nil)
3
+ module Aliyun
4
+ module Rails
5
+ class Dysms < Aliyun::Rails::Connector::RPCClient
6
+ # 本产品(Dysmsapi/2017-05-25)的OpenAPI采用RPC签名风格,签名细节参见签名机制说明。
7
+ # 我们已经为开发者封装了常见编程语言的SDK,开发者可通过下载SDK直接调用本产品OpenAPI而无需关心技术细节。
8
+ def initialize(config, verbose = nil)
9
+ config["endpoint"] = "http://dysmsapi.aliyuncs.com"
10
+ config["api_version"] = "2017-05-25"
7
11
 
8
- config["endpoint"] = "http://dysmsapi.aliyuncs.com"
9
- config["api_version"] = "2017-05-25"
12
+ super
13
+ end
10
14
 
11
- super
12
- end
13
-
14
- # 发送短信,发送前要申请短信签名和短信模板,并确保签名和模板已审核通过。
15
- def send_sms(phone_numbers, template_code, template_param, sign_name = "")
16
- params = {
17
- PhoneNumbers: phone_numbers,
18
- SignName: sign_name,
19
- TemplateCode: template_code,
20
- TemplateParam: template_param.to_json
21
- }
22
- opts = { method: "POST", timeout: 15000 }
23
- request(action: "SendSms", params: params, opts: opts)
15
+ # 发送短信,发送前要申请短信签名和短信模板,并确保签名和模板已审核通过。
16
+ def send_sms(phone_numbers, template_code, template_param, sign_name = "")
17
+ params = {
18
+ PhoneNumbers: phone_numbers,
19
+ SignName: sign_name,
20
+ TemplateCode: template_code,
21
+ TemplateParam: template_param.to_json
22
+ }
23
+ opts = { method: "POST", timeout: 15000 }
24
+ request(action: "SendSms", params: params, opts: opts)
25
+ end
24
26
  end
25
27
  end
26
28
  end
@@ -1,26 +1,28 @@
1
- module Aliyun::Rails
2
- class Dysms < Aliyun::Rails::Connector::RPCClient
1
+ # frozen_string_literal: true
3
2
 
4
- # 本产品(Dyvmsapi/2017-05-25)的OpenAPI采用RPC签名风格,签名细节参见签名机制说明。
5
- # 我们已经为开发者封装了常见编程语言的SDK,开发者可通过下载SDK直接调用本产品OpenAPI而无需关心技术细节。
6
- def initialize(config, verbose = nil)
3
+ module Aliyun
4
+ module Rails
5
+ class Dysms < Aliyun::Rails::Connector::RPCClient
6
+ # 本产品(Dyvmsapi/2017-05-25)的OpenAPI采用RPC签名风格,签名细节参见签名机制说明。
7
+ # 我们已经为开发者封装了常见编程语言的SDK,开发者可通过下载SDK直接调用本产品OpenAPI而无需关心技术细节。
8
+ def initialize(config, verbose = nil)
9
+ config["endpoint"] = "http://dyvmsapi.aliyuncs.com"
10
+ config["api_version"] = "2017-05-25"
7
11
 
8
- config["endpoint"] = "http://dyvmsapi.aliyuncs.com"
9
- config["api_version"] = "2017-05-25"
12
+ super
13
+ end
10
14
 
11
- super
12
- end
13
-
14
- # 调用SingleCallByTts接口向指定号码发送语音验证码和带参数变量的语音通知
15
- def single_call_by_tts(called_show_number, called_number, tts_code, tts_param)
16
- params = {
17
- CalledShowNumber: called_show_number,
18
- CalledNumber: called_number,
19
- TtsCode: tts_code,
20
- TtsParam: tts_param.to_json
21
- }
22
- opts = { method: "POST", timeout: 15000 }
23
- request(action: "SendSms", params: params, opts: opts)
15
+ # 调用SingleCallByTts接口向指定号码发送语音验证码和带参数变量的语音通知
16
+ def single_call_by_tts(called_show_number, called_number, tts_code, tts_param)
17
+ params = {
18
+ CalledShowNumber: called_show_number,
19
+ CalledNumber: called_number,
20
+ TtsCode: tts_code,
21
+ TtsParam: tts_param.to_json
22
+ }
23
+ opts = { method: "POST", timeout: 15000 }
24
+ request(action: "SendSms", params: params, opts: opts)
25
+ end
24
26
  end
25
27
  end
26
28
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Aliyun
4
4
  module Rails
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.4"
6
6
  DEFAULT_UA = "AlibabaCloud (#{Gem::Platform.local.os}; " +
7
7
  "#{Gem::Platform.local.cpu}) Ruby/#{RUBY_VERSION} Core/#{VERSION}"
8
8
  end
@@ -2,12 +2,21 @@
2
2
 
3
3
  require_relative "rails/version"
4
4
 
5
+ require "aliyun/rails/version"
5
6
  require "aliyun/rails/connector/roa_client"
6
7
  require "aliyun/rails/connector/rpc_client"
8
+ require "aliyun/rails/dysms"
9
+ require "aliyun/rails/dyvms"
7
10
 
8
11
  module Aliyun
9
12
  module Rails
10
13
  class Error < StandardError; end
14
+
15
+ class << self
16
+ def config(&block)
17
+ RPCClient.init_params(&block)
18
+ end
19
+ end
11
20
  # Your code goes here...
12
21
  end
13
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliyun-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - WENWU.YAN
@@ -47,7 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - README.md
49
49
  - Rakefile
50
- - lib/aliyun/aliyun-rails.rb
50
+ - lib/aliyun/rails.rb
51
51
  - lib/aliyun/rails/connector/roa_client.rb
52
52
  - lib/aliyun/rails/connector/rpc_client.rb
53
53
  - lib/aliyun/rails/dysms.rb