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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42774c4aed1ba07e126a7023b8e2baedf85dc25e53bbeafc4739cff39765d0b3
4
- data.tar.gz: 978e2c9b36e5cc2a2b79ad6f05b90f360f49c8930f50c5131851eb170a10aaf3
3
+ metadata.gz: bc6252ee1a0e46b2d3b81d7ac1522a97414d9f923836887e3347909b7136d1a7
4
+ data.tar.gz: 7feece9cd7334075d6c6c23d5235c272245f656301d6bd3318db87753d5ac70d
5
5
  SHA512:
6
- metadata.gz: '0859b813573741a6ff71f8339c1a56bb4c625a6acdb0f861b1f2407a5981fce7619cd70580301558b0bac4e682350ccbb6ffb9e35b7a8ff30f45f3f6e80c4992'
7
- data.tar.gz: 350a37d091491be985e03b736b39ea999e28edf7a90eb5edc378a0119719a343eb3aeb6f4d558a17e1ea9bdb233d886e8aba585f38f1894b62d46f8500c03b30
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
  [![codecov](https://codecov.io/gh/7a6163/mitake_sms/graph/badge.svg?token=QNRP1N3TOP)](https://codecov.io/gh/7a6163/mitake_sms)
4
+ ![Gem Version](https://img.shields.io/gem/v/mitake_sms)
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
 
@@ -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
- params = {
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
- response = @connection.post('SmSend', params)
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
- params = {
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: batch.map do |msg|
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
- response = @connection.post('SmBulkSend', params)
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
- body = batch.map do |msg|
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
- params = {
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: body,
213
+ data: data,
195
214
  Encoding_PostIn: charset
196
215
  }
197
216
 
198
- response = @connection.post('SmPost', params)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MitakeSms
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mitake_sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac