mitake_sms 1.5.1 → 1.5.3
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/lib/mitake_sms/client.rb +20 -17
- data/lib/mitake_sms/configuration.rb +1 -1
- data/lib/mitake_sms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69819e16435ee76e99640024557815e7ad6a9854c4bcdcea982b0fcd330c85e3
|
4
|
+
data.tar.gz: fdb94f92929b03ca298d86ea6babaa38910bf266c6bfb8870f281ababa773068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6ecaef16af836d259dbcdc16e0a34d02fd3a1a5705803827bcef72c70ebc0639502a1eff273182205f1e141200cd307e01550903aec4a52ef9979eed767e452
|
7
|
+
data.tar.gz: 93f2a41050e17e6c4f2abcede74f4a3877252e20533a89d7612c39ee39bdf381408da0a214218f31f4b581e466f268085e28f3824ba4008896cc280a1d869ef2
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [1.5.3] - 2025-05-25
|
11
|
+
### Changed
|
12
|
+
- Updated the default API URL to `https://smsapi.mitake.com.tw/api/mtk/`
|
13
|
+
- Cleaned up whitespace in the codebase
|
14
|
+
|
15
|
+
## [1.5.2] - 2025-05-25
|
16
|
+
### Changed
|
17
|
+
- Modified `send_sms` method to keep only `CharsetURL` in query string and put all other parameters in POST body
|
18
|
+
- Updated tests to match the new parameter structure
|
19
|
+
|
10
20
|
## [1.5.1] - 2025-05-25
|
11
21
|
### Fixed
|
12
22
|
- Updated the API URL from `smsapi.mitake.com.tw` to `smsb2c.mitake.com.tw` to match the correct Mitake SMS API endpoint
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ require 'mitake_sms'
|
|
47
47
|
MitakeSms.configure do |config|
|
48
48
|
config.username = 'your_username' # Your Mitake SMS API username
|
49
49
|
config.password = 'your_password' # Your Mitake SMS API password
|
50
|
-
config.api_url = 'https://
|
50
|
+
config.api_url = 'https://smsapi.mitake.com.tw/api/mtk/' # Default API URL
|
51
51
|
end
|
52
52
|
```
|
53
53
|
|
data/lib/mitake_sms/client.rb
CHANGED
@@ -29,7 +29,7 @@ module MitakeSms
|
|
29
29
|
# @return [MitakeSms::Response] response object
|
30
30
|
def send_sms(to:, text:, response_url: nil, client_id: nil, charset: 'UTF8', **options)
|
31
31
|
require 'uri'
|
32
|
-
|
32
|
+
|
33
33
|
# Create options hash with only non-nil values
|
34
34
|
param_options = {}
|
35
35
|
param_options[:response_url] = response_url if response_url
|
@@ -39,24 +39,27 @@ module MitakeSms
|
|
39
39
|
# This is required by the Mitake API to represent line breaks
|
40
40
|
processed_text = text.to_s.gsub("\n", 6.chr)
|
41
41
|
|
42
|
-
# Prepare query parameters -
|
42
|
+
# Prepare query parameters - only CharsetURL is sent as query parameter
|
43
43
|
query_params = {
|
44
|
+
CharsetURL: charset
|
45
|
+
}
|
46
|
+
|
47
|
+
# Prepare form parameters - all other parameters are sent in the POST body
|
48
|
+
form_params = {
|
44
49
|
username: @config.username,
|
45
50
|
password: @config.password,
|
46
51
|
dstaddr: to,
|
47
|
-
smbody: processed_text
|
48
|
-
CharsetURL: charset
|
52
|
+
smbody: processed_text
|
49
53
|
}.merge(param_options).merge(options)
|
50
|
-
|
54
|
+
|
51
55
|
# Construct the endpoint URL
|
52
56
|
endpoint = "SmSend"
|
53
|
-
|
57
|
+
|
54
58
|
response = @connection.post(endpoint) do |req|
|
55
59
|
req.params = query_params
|
56
|
-
|
57
|
-
req.body = {}
|
60
|
+
req.body = form_params
|
58
61
|
end
|
59
|
-
|
62
|
+
|
60
63
|
handle_response(response)
|
61
64
|
end
|
62
65
|
|
@@ -149,7 +152,7 @@ module MitakeSms
|
|
149
152
|
# @return [MitakeSms::Response] response object
|
150
153
|
def send_batch(batch, charset = 'UTF8', options = {})
|
151
154
|
require 'uri'
|
152
|
-
|
155
|
+
|
153
156
|
# Prepare the batch message content
|
154
157
|
smbody = batch.map do |msg|
|
155
158
|
to = msg[:to]
|
@@ -160,7 +163,7 @@ module MitakeSms
|
|
160
163
|
|
161
164
|
"#{to}:#{processed_text}"
|
162
165
|
end.join("\n")
|
163
|
-
|
166
|
+
|
164
167
|
# All parameters should be sent as query string parameters
|
165
168
|
query_params = {
|
166
169
|
username: @config.username,
|
@@ -168,13 +171,13 @@ module MitakeSms
|
|
168
171
|
smbody: smbody,
|
169
172
|
Encoding_PostIn: charset
|
170
173
|
}
|
171
|
-
|
174
|
+
|
172
175
|
# Use empty body with all parameters in query string
|
173
176
|
response = @connection.post('SmBulkSend') do |req|
|
174
177
|
req.params = query_params
|
175
178
|
req.body = {}
|
176
179
|
end
|
177
|
-
|
180
|
+
|
178
181
|
handle_response(response)
|
179
182
|
end
|
180
183
|
|
@@ -185,7 +188,7 @@ module MitakeSms
|
|
185
188
|
# @return [MitakeSms::Response] response object
|
186
189
|
def send_advanced_batch(batch, charset = 'UTF8', options = {})
|
187
190
|
require 'uri'
|
188
|
-
|
191
|
+
|
189
192
|
# Format each message according to the advanced format
|
190
193
|
# ClientID $$ dstaddr $$ dlvtime $$ vldtime $$ destname $$ response $$ smbody
|
191
194
|
data = batch.map do |msg|
|
@@ -201,11 +204,11 @@ module MitakeSms
|
|
201
204
|
vldtime = msg[:vldtime] || ''
|
202
205
|
dest_name = msg[:dest_name] || ''
|
203
206
|
response_url = msg[:response] || ''
|
204
|
-
|
207
|
+
|
205
208
|
# Replace any newline characters in the message text with ASCII code 6 (ACK)
|
206
209
|
# This is required by the Mitake API to represent line breaks within message content
|
207
210
|
processed_text = msg[:text].to_s.gsub("\n", 6.chr)
|
208
|
-
|
211
|
+
|
209
212
|
[client_id, to, dlvtime, vldtime, dest_name, response_url, processed_text].join('$$')
|
210
213
|
end.join("\n")
|
211
214
|
|
@@ -222,7 +225,7 @@ module MitakeSms
|
|
222
225
|
req.params = query_params
|
223
226
|
req.body = {}
|
224
227
|
end
|
225
|
-
|
228
|
+
|
226
229
|
handle_response(response)
|
227
230
|
end
|
228
231
|
|
@@ -8,7 +8,7 @@ module MitakeSms
|
|
8
8
|
|
9
9
|
setting :username, default: ENV['MITAKE_USERNAME']
|
10
10
|
setting :password, default: ENV['MITAKE_PASSWORD']
|
11
|
-
setting :api_url, default: 'https://
|
11
|
+
setting :api_url, default: 'https://smsapi.mitake.com.tw/api/mtk/'
|
12
12
|
setting :timeout, default: 30
|
13
13
|
setting :open_timeout, default: 5
|
14
14
|
|
data/lib/mitake_sms/version.rb
CHANGED