mitake_sms 1.4.0 → 1.5.1

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: bc6252ee1a0e46b2d3b81d7ac1522a97414d9f923836887e3347909b7136d1a7
4
- data.tar.gz: 7feece9cd7334075d6c6c23d5235c272245f656301d6bd3318db87753d5ac70d
3
+ metadata.gz: ce3a09712c7955800b5008e576ca2bc515bee3eb2ef9f8e4f4fa19be4dcc7f39
4
+ data.tar.gz: cc5b846bb58eb1cddfd71b565f448784e9e3acaa3639bb308caf1db8f8bdb6d9
5
5
  SHA512:
6
- metadata.gz: 118431e6c6b70bd7bcbb964b0d8953914def6b4b542e5101f89a4e3c19eddf2e07f930455975f4e9756462b3899f3e3df2d3b252d5abca87c28ad38b6f6a6b55
7
- data.tar.gz: c252b2d7da8b4bf21a63081790582dd3f8e0bf4a956b7d6a4cf9c0f12f1f64ed1164c34186223a1c3206e3d56f797712ee187ebf2cf2e4a6972ec30cc586912f
6
+ metadata.gz: ad51be7878326be0c89a6d1ac81bb66e6e7f9c666375a6b98bac224074a4c599f03f4043a2ff75f9b6e6985a9412a4a9a397f16d6807ea59f223e6bdb390d061
7
+ data.tar.gz: 51c0c4eece86ad4a532e410b8b890ebbc23d5d90b5ea3afe960df86da110054d4d4c5542da7a11a847d8879e0a7f9728d21c6e45a0bb89dc33472b833db6b444
data/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.5.1] - 2025-05-25
11
+ ### Fixed
12
+ - Updated the API URL from `smsapi.mitake.com.tw` to `smsb2c.mitake.com.tw` to match the correct Mitake SMS API endpoint
13
+ - Fixed 404 errors when sending SMS messages
14
+
15
+ ## [1.5.0] - 2025-05-25
16
+ ### Added
17
+ - Added named parameters (keyword arguments) to `send_sms` method for improved readability and flexibility
18
+
19
+ ### Changed
20
+ - Updated `send_sms` method to use named parameters instead of positional parameters
21
+ - Removed `from` parameter from `send_sms` method
22
+ - Updated tests to use named parameters for `send_sms` method
23
+
10
24
  ## [1.4.0] - 2025-05-25
11
25
  ### Changed
12
26
  - Modified all batch SMS parameters to be sent as query string parameters instead of in the POST body
data/README.md CHANGED
@@ -47,7 +47,7 @@ require 'mitake_sms'
47
47
  MitakeSms.configure do |config|
48
48
  config.username = 'your_username' # Your Mitake SMS API username
49
49
  config.password = 'your_password' # Your Mitake SMS API password
50
- config.api_url = 'https://smsapi.mitake.com.tw/b2c/mtk/' # Default API URL
50
+ config.api_url = 'https://smsb2c.mitake.com.tw/b2c/mtk/' # Default API URL
51
51
  end
52
52
  ```
53
53
 
@@ -55,7 +55,7 @@ end
55
55
 
56
56
  ```ruby
57
57
  # Send a simple SMS (uses UTF-8 encoding by default)
58
- response = MitakeSms.send_sms('0912345678', 'Hello, this is a test message!')
58
+ response = MitakeSms.send_sms(to: '0912345678', text: 'Hello, this is a test message!')
59
59
 
60
60
  if response.success?
61
61
  puts "Message sent successfully! Message ID: #{response.message_id}"
@@ -66,9 +66,8 @@ end
66
66
 
67
67
  # With additional options
68
68
  response = MitakeSms.send_sms(
69
- '0912345678',
70
- 'Hello with options!',
71
- from: 'YourBrand',
69
+ to: '0912345678',
70
+ text: 'Hello with options!',
72
71
  response_url: 'https://your-callback-url.com/delivery-reports',
73
72
  client_id: 'your-client-reference-id',
74
73
  charset: 'BIG5' # Override the default UTF-8 encoding if needed
@@ -22,15 +22,18 @@ module MitakeSms
22
22
  # Send a single SMS
23
23
  # @param to [String] recipient phone number
24
24
  # @param text [String] message content
25
- # @param options [Hash] additional options
26
- # @option options [String] :from sender ID
27
- # @option options [String] :response_url callback URL for delivery reports
28
- # @option options [String] :client_id client reference ID
29
- # @option options [String] :charset character encoding, defaults to 'UTF8'
25
+ # @param response_url [String] callback URL for delivery reports (optional)
26
+ # @param client_id [String] client reference ID (optional)
27
+ # @param charset [String] character encoding, defaults to 'UTF8' (optional)
28
+ # @param options [Hash] additional options (optional)
30
29
  # @return [MitakeSms::Response] response object
31
- def send_sms(to, text, options = {})
30
+ def send_sms(to:, text:, response_url: nil, client_id: nil, charset: 'UTF8', **options)
32
31
  require 'uri'
33
- charset = options.delete(:charset) || 'UTF8'
32
+
33
+ # Create options hash with only non-nil values
34
+ param_options = {}
35
+ param_options[:response_url] = response_url if response_url
36
+ param_options[:client_id] = client_id if client_id
34
37
 
35
38
  # Replace any newline characters with ASCII code 6 (ACK)
36
39
  # This is required by the Mitake API to represent line breaks
@@ -43,7 +46,7 @@ module MitakeSms
43
46
  dstaddr: to,
44
47
  smbody: processed_text,
45
48
  CharsetURL: charset
46
- }.merge(options.slice(:from, :response_url, :client_id))
49
+ }.merge(param_options).merge(options)
47
50
 
48
51
  # Construct the endpoint URL
49
52
  endpoint = "SmSend"
@@ -8,48 +8,48 @@ module MitakeSms
8
8
 
9
9
  setting :username, default: ENV['MITAKE_USERNAME']
10
10
  setting :password, default: ENV['MITAKE_PASSWORD']
11
- setting :api_url, default: 'https://smsapi.mitake.com.tw/api/mtk/'
11
+ setting :api_url, default: 'https://smsb2c.mitake.com.tw/b2c/mtk/'
12
12
  setting :timeout, default: 30
13
13
  setting :open_timeout, default: 5
14
-
14
+
15
15
  # Provide direct access to configuration values at the class level
16
16
  class << self
17
17
  def username
18
18
  config.username
19
19
  end
20
-
20
+
21
21
  def username=(value)
22
22
  config.username = value
23
23
  end
24
-
24
+
25
25
  def password
26
26
  config.password
27
27
  end
28
-
28
+
29
29
  def password=(value)
30
30
  config.password = value
31
31
  end
32
-
32
+
33
33
  def api_url
34
34
  config.api_url
35
35
  end
36
-
36
+
37
37
  def api_url=(value)
38
38
  config.api_url = value
39
39
  end
40
-
40
+
41
41
  def timeout
42
42
  config.timeout
43
43
  end
44
-
44
+
45
45
  def timeout=(value)
46
46
  config.timeout = value
47
47
  end
48
-
48
+
49
49
  def open_timeout
50
50
  config.open_timeout
51
51
  end
52
-
52
+
53
53
  def open_timeout=(value)
54
54
  config.open_timeout = value
55
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MitakeSms
4
- VERSION = "1.4.0"
4
+ VERSION = "1.5.1"
5
5
  end
data/lib/mitake_sms.rb CHANGED
@@ -38,15 +38,21 @@ module MitakeSms
38
38
  # Send a single SMS message
39
39
  # @param to [String] recipient phone number
40
40
  # @param text [String] message content
41
- # @param options [Hash] additional options
42
- # @option options [String] :from sender ID
43
- # @option options [String] :response_url callback URL for delivery reports
44
- # @option options [String] :client_id client reference ID
45
- # @option options [String] :charset character encoding, defaults to 'UTF8'
46
-
41
+ # @param response_url [String] callback URL for delivery reports (optional)
42
+ # @param client_id [String] client reference ID (optional)
43
+ # @param charset [String] character encoding, defaults to 'UTF8' (optional)
44
+ # @param options [Hash] additional options (optional)
47
45
  # @return [MitakeSms::Response] response object
48
- def send_sms(to, text, options = {})
49
- client.send_sms(to, text, options)
46
+ def send_sms(to:, text:, response_url: nil, client_id: nil, charset: 'UTF8', **options)
47
+ # Forward all parameters to the client method using named parameters
48
+ client.send_sms(
49
+ to: to,
50
+ text: text,
51
+ response_url: response_url,
52
+ client_id: client_id,
53
+ charset: charset,
54
+ **options
55
+ )
50
56
  end
51
57
 
52
58
  # Send multiple SMS messages in a single request
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.4.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac