tencent_cloud_sms 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c7ea9bd8c5180c766561bdee1ecdd0153386fbd035d91b12e00a04e4fbb6208c
4
+ data.tar.gz: 0d565d8e1520e2c45cb48207b2bc5fe8a0af399e2322584f31aa6d198c97066b
5
+ SHA512:
6
+ metadata.gz: a596ec6e06be40824704dc801268c032ede11a46f131361d1be68afa64590d47d5096d1778c9e8fd6275ea762ef498699de027c5d6383b83a17e49dd356e1a8f
7
+ data.tar.gz: 9bfe2cbfac231452ed83eb3ad2eb571af838140a299984f5ba9ba4d9b2439a70160068e1432c243b1c2b186267095e01b56ed7de52a6eebee8141015a8a05edc
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kobelu1990@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tencent_cloud_sms.gemspec
4
+ gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tencent_cloud_sms (0.1.0)
5
+ httparty (~> 0.17.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ httparty (0.17.3)
12
+ mime-types (~> 3.0)
13
+ multi_xml (>= 0.5.2)
14
+ mime-types (3.3.1)
15
+ mime-types-data (~> 3.2015)
16
+ mime-types-data (3.2019.1009)
17
+ multi_xml (0.6.0)
18
+ rake (10.5.0)
19
+ rspec (3.9.0)
20
+ rspec-core (~> 3.9.0)
21
+ rspec-expectations (~> 3.9.0)
22
+ rspec-mocks (~> 3.9.0)
23
+ rspec-core (3.9.1)
24
+ rspec-support (~> 3.9.1)
25
+ rspec-expectations (3.9.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.9.0)
28
+ rspec-mocks (3.9.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.9.0)
31
+ rspec-support (3.9.2)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 2.0)
38
+ rake (~> 10.0)
39
+ rspec (~> 3.0)
40
+ tencent_cloud_sms!
41
+
42
+ BUNDLED WITH
43
+ 2.0.2
@@ -0,0 +1,39 @@
1
+ # TencentCloudSms
2
+
3
+ Send sms by tencent cloud sms service
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tencent_cloud_sms'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tencent_cloud_sms
20
+
21
+ ## Usage
22
+
23
+ #### Configuration
24
+
25
+ ```ruby
26
+ TencentCloudSms::Configuration.config do |c|
27
+ c.sign = "sign"
28
+ c.sms_sdk_appid = 'appid'
29
+ c.template_id = 123
30
+ c.secret_id = 'secret_id'
31
+ c.secret_key = 'secret_key'
32
+ end
33
+ ```
34
+ #### Send Msg
35
+
36
+ ```ruby
37
+ TencentCloudSms.send_msg("18888888888", "msg")
38
+ ```
39
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tencent_cloud_sms"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,57 @@
1
+ require "tencent_cloud_sms/version"
2
+ require "tencent_cloud_sms/configuration"
3
+ require "httparty"
4
+
5
+ module TencentCloudSms
6
+ URL = 'sms.tencentcloudapi.com'
7
+ class Error < StandardError; end
8
+
9
+ class << self
10
+ attr_accessor :phone_number, :msg, :time_now, :nonce
11
+ def send_msg(phone_number, msg)
12
+ assign_attributes(phone_number, msg)
13
+ res = HTTParty.get("https://#{URL}/", query: params_with_sign)
14
+ result = JSON.load(res.body)
15
+ result_code = result["Response"]["SendStatusSet"].first["Code"]
16
+ return 'success' if result_code == 'Ok'
17
+ result_code #LimitExceeded.PhoneNumberDailyLimit 单手机超出每日限制
18
+ end
19
+
20
+ private
21
+
22
+ def assign_attributes(phone_number, msg)
23
+ self.phone_number = phone_number
24
+ self.msg = msg
25
+ self.time_now = Time.now.to_i
26
+ self.nonce = create_nonce
27
+ end
28
+
29
+ def params_with_sign
30
+ params.merge('Signature' => signature)
31
+ end
32
+
33
+ def signature
34
+ sign_str = "GET#{URL}/?" + params.sort.map { |param| param.join('=') }.join('&')
35
+ Base64.encode64(OpenSSL::HMAC.digest('sha1', Configuration.secret_key, sign_str)).strip
36
+ end
37
+
38
+ def params
39
+ {
40
+ 'Action'=> 'SendSms',
41
+ 'Version'=> '2019-07-11',
42
+ 'SmsSdkAppid'=> Configuration.sms_sdk_appid,
43
+ 'PhoneNumberSet.0'=> "+86" + phone_number,
44
+ 'TemplateID'=> Configuration.template_id,
45
+ 'TemplateParamSet.0'=> msg,
46
+ 'Timestamp'=> time_now,
47
+ 'Nonce'=> nonce,
48
+ 'SecretId'=> Configuration.secret_id,
49
+ 'Sign'=> Configuration.sign
50
+ }
51
+ end
52
+
53
+ def create_nonce
54
+ Random.new.rand(100000..999999).to_s
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,10 @@
1
+ module TencentCloudSms
2
+ class Configuration
3
+ class << self
4
+ attr_accessor :sms_sdk_appid, :template_id, :secret_id, :secret_key, :sign
5
+ def config
6
+ yield self if block_given?
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module TencentCloudSms
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "tencent_cloud_sms/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "tencent_cloud_sms"
7
+ spec.version = TencentCloudSms::VERSION
8
+ spec.authors = ["Michael"]
9
+ spec.email = ["kobelu1990@gmail.com"]
10
+
11
+ spec.summary = %q{send sms by tencent cloud sms service.}
12
+ spec.description = %q{send sms by tencent cloud sms service.}
13
+ spec.homepage = "https://github.com/luckylu/tencent_cloud_sms"
14
+
15
+ spec.metadata["allowed_push_host"] = 'https://rubygems.org'
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/luckylu/tencent_cloud_sms"
19
+ spec.metadata["changelog_uri"] = "https://github.com/luckylu/tencent_cloud_sms/README.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "httparty", '~> 0.17.3'
31
+
32
+ spec.add_development_dependency "bundler", "~> 2.0"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tencent_cloud_sms
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.17.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.17.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: send sms by tencent cloud sms service.
70
+ email:
71
+ - kobelu1990@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/tencent_cloud_sms.rb
87
+ - lib/tencent_cloud_sms/configuration.rb
88
+ - lib/tencent_cloud_sms/version.rb
89
+ - tencent_cloud_sms.gemspec
90
+ homepage: https://github.com/luckylu/tencent_cloud_sms
91
+ licenses: []
92
+ metadata:
93
+ allowed_push_host: https://rubygems.org
94
+ homepage_uri: https://github.com/luckylu/tencent_cloud_sms
95
+ source_code_uri: https://github.com/luckylu/tencent_cloud_sms
96
+ changelog_uri: https://github.com/luckylu/tencent_cloud_sms/README.md
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubygems_version: 3.0.3
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: send sms by tencent cloud sms service.
116
+ test_files: []