mitake_sms 1.3.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 +11 -0
- data/README.md +2 -0
- data/lib/mitake_sms/client.rb +46 -22
- 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,17 @@ 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
|
+
|
10
21
|
## [1.3.0] - 2025-05-25
|
11
22
|
### Changed
|
12
23
|
- Removed automatic URL encoding of message content
|
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
@@ -36,15 +36,24 @@ module MitakeSms
|
|
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
38
|
|
39
|
-
|
39
|
+
# Prepare query parameters - all parameters are now sent as query parameters
|
40
|
+
query_params = {
|
40
41
|
username: @config.username,
|
41
42
|
password: @config.password,
|
42
43
|
dstaddr: to,
|
43
44
|
smbody: processed_text,
|
44
45
|
CharsetURL: charset
|
45
46
|
}.merge(options.slice(:from, :response_url, :client_id))
|
46
|
-
|
47
|
-
|
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
|
+
|
48
57
|
handle_response(response)
|
49
58
|
end
|
50
59
|
|
@@ -137,23 +146,32 @@ module MitakeSms
|
|
137
146
|
# @return [MitakeSms::Response] response object
|
138
147
|
def send_batch(batch, charset = 'UTF8', options = {})
|
139
148
|
require 'uri'
|
149
|
+
|
150
|
+
# Prepare the batch message content
|
151
|
+
smbody = batch.map do |msg|
|
152
|
+
to = msg[:to]
|
140
153
|
|
141
|
-
|
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 = {
|
142
163
|
username: @config.username,
|
143
164
|
password: @config.password,
|
144
|
-
smbody:
|
145
|
-
to = msg[:to]
|
146
|
-
|
147
|
-
# Replace any newline characters with ASCII code 6 (ACK)
|
148
|
-
# This is required by the Mitake API to represent line breaks
|
149
|
-
processed_text = msg[:text].to_s.gsub("\n", 6.chr)
|
150
|
-
|
151
|
-
"#{to}:#{processed_text}"
|
152
|
-
end.join("\n"),
|
165
|
+
smbody: smbody,
|
153
166
|
Encoding_PostIn: charset
|
154
167
|
}
|
155
|
-
|
156
|
-
|
168
|
+
|
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
|
+
|
157
175
|
handle_response(response)
|
158
176
|
end
|
159
177
|
|
@@ -164,10 +182,10 @@ module MitakeSms
|
|
164
182
|
# @return [MitakeSms::Response] response object
|
165
183
|
def send_advanced_batch(batch, charset = 'UTF8', options = {})
|
166
184
|
require 'uri'
|
167
|
-
|
185
|
+
|
168
186
|
# Format each message according to the advanced format
|
169
187
|
# ClientID $$ dstaddr $$ dlvtime $$ vldtime $$ destname $$ response $$ smbody
|
170
|
-
|
188
|
+
data = batch.map do |msg|
|
171
189
|
# ClientID is required and must be unique
|
172
190
|
# If not provided, generate a unique ID
|
173
191
|
client_id = msg[:client_id]
|
@@ -180,22 +198,28 @@ module MitakeSms
|
|
180
198
|
vldtime = msg[:vldtime] || ''
|
181
199
|
dest_name = msg[:dest_name] || ''
|
182
200
|
response_url = msg[:response] || ''
|
183
|
-
|
201
|
+
|
184
202
|
# Replace any newline characters in the message text with ASCII code 6 (ACK)
|
185
203
|
# This is required by the Mitake API to represent line breaks within message content
|
186
204
|
processed_text = msg[:text].to_s.gsub("\n", 6.chr)
|
187
|
-
|
205
|
+
|
188
206
|
[client_id, to, dlvtime, vldtime, dest_name, response_url, processed_text].join('$$')
|
189
207
|
end.join("\n")
|
190
208
|
|
191
|
-
|
209
|
+
# All parameters should be sent as query string parameters
|
210
|
+
query_params = {
|
192
211
|
username: @config.username,
|
193
212
|
password: @config.password,
|
194
|
-
data:
|
213
|
+
data: data,
|
195
214
|
Encoding_PostIn: charset
|
196
215
|
}
|
197
216
|
|
198
|
-
|
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
|
+
|
199
223
|
handle_response(response)
|
200
224
|
end
|
201
225
|
|
data/lib/mitake_sms/version.rb
CHANGED