mitake_sms 1.5.1 → 1.5.2

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: ce3a09712c7955800b5008e576ca2bc515bee3eb2ef9f8e4f4fa19be4dcc7f39
4
- data.tar.gz: cc5b846bb58eb1cddfd71b565f448784e9e3acaa3639bb308caf1db8f8bdb6d9
3
+ metadata.gz: ed3ca4ddde2280f9eaf8eab941bc8dd7cce15e286961626c02b969c13c1c039c
4
+ data.tar.gz: f5f8b5dcef17f97f029f05c29a24f87904a3d7a13b8a42e850f769a5978858af
5
5
  SHA512:
6
- metadata.gz: ad51be7878326be0c89a6d1ac81bb66e6e7f9c666375a6b98bac224074a4c599f03f4043a2ff75f9b6e6985a9412a4a9a397f16d6807ea59f223e6bdb390d061
7
- data.tar.gz: 51c0c4eece86ad4a532e410b8b890ebbc23d5d90b5ea3afe960df86da110054d4d4c5542da7a11a847d8879e0a7f9728d21c6e45a0bb89dc33472b833db6b444
6
+ metadata.gz: 679340eb268bf398b4e3971eb042ff983e941ba422b4112a1cb6c27c5fa91d920f6050d220c7ee945359bdb6cc1df1147d424077246192bd5fd0d791ab049450
7
+ data.tar.gz: 318696e9d93e918b13b1e2ef98bad3d14f35818b32240f35c82ea6ad4f98e967c69613bccb96f77a7915348afed27e14d71da6d41a1aa2c76648279610277839
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.5.2] - 2025-05-25
11
+ ### Changed
12
+ - Modified `send_sms` method to keep only `CharsetURL` in query string and put all other parameters in POST body
13
+ - Updated tests to match the new parameter structure
14
+
10
15
  ## [1.5.1] - 2025-05-25
11
16
  ### Fixed
12
17
  - Updated the API URL from `smsapi.mitake.com.tw` to `smsb2c.mitake.com.tw` to match the correct Mitake SMS API endpoint
@@ -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 - all parameters are now sent as 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
- # Empty body since all parameters are in the query string
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MitakeSms
4
- VERSION = "1.5.1"
4
+ VERSION = "1.5.2"
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.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac