twsms2 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -6
- data/Rakefile +2 -2
- data/bin/console +4 -4
- data/lib/twsms2/formatter.rb +2 -6
- data/lib/twsms2/version.rb +1 -1
- data/lib/twsms2.rb +1 -2
- data/twsms2.gemspec +0 -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: 604e4232d10dd76ea6064e215fae633f8b020746
|
4
|
+
data.tar.gz: 5585e90bff7241bdd4bafdf2562e4e3848b6fed6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3268a918b026b4f3ff830ffede2457a0a9cd05815121e26a4a7af4164424bc39866026d9b7dd925ddfb43bffb0f486295334aa25fa9a0deaac6670d4726cacc7
|
7
|
+
data.tar.gz: bf60f687de9713a89c52bba76200254aad1da2558ae405581f58a3ded581eead607441e49154c4b619af32189cedfc3fcf4e321f273fc6ef5d13281435be237c
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
Twsms2 ( 2016 新版 台灣簡訊 TwSMS API Ruby 版套件 )
|
2
2
|
=================================================
|
3
3
|
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/twsms2.svg)](https://badge.fury.io/rb/twsms2)
|
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
|
+
[![Code Climate](https://codeclimate.com/github/guanting112/twsms2/badges/gpa.svg)](https://codeclimate.com/github/guanting112/twsms2)
|
5
7
|
|
6
8
|
![twsms](http://i.imgur.com/KVuaBIm.png)
|
7
9
|
|
@@ -42,7 +44,9 @@ gem 'twsms2', '~> 1.1.0'
|
|
42
44
|
require 'twsms2'
|
43
45
|
|
44
46
|
# Twsms2 是走 https 的方式進行系統操作
|
45
|
-
sms_client = Twsms2::Client.new(
|
47
|
+
sms_client = Twsms2::Client.new(
|
48
|
+
username: '會員帳號', password: '會員密碼', agent: "Mozilla/5.0 (可自訂 user-agent)"
|
49
|
+
)
|
46
50
|
```
|
47
51
|
|
48
52
|
使用範例
|
@@ -86,7 +90,7 @@ sms_client.send_message to: '手機號碼', content: "預約簡訊測試: #{Time
|
|
86
90
|
|
87
91
|
#### 強制直接顯示簡訊內容
|
88
92
|
|
89
|
-
可以加入 popup
|
93
|
+
可以加入 popup 參數,讓簡訊在收訊人的手機上直接顯示,但有可能不會被手機儲存
|
90
94
|
|
91
95
|
```ruby
|
92
96
|
sms_client.send_message to: '手機號碼', content: "簡訊內容..", popup: true
|
@@ -94,9 +98,9 @@ sms_client.send_message to: '手機號碼', content: "簡訊內容..", popup: tr
|
|
94
98
|
|
95
99
|
#### 關閉長簡訊支援
|
96
100
|
|
97
|
-
|
101
|
+
一般發送簡訊時,程式預設支援長簡訊發送
|
98
102
|
|
99
|
-
因此,若超 SMS
|
103
|
+
因此,若超 SMS 簡訊字元長度,將會以第二封起開始計算
|
100
104
|
|
101
105
|
加入 long 參數,若指定為 false 則不會使用長簡訊格式
|
102
106
|
|
@@ -104,6 +108,8 @@ sms_client.send_message to: '手機號碼', content: "簡訊內容..", popup: tr
|
|
104
108
|
sms_client.send_message to: '手機號碼', content: "簡訊內容..", long: false
|
105
109
|
```
|
106
110
|
|
111
|
+
詳細規則請以 台灣簡訊 公告為主
|
112
|
+
|
107
113
|
### 發送簡訊 的 回傳結果
|
108
114
|
|
109
115
|
#### 發送成功
|
@@ -155,7 +161,7 @@ message_quota 則是簡訊餘額,代表你還剩幾封可以用,若為 0 就
|
|
155
161
|
{:access_success=>true, :message_quota=>77, :error=>nil}
|
156
162
|
```
|
157
163
|
|
158
|
-
####
|
164
|
+
#### 發生錯誤時
|
159
165
|
|
160
166
|
若 access_success 為 false 則表示過程有出現錯誤,同時 message_quota 會為 0
|
161
167
|
|
@@ -176,3 +182,4 @@ LICENSE
|
|
176
182
|
|
177
183
|
[twsms_signup]: https://www.twsms.com/accjoin.php
|
178
184
|
[twsms_homepage]: https://www.twsms.com/
|
185
|
+
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'twsms2'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require
|
10
|
+
# require 'pry'
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/lib/twsms2/formatter.rb
CHANGED
@@ -32,9 +32,7 @@ module Twsms2
|
|
32
32
|
if new_info[:access_success]
|
33
33
|
new_info[:message_id] = message_id_text
|
34
34
|
else
|
35
|
-
new_info[:error] = "TWSMS:CODE_NOT_FOUND"
|
36
|
-
new_info[:error] = "TWSMS:#{code_text}" unless code_text.nil?
|
37
|
-
new_info[:error].upcase!
|
35
|
+
new_info[:error] = code_text.nil? ? "TWSMS:CODE_NOT_FOUND" : "TWSMS:#{code_text}".upcase
|
38
36
|
end
|
39
37
|
|
40
38
|
new_info
|
@@ -55,9 +53,7 @@ module Twsms2
|
|
55
53
|
if new_info[:access_success]
|
56
54
|
new_info[:message_quota] = point_text.to_i
|
57
55
|
else
|
58
|
-
new_info[:error] = "TWSMS:CODE_NOT_FOUND"
|
59
|
-
new_info[:error] = "TWSMS:#{code_text}" unless code_text.nil?
|
60
|
-
new_info[:error].upcase!
|
56
|
+
new_info[:error] = code_text.nil? ? "TWSMS:CODE_NOT_FOUND" : "TWSMS:#{code_text}".upcase
|
61
57
|
end
|
62
58
|
|
63
59
|
new_info
|
data/lib/twsms2/version.rb
CHANGED
data/lib/twsms2.rb
CHANGED
@@ -17,8 +17,7 @@ module Twsms2
|
|
17
17
|
|
18
18
|
def account_is_available
|
19
19
|
balance_info = get_balance
|
20
|
-
|
21
|
-
ok = balance_info[:message_quota] > 0 && balance_info[:access_success]
|
20
|
+
balance_info[:message_quota] > 0 && balance_info[:access_success]
|
22
21
|
end
|
23
22
|
|
24
23
|
def send_message(options={})
|
data/twsms2.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twsms2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guanting Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.5.1
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: 2016 新版 台灣簡訊 TwSMS API ( 純 Ruby / Rails 專案適用 )
|