mitake_sms 1.2.0 → 1.4.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 +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +2 -0
- data/lib/mitake_sms/client.rb +45 -33
- 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: bc6252ee1a0e46b2d3b81d7ac1522a97414d9f923836887e3347909b7136d1a7
|
4
|
+
data.tar.gz: 7feece9cd7334075d6c6c23d5235c272245f656301d6bd3318db87753d5ac70d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 118431e6c6b70bd7bcbb964b0d8953914def6b4b542e5101f89a4e3c19eddf2e07f930455975f4e9756462b3899f3e3df2d3b252d5abca87c28ad38b6f6a6b55
|
7
|
+
data.tar.gz: c252b2d7da8b4bf21a63081790582dd3f8e0bf4a956b7d6a4cf9c0f12f1f64ed1164c34186223a1c3206e3d56f797712ee187ebf2cf2e4a6972ec30cc586912f
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [1.4.0] - 2025-05-25
|
11
|
+
### Changed
|
12
|
+
- Modified all batch SMS parameters to be sent as query string parameters instead of in the POST body
|
13
|
+
- Updated `send_batch` and `send_advanced_batch` methods to use query string parameters
|
14
|
+
- Modified tests to verify query string parameter handling for batch SMS
|
15
|
+
|
16
|
+
## [1.3.1] - 2025-05-25
|
17
|
+
### Changed
|
18
|
+
- Modified `CharsetURL` parameter to be sent as a query string parameter instead of a form parameter
|
19
|
+
- Updated tests to verify query string parameter handling
|
20
|
+
|
21
|
+
## [1.3.0] - 2025-05-25
|
22
|
+
### Changed
|
23
|
+
- Removed automatic URL encoding of message content
|
24
|
+
- Simplified message handling by only converting newlines to ASCII code 6
|
25
|
+
- Modified tests to match the updated implementation
|
26
|
+
|
10
27
|
## [1.2.0] - 2025-05-25
|
11
28
|
### Added
|
12
29
|
- Added proper handling of newlines in message text (converts to ASCII code 6)
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# MitakeSms
|
2
2
|
|
3
3
|
[](https://codecov.io/gh/7a6163/mitake_sms)
|
4
|
+

|
5
|
+
|
4
6
|
|
5
7
|
A Ruby client for the Mitake SMS API, providing a simple and efficient way to send SMS messages through the Mitake SMS service.
|
6
8
|
|
data/lib/mitake_sms/client.rb
CHANGED
@@ -31,24 +31,29 @@ module MitakeSms
|
|
31
31
|
def send_sms(to, text, options = {})
|
32
32
|
require 'uri'
|
33
33
|
charset = options.delete(:charset) || 'UTF8'
|
34
|
-
|
34
|
+
|
35
35
|
# Replace any newline characters with ASCII code 6 (ACK)
|
36
36
|
# This is required by the Mitake API to represent line breaks
|
37
37
|
processed_text = text.to_s.gsub("\n", 6.chr)
|
38
|
-
|
39
|
-
# URL encode the message content to handle special characters like '&'
|
40
|
-
# This is required by the Mitake API
|
41
|
-
message_text = URI.encode_www_form_component(processed_text)
|
42
38
|
|
43
|
-
|
39
|
+
# Prepare query parameters - all parameters are now sent as query parameters
|
40
|
+
query_params = {
|
44
41
|
username: @config.username,
|
45
42
|
password: @config.password,
|
46
43
|
dstaddr: to,
|
47
|
-
smbody:
|
44
|
+
smbody: processed_text,
|
48
45
|
CharsetURL: charset
|
49
46
|
}.merge(options.slice(:from, :response_url, :client_id))
|
50
|
-
|
51
|
-
|
47
|
+
|
48
|
+
# Construct the endpoint URL
|
49
|
+
endpoint = "SmSend"
|
50
|
+
|
51
|
+
response = @connection.post(endpoint) do |req|
|
52
|
+
req.params = query_params
|
53
|
+
# Empty body since all parameters are in the query string
|
54
|
+
req.body = {}
|
55
|
+
end
|
56
|
+
|
52
57
|
handle_response(response)
|
53
58
|
end
|
54
59
|
|
@@ -142,26 +147,31 @@ module MitakeSms
|
|
142
147
|
def send_batch(batch, charset = 'UTF8', options = {})
|
143
148
|
require 'uri'
|
144
149
|
|
145
|
-
|
150
|
+
# Prepare the batch message content
|
151
|
+
smbody = batch.map do |msg|
|
152
|
+
to = msg[:to]
|
153
|
+
|
154
|
+
# Replace any newline characters with ASCII code 6 (ACK)
|
155
|
+
# This is required by the Mitake API to represent line breaks
|
156
|
+
processed_text = msg[:text].to_s.gsub("\n", 6.chr)
|
157
|
+
|
158
|
+
"#{to}:#{processed_text}"
|
159
|
+
end.join("\n")
|
160
|
+
|
161
|
+
# All parameters should be sent as query string parameters
|
162
|
+
query_params = {
|
146
163
|
username: @config.username,
|
147
164
|
password: @config.password,
|
148
|
-
smbody:
|
149
|
-
to = msg[:to]
|
150
|
-
|
151
|
-
# Replace any newline characters with ASCII code 6 (ACK)
|
152
|
-
# This is required by the Mitake API to represent line breaks
|
153
|
-
processed_text = msg[:text].to_s.gsub("\n", 6.chr)
|
154
|
-
|
155
|
-
# URL encode the message content to handle special characters like '&'
|
156
|
-
# This is required by the Mitake API
|
157
|
-
message_text = URI.encode_www_form_component(processed_text)
|
158
|
-
|
159
|
-
"#{to}:#{message_text}"
|
160
|
-
end.join("\n"),
|
165
|
+
smbody: smbody,
|
161
166
|
Encoding_PostIn: charset
|
162
167
|
}
|
163
168
|
|
164
|
-
|
169
|
+
# Use empty body with all parameters in query string
|
170
|
+
response = @connection.post('SmBulkSend') do |req|
|
171
|
+
req.params = query_params
|
172
|
+
req.body = {}
|
173
|
+
end
|
174
|
+
|
165
175
|
handle_response(response)
|
166
176
|
end
|
167
177
|
|
@@ -175,7 +185,7 @@ module MitakeSms
|
|
175
185
|
|
176
186
|
# Format each message according to the advanced format
|
177
187
|
# ClientID $$ dstaddr $$ dlvtime $$ vldtime $$ destname $$ response $$ smbody
|
178
|
-
|
188
|
+
data = batch.map do |msg|
|
179
189
|
# ClientID is required and must be unique
|
180
190
|
# If not provided, generate a unique ID
|
181
191
|
client_id = msg[:client_id]
|
@@ -193,21 +203,23 @@ module MitakeSms
|
|
193
203
|
# This is required by the Mitake API to represent line breaks within message content
|
194
204
|
processed_text = msg[:text].to_s.gsub("\n", 6.chr)
|
195
205
|
|
196
|
-
|
197
|
-
# This is required by the Mitake API
|
198
|
-
text = URI.encode_www_form_component(processed_text)
|
199
|
-
|
200
|
-
[client_id, to, dlvtime, vldtime, dest_name, response_url, text].join('$$')
|
206
|
+
[client_id, to, dlvtime, vldtime, dest_name, response_url, processed_text].join('$$')
|
201
207
|
end.join("\n")
|
202
208
|
|
203
|
-
|
209
|
+
# All parameters should be sent as query string parameters
|
210
|
+
query_params = {
|
204
211
|
username: @config.username,
|
205
212
|
password: @config.password,
|
206
|
-
data:
|
213
|
+
data: data,
|
207
214
|
Encoding_PostIn: charset
|
208
215
|
}
|
209
216
|
|
210
|
-
|
217
|
+
# Use empty body with all parameters in query string
|
218
|
+
response = @connection.post('SmPost') do |req|
|
219
|
+
req.params = query_params
|
220
|
+
req.body = {}
|
221
|
+
end
|
222
|
+
|
211
223
|
handle_response(response)
|
212
224
|
end
|
213
225
|
|
data/lib/mitake_sms/version.rb
CHANGED