twsms2 1.2.1 → 1.3.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.
- checksums.yaml +5 -5
- data/README.md +2 -3
- data/lib/twsms2/formatter.rb +20 -13
- data/lib/twsms2/version.rb +1 -1
- data/lib/twsms2.rb +3 -3
- data/twsms2.gemspec +5 -5
- metadata +21 -17
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ed7351473d76e0ad230808dc4ac38abb5609887a79efef9b40a3d6a6e4587019
|
4
|
+
data.tar.gz: 36a0052de311fde0274c540b08b6a91cdb56127b80e02112dc9245387350025d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b595982bb5db4ba708c67a59b893901ad831d35d7310fdd2b7fe44b5563128deffb68294592f79e5a745a58dfcc97df5307830e408b83b9f0dfc533afee5bedf
|
7
|
+
data.tar.gz: 6374876b1a82e0804ecb16850ffcbea004b7a25f93dac4614714e3cda311f89112129a5a060a3ba15388d86b32cfeb3b382fa7806066ab3f58aa90f996041901
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
Twsms2 (
|
1
|
+
Twsms2 ( 台灣簡訊 TwSMS API Ruby 版套件 )
|
2
2
|
=================================================
|
3
3
|
|
4
4
|
[](https://badge.fury.io/rb/twsms2)
|
5
|
-
[](https://travis-ci.org/guanting112/twsms2)
|
6
5
|
[](https://codeclimate.com/github/guanting112/twsms2)
|
7
6
|
|
8
7
|

|
@@ -22,7 +21,7 @@ Ruby 2 以上的版本,也可在 Ruby On Rails 專案引入
|
|
22
21
|
請在您的 Ruby 或 Rails 專案裡的 Gemfile 加入以下指令
|
23
22
|
|
24
23
|
```ruby
|
25
|
-
gem 'twsms2', '
|
24
|
+
gem 'twsms2', '=> 1.3.0'
|
26
25
|
```
|
27
26
|
|
28
27
|
然後執行 bundle install 更新套件組
|
data/lib/twsms2/formatter.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Twsms2
|
2
4
|
module Formatter
|
3
|
-
def match_string(rule, string)
|
4
|
-
match_data = rule.match(string)
|
5
|
-
match_data.nil? ? nil : match_data[1]
|
6
|
-
end
|
7
5
|
|
8
6
|
def format_time_string(time)
|
9
7
|
return nil if time.nil?
|
@@ -31,6 +29,7 @@ module Twsms2
|
|
31
29
|
when 'MSGERROR' then 'incorrect_content'
|
32
30
|
when 'OTHERROR' then 'sms_system_other_error'
|
33
31
|
when 'REJERROR' then 'illegal_content'
|
32
|
+
when 'REJMOBIL' then 'device_rejected'
|
34
33
|
else 'status_undefined'
|
35
34
|
end
|
36
35
|
|
@@ -45,10 +44,13 @@ module Twsms2
|
|
45
44
|
error: nil
|
46
45
|
}
|
47
46
|
|
48
|
-
|
49
|
-
status_text = match_string(/<statustext>(?<status>\w+)<\/statustext>/, original_info)
|
47
|
+
json_info = JSON.parse(original_info)
|
50
48
|
|
51
|
-
|
49
|
+
code_text = json_info['code']
|
50
|
+
status_text = json_info['statustext']
|
51
|
+
|
52
|
+
new_info[:access_success] =
|
53
|
+
!code_text.nil? && !status_text.nil? && code_text == '00000'
|
52
54
|
|
53
55
|
if new_info[:access_success]
|
54
56
|
new_info[:message_status] = message_status_sanitize(status_text)
|
@@ -67,10 +69,13 @@ module Twsms2
|
|
67
69
|
error: nil
|
68
70
|
}
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
+
json_info = JSON.parse(original_info)
|
73
|
+
|
74
|
+
code_text = json_info['code']
|
75
|
+
message_id_text = json_info['msgid']
|
72
76
|
|
73
|
-
new_info[:access_success] =
|
77
|
+
new_info[:access_success] =
|
78
|
+
!code_text.nil? && !message_id_text.nil? && code_text == '00000'
|
74
79
|
|
75
80
|
if new_info[:access_success]
|
76
81
|
new_info[:message_id] = message_id_text
|
@@ -88,10 +93,12 @@ module Twsms2
|
|
88
93
|
error: nil
|
89
94
|
}
|
90
95
|
|
91
|
-
|
92
|
-
|
96
|
+
json_info = JSON.parse(original_info)
|
97
|
+
code_text = json_info['code']
|
98
|
+
point_text = json_info['point']
|
93
99
|
|
94
|
-
new_info[:access_success] =
|
100
|
+
new_info[:access_success] =
|
101
|
+
!code_text.nil? && !point_text.nil? && code_text == '00000'
|
95
102
|
|
96
103
|
if new_info[:access_success]
|
97
104
|
new_info[:message_quota] = point_text.to_i
|
data/lib/twsms2/version.rb
CHANGED
data/lib/twsms2.rb
CHANGED
@@ -28,13 +28,13 @@ module Twsms2
|
|
28
28
|
options[:long] = options[:long] || options[:long].nil? ? :Y : :N
|
29
29
|
options[:popup] = options[:popup] ? :Y : :N
|
30
30
|
|
31
|
-
response = get(@api_host, '/
|
31
|
+
response = get(@api_host, '/json/sms_send.php', popup: options[:popup], mo: :N, longsms: options[:long], mobile: options[:to], message: options[:content], drurl: '', sendtime: options[:at])
|
32
32
|
|
33
33
|
format_send_message_info(response)
|
34
34
|
end
|
35
35
|
|
36
36
|
def get_balance
|
37
|
-
response = get(@api_host, '/
|
37
|
+
response = get(@api_host, '/json/sms_query.php', deltime: :N, checkpoint: :Y, mobile: '', msgid: '')
|
38
38
|
|
39
39
|
format_balance_info(response)
|
40
40
|
end
|
@@ -43,7 +43,7 @@ module Twsms2
|
|
43
43
|
options[:message_id] ||= nil
|
44
44
|
options[:phone_number] ||= nil
|
45
45
|
|
46
|
-
response = get(@api_host, '/
|
46
|
+
response = get(@api_host, '/json/sms_query.php', mobile: options[:phone_number], msgid: options[:message_id])
|
47
47
|
|
48
48
|
format_message_status(response)
|
49
49
|
end
|
data/twsms2.gemspec
CHANGED
@@ -10,10 +10,10 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["cgt886@gmail.com"]
|
11
11
|
spec.license = "MIT"
|
12
12
|
spec.platform = Gem::Platform::RUBY
|
13
|
-
spec.summary = %q{
|
14
|
-
spec.description = %q{
|
13
|
+
spec.summary = %q{2021 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )}
|
14
|
+
spec.description = %q{2021 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )}
|
15
15
|
spec.homepage = "https://github.com/guanting112/twsms2"
|
16
|
-
spec.required_ruby_version = '
|
16
|
+
spec.required_ruby_version = '>= 2'
|
17
17
|
|
18
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.add_development_dependency "bundler", "
|
32
|
-
spec.add_development_dependency "rake", "
|
31
|
+
spec.add_development_dependency "bundler", "<3.0", ">=1.7"
|
32
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
33
33
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
34
34
|
end
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twsms2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guanting Chen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: '1.7'
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - "<"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: '1.7'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rake
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
39
|
+
version: 12.3.3
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
46
|
+
version: 12.3.3
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: minitest
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +58,7 @@ dependencies:
|
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '5.0'
|
55
|
-
description:
|
61
|
+
description: 2021 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )
|
56
62
|
email:
|
57
63
|
- cgt886@gmail.com
|
58
64
|
executables: []
|
@@ -60,7 +66,6 @@ extensions: []
|
|
60
66
|
extra_rdoc_files: []
|
61
67
|
files:
|
62
68
|
- ".gitignore"
|
63
|
-
- ".travis.yml"
|
64
69
|
- Gemfile
|
65
70
|
- LICENSE
|
66
71
|
- README.md
|
@@ -78,13 +83,13 @@ licenses:
|
|
78
83
|
- MIT
|
79
84
|
metadata:
|
80
85
|
allowed_push_host: https://rubygems.org
|
81
|
-
post_install_message:
|
86
|
+
post_install_message:
|
82
87
|
rdoc_options: []
|
83
88
|
require_paths:
|
84
89
|
- lib
|
85
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
91
|
requirements:
|
87
|
-
- - "
|
92
|
+
- - ">="
|
88
93
|
- !ruby/object:Gem::Version
|
89
94
|
version: '2'
|
90
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -93,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
98
|
- !ruby/object:Gem::Version
|
94
99
|
version: '0'
|
95
100
|
requirements: []
|
96
|
-
|
97
|
-
|
98
|
-
signing_key:
|
101
|
+
rubygems_version: 3.2.15
|
102
|
+
signing_key:
|
99
103
|
specification_version: 4
|
100
|
-
summary:
|
104
|
+
summary: 2021 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )
|
101
105
|
test_files: []
|