twsms2 1.2.1 → 1.3.0

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
- SHA1:
3
- metadata.gz: d39c490008149fc9f2d6a6738c1de1bdcba3ed8b
4
- data.tar.gz: 1db018aafffe92c2124f607ded73d47d1959c7b6
2
+ SHA256:
3
+ metadata.gz: ed7351473d76e0ad230808dc4ac38abb5609887a79efef9b40a3d6a6e4587019
4
+ data.tar.gz: 36a0052de311fde0274c540b08b6a91cdb56127b80e02112dc9245387350025d
5
5
  SHA512:
6
- metadata.gz: 67f2cc587cbbfaa478827e217b3d5d4451e68f6d0fb7f53776d2a0b7b6899e7483bd58f2ad20c5ec2be5ffea35e4743e3b8991645433ef3ef5a5718afbc57931
7
- data.tar.gz: ae2e987cfbd410d852c064b290a583ca84d2ea9d41c319ee7a250e6870009bc69a136930c57ebe20d0d1d1b84e7c4287c46a64575332bcb8688c1ade197fda9b
6
+ metadata.gz: b595982bb5db4ba708c67a59b893901ad831d35d7310fdd2b7fe44b5563128deffb68294592f79e5a745a58dfcc97df5307830e408b83b9f0dfc533afee5bedf
7
+ data.tar.gz: 6374876b1a82e0804ecb16850ffcbea004b7a25f93dac4614714e3cda311f89112129a5a060a3ba15388d86b32cfeb3b382fa7806066ab3f58aa90f996041901
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
- Twsms2 ( 2016 新版 台灣簡訊 TwSMS API Ruby 版套件 )
1
+ Twsms2 ( 台灣簡訊 TwSMS API Ruby 版套件 )
2
2
  =================================================
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/twsms2.svg)](https://badge.fury.io/rb/twsms2)
5
- [![Build Status](https://travis-ci.org/guanting112/twsms2.svg?branch=master)](https://travis-ci.org/guanting112/twsms2)
6
5
  [![Code Climate](https://codeclimate.com/github/guanting112/twsms2/badges/gpa.svg)](https://codeclimate.com/github/guanting112/twsms2)
7
6
 
8
7
  ![twsms](http://i.imgur.com/KVuaBIm.png)
@@ -22,7 +21,7 @@ Ruby 2 以上的版本,也可在 Ruby On Rails 專案引入
22
21
  請在您的 Ruby 或 Rails 專案裡的 Gemfile 加入以下指令
23
22
 
24
23
  ```ruby
25
- gem 'twsms2', '~> 1.2.0'
24
+ gem 'twsms2', '=> 1.3.0'
26
25
  ```
27
26
 
28
27
  然後執行 bundle install 更新套件組
@@ -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
- code_text = match_string(/<code>(?<code>\w+)<\/code>/, original_info)
49
- status_text = match_string(/<statustext>(?<status>\w+)<\/statustext>/, original_info)
47
+ json_info = JSON.parse(original_info)
50
48
 
51
- new_info[:access_success] = !code_text.nil? && !status_text.nil? && code_text == '00000'
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
- code_text = match_string(/<code>(?<code>\w+)<\/code>/, original_info)
71
- message_id_text = match_string(/<msgid>(?<message_id>\d+)<\/msgid>/, original_info)
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] = !code_text.nil? && !message_id_text.nil? && code_text == '00000'
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
- code_text = match_string(/<code>(?<code>\w+)<\/code>/, original_info)
92
- point_text = match_string(/<point>(?<point>\d+)<\/point>/, original_info)
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] = !code_text.nil? && !point_text.nil? && code_text == '00000'
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
@@ -1,3 +1,3 @@
1
1
  module Twsms2
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
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, '/smsSend.php', popup: options[:popup], mo: :N, longsms: options[:long], mobile: options[:to], message: options[:content], drurl: '', sendtime: options[:at])
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, '/smsQuery.php', deltime: :N, checkpoint: :Y, mobile: '', msgid: '')
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, '/smsQuery.php', mobile: options[:phone_number], msgid: options[:message_id])
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{2016 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )}
14
- spec.description = %q{2016 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )}
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 = '~> 2'
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", "~> 1.7"
32
- spec.add_development_dependency "rake", "~> 10.0"
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.2.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: 2016-09-06 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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: 2016 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )
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
- rubyforge_project:
97
- rubygems_version: 2.5.1
98
- signing_key:
101
+ rubygems_version: 3.2.15
102
+ signing_key:
99
103
  specification_version: 4
100
- summary: 2016 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )
104
+ summary: 2021 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )
101
105
  test_files: []
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0
4
- - 2.1
5
- - 2.2
6
- - 2.3.1