mitake_sms 1.4.0 → 1.5.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: bc6252ee1a0e46b2d3b81d7ac1522a97414d9f923836887e3347909b7136d1a7
4
- data.tar.gz: 7feece9cd7334075d6c6c23d5235c272245f656301d6bd3318db87753d5ac70d
3
+ metadata.gz: 7b8e4f3f9a2745fa7633cb7df508a09c1c639d1d55935ae9b5b77b5102535f70
4
+ data.tar.gz: 10e11540186c4f9a52f0f178c516dfe94ae407d752f97779596f650403638462
5
5
  SHA512:
6
- metadata.gz: 118431e6c6b70bd7bcbb964b0d8953914def6b4b542e5101f89a4e3c19eddf2e07f930455975f4e9756462b3899f3e3df2d3b252d5abca87c28ad38b6f6a6b55
7
- data.tar.gz: c252b2d7da8b4bf21a63081790582dd3f8e0bf4a956b7d6a4cf9c0f12f1f64ed1164c34186223a1c3206e3d56f797712ee187ebf2cf2e4a6972ec30cc586912f
6
+ metadata.gz: f49f9b77f286f86c21e0439bd0f78799d788e8abab1ddfe3c6b3f52679cd0e978e25a3344a22d55a262b46767864af0969ae4569e6a3789e4ebcb119149bf45f
7
+ data.tar.gz: 624ffd3d41a925bc2a6ee287f0e4ca5f00cc9e5ba0f30e3cb6d98c4fd2ec26b260066620884642e92cb22e756c07f78126d7c8006828af01b54705edd67d138c
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
+ ## [1.5.0] - 2025-05-25
11
+ ### Added
12
+ - Added named parameters (keyword arguments) to `send_sms` method for improved readability and flexibility
13
+
14
+ ### Changed
15
+ - Updated `send_sms` method to use named parameters instead of positional parameters
16
+ - Removed `from` parameter from `send_sms` method
17
+ - Updated tests to use named parameters for `send_sms` method
18
+
10
19
  ## [1.4.0] - 2025-05-25
11
20
  ### Changed
12
21
  - Modified all batch SMS parameters to be sent as query string parameters instead of in the POST body
data/README.md CHANGED
@@ -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://smsapi.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.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac