mitake_sms 1.6.0 → 2.0.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 +9 -0
- data/README.md +6 -6
- data/lib/mitake_sms/client.rb +22 -9
- data/lib/mitake_sms/version.rb +1 -1
- data/lib/mitake_sms.rb +0 -9
- 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: 39775d8249e44177aa4d89da4716abc178ccd834e6c653549389a419f305d08c
|
4
|
+
data.tar.gz: c47d00857751465b785cfe5da97b858b7c78722a8f65fd81d6e965de06541730
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04bea4cc56b8294f4e5ecc6667a6378ed49bc13221c4766e6b3102421ad598b118d0793bdf7cf900340013fcfe83484f6b64b75d55c1f2e508330c7aef26c49c
|
7
|
+
data.tar.gz: df170765544707a1b51ee0240811f4b379211f146725504d5b496c41792be713f13cf86ed4565689d51f2d09510f1b0a6df72a43512753bdc901fdb632402a38
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [2.0.0] - 2025-05-26
|
11
|
+
### Changed
|
12
|
+
- Modified `send_batch` method to use the advanced format with $$ separators
|
13
|
+
- Updated batch SMS request to place data in the request body with 'text/plain' content type
|
14
|
+
- Updated tests to verify the new batch SMS request format
|
15
|
+
|
16
|
+
### Removed
|
17
|
+
- Removed `advanced_batch_send_with_limit` method to simplify the API surface
|
18
|
+
|
10
19
|
## [1.6.0] - 2025-05-25
|
11
20
|
### Added
|
12
21
|
- Added `destname` parameter to `send_sms` method for recipient name or system integration key value
|
data/README.md
CHANGED
@@ -141,9 +141,9 @@ responses.each_with_index do |batch_response, index|
|
|
141
141
|
end
|
142
142
|
```
|
143
143
|
|
144
|
-
### Sending Advanced Format
|
144
|
+
### Sending Batch SMS with Advanced Format
|
145
145
|
|
146
|
-
The advanced format
|
146
|
+
The batch_send method now uses the advanced format by default, which provides more control over each message in the batch, including scheduled delivery, validity period, recipient name, and more:
|
147
147
|
|
148
148
|
```ruby
|
149
149
|
# Create messages with advanced options
|
@@ -153,8 +153,8 @@ messages = [
|
|
153
153
|
to: '0912345678', # Required recipient phone number
|
154
154
|
dlvtime: '20250526120000', # Optional delivery time (YYYYMMDDhhmmss)
|
155
155
|
vldtime: '20250527120000', # Optional validity period (YYYYMMDDhhmmss)
|
156
|
-
|
157
|
-
|
156
|
+
destname: '大寶', # Optional recipient name
|
157
|
+
response_url: 'https://callback.url', # Optional callback URL
|
158
158
|
text: '這是一則測試簡訊' # Required message content
|
159
159
|
},
|
160
160
|
{
|
@@ -178,8 +178,8 @@ messages = [
|
|
178
178
|
# - Long messages will be automatically split into multiple SMS messages if your account doesn't
|
179
179
|
# have long message permissions
|
180
180
|
|
181
|
-
# Send using
|
182
|
-
response = MitakeSms.
|
181
|
+
# Send using batch_send (automatically handles the advanced format)
|
182
|
+
response = MitakeSms.batch_send(messages)
|
183
183
|
|
184
184
|
# Process response similar to regular batch sending
|
185
185
|
if response.is_a?(MitakeSms::Response) && response.success?
|
data/lib/mitake_sms/client.rb
CHANGED
@@ -155,29 +155,42 @@ module MitakeSms
|
|
155
155
|
def send_batch(batch, charset = 'UTF8', options = {})
|
156
156
|
require 'uri'
|
157
157
|
|
158
|
-
#
|
159
|
-
|
158
|
+
# Format each message according to the advanced format
|
159
|
+
# ClientID $$ dstaddr $$ dlvtime $$ vldtime $$ destname $$ response $$ smbody
|
160
|
+
data = batch.map do |msg|
|
161
|
+
# ClientID is required and must be unique
|
162
|
+
# If not provided, generate a unique ID
|
163
|
+
client_id = msg[:client_id]
|
164
|
+
if client_id.nil? || client_id.empty?
|
165
|
+
client_id = generate_unique_client_id
|
166
|
+
end
|
167
|
+
|
160
168
|
to = msg[:to]
|
169
|
+
dlvtime = msg[:dlvtime] || ''
|
170
|
+
vldtime = msg[:vldtime] || ''
|
171
|
+
dest_name = msg[:destname] || ''
|
172
|
+
response_url = msg[:response_url] || ''
|
161
173
|
|
162
|
-
# Replace any newline characters with ASCII code 6 (ACK)
|
163
|
-
# This is required by the Mitake API to represent line breaks
|
174
|
+
# Replace any newline characters in the message text with ASCII code 6 (ACK)
|
175
|
+
# This is required by the Mitake API to represent line breaks within message content
|
164
176
|
processed_text = msg[:text].to_s.gsub("\n", 6.chr)
|
165
177
|
|
166
|
-
|
178
|
+
# Format according to API documentation: ClientID $$ dstaddr $$ dlvtime $$ vldtime $$ destname $$ response $$ smbody
|
179
|
+
[client_id, to, dlvtime, vldtime, dest_name, response_url, processed_text].join('$$')
|
167
180
|
end.join("\n")
|
168
181
|
|
169
|
-
#
|
182
|
+
# Parameters for the request
|
170
183
|
query_params = {
|
171
184
|
username: @config.username,
|
172
185
|
password: @config.password,
|
173
|
-
smbody: smbody,
|
174
186
|
Encoding_PostIn: charset
|
175
187
|
}
|
176
188
|
|
177
|
-
#
|
189
|
+
# According to the API documentation, the data should be in the request body
|
178
190
|
response = @connection.post('SmBulkSend') do |req|
|
179
191
|
req.params = query_params
|
180
|
-
req.body =
|
192
|
+
req.body = data
|
193
|
+
req.headers['Content-Type'] = 'text/plain'
|
181
194
|
end
|
182
195
|
|
183
196
|
handle_response(response)
|
data/lib/mitake_sms/version.rb
CHANGED
data/lib/mitake_sms.rb
CHANGED
@@ -100,15 +100,6 @@ module MitakeSms
|
|
100
100
|
client.advanced_batch_send(messages, options)
|
101
101
|
end
|
102
102
|
|
103
|
-
# Send multiple SMS messages in a single request with a limit per request using advanced format
|
104
|
-
# @param messages [Array<Hash>] array of message hashes with advanced options
|
105
|
-
# @param limit [Integer] maximum number of messages per request (default: 500)
|
106
|
-
# @param options [Hash] additional options
|
107
|
-
# @option options [String] :charset character encoding, defaults to 'UTF8'
|
108
103
|
|
109
|
-
# @return [MitakeSms::Response, Array<MitakeSms::Response>] response object or array of response objects if batch was split
|
110
|
-
def advanced_batch_send_with_limit(messages, limit = 500, options = {})
|
111
|
-
client.advanced_batch_send_with_limit(messages, limit, options)
|
112
|
-
end
|
113
104
|
end
|
114
105
|
end
|