luosimao-sms 0.1.0 → 0.1.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: 4b04f880e4d7bb95c53ca54950ddcb29a2c7e7780a8bcc1674d379812d957c59
4
- data.tar.gz: d32d0083600b86cdeef688b06ff7d345f9928ed95fd64cf809dff474c4367091
3
+ metadata.gz: 594494c09ac0b6b45af894d922c67fe08216b0226be0c68bb128a6fb778756b6
4
+ data.tar.gz: 5d1fc0bed22b7bb81f59199e20da97411ee79e070f02ad026be8e443409780ec
5
5
  SHA512:
6
- metadata.gz: dcf71f6970bda2685bc21baf2dfd4955fdf1f1ef33a28dd1587a16ca08760e1c13c7035493701aae9034802bd7efad1b524ed3fff9e33f36d45431862f5a31e6
7
- data.tar.gz: 2181349a2b92bc23e455b8e17548916903187ce7fc04e2fd33f0ca318cf322e91b721c891bc9b9ddaf54c5c5b49d129507a45c8b25cdad2ffdf247cf92887bdb
6
+ metadata.gz: 79d6a256e7754ea309eb869d6d61c4895ac5f25d0773d64b0edbac7b321b59a0238cd3c2ac09d2f8eb2b2e038a932e38b0ecf53f7ff49733abd4292aea4b4882
7
+ data.tar.gz: 663a2b0304b508024a6be497d58d702cf82888fa0c02d2705cbb6e81b52057e126205172ee73ea962590cf2589c7b2d2ccb61bb8b3afa7334baf67065badc05d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.1.1] - 2026-03-29
6
+ ### Fixed
7
+ - Corrected `homepage` URL in gemspec to match the actual GitHub repository.
8
+
5
9
  ## [0.1.0] - 2026-03-29
6
10
  ### Added
7
11
  - Initial release of `luosimao-sms` gem.
data/README.md CHANGED
@@ -1,30 +1,27 @@
1
1
  # Luosimao SMS Ruby SDK
2
2
 
3
+ [![Gem Version](https://img.shields.io/gem/v/luosimao-sms)](https://rubygems.org/gems/luosimao-sms)
4
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+
6
+ A Ruby SDK for sending SMS via the [Luosimao](https://luosimao.com) API. Integrates seamlessly with your Ruby/Rails application.
7
+
3
8
  [English](#english) | [中文](#chinese)
4
9
 
10
+ ---
11
+
5
12
  <a id="english"></a>
6
13
  ## English
7
14
 
8
- A Ruby SDK for sending SMS via the [Luosimao](https://luosimao.com) API.
9
-
10
15
  ### Installation
11
16
 
12
- Add this line to your application's Gemfile:
13
-
14
- ```ruby
15
- gem 'luosimao-sms'
16
- ```
17
-
18
- And then execute:
19
-
20
17
  ```bash
21
- $ bundle install
18
+ gem install luosimao-sms
22
19
  ```
23
20
 
24
- Or install it yourself as:
21
+ Or add to your `Gemfile`:
25
22
 
26
- ```bash
27
- $ gem install luosimao-sms
23
+ ```ruby
24
+ gem 'luosimao-sms'
28
25
  ```
29
26
 
30
27
  ### Quick Start
@@ -34,65 +31,77 @@ require 'luosimao-sms'
34
31
 
35
32
  client = Luosimao::SMS::Client.new(api_key: 'your_api_key')
36
33
 
37
- # Send SMS
34
+ # Send a single SMS
38
35
  response = client.send(mobile: '13800138000', message: 'Verification code 123456【Your Company】')
39
36
  puts response.success?
40
37
 
41
- # Batch Send SMS
38
+ # Batch send
42
39
  response = client.send_batch(
43
40
  mobiles: ['13800138000', '13800138001'],
44
- message: 'Batch message【Your Company】'
41
+ message: 'Notification content【Your Company】'
45
42
  )
46
43
 
47
- # Check Balance
44
+ # Check balance
48
45
  status = client.status
49
- puts status.deposit
46
+ puts "Balance: #{status.deposit} messages"
50
47
  ```
51
48
 
52
49
  ### Configuration
53
50
 
54
- You can configure the client with optional parameters:
55
-
56
51
  ```ruby
57
52
  client = Luosimao::SMS::Client.new(
58
- api_key: 'your_api_key',
59
- timeout: 10, # Read timeout in seconds (default: 30)
60
- open_timeout: 5, # Connection timeout in seconds (default: 10)
61
- base_url: 'https://sms-api.luosimao.com' # API base URL
53
+ api_key: 'your_api_key', # Required. Auto-adds 'key-' prefix if omitted.
54
+ timeout: 10, # Read timeout in seconds (default: 30).
55
+ open_timeout: 5, # Connection timeout in seconds (default: 10).
56
+ base_url: 'https://sms-api.luosimao.com' # For testing purposes.
62
57
  )
63
58
  ```
64
59
 
65
- The `api_key` can be provided with or without the `key-` prefix.
66
-
67
60
  ### API Reference
68
61
 
69
- #### `client.send(mobile:, message:)`
70
- Sends a single SMS message. Returns `Luosimao::SMS::Response`. Raises `Luosimao::SMS::APIError` on API failure.
62
+ | Method | Description |
63
+ |--------|-------------|
64
+ | `client.send(mobile:, message:)` | Send a single SMS. Returns `Luosimao::SMS::Response`. |
65
+ | `client.send_batch(mobiles:, message:, send_at: nil)` | Batch send. `send_at` accepts a `Time` object for scheduled delivery. |
66
+ | `client.status` | Query account balance. Returns `Luosimao::SMS::StatusResponse`. |
71
67
 
72
- #### `client.send_batch(mobiles:, message:, send_at: nil)`
73
- Sends a batch SMS message. Returns `Luosimao::SMS::Response`.
68
+ ### Error Handling
74
69
 
75
- #### `client.status`
76
- Queries the account balance. Returns `Luosimao::SMS::StatusResponse`.
70
+ | Exception | Description | Helper Methods |
71
+ |-----------|-------------|----------------|
72
+ | `Luosimao::SMS::APIError` | API returned an error code. | `auth_failed?`, `insufficient_balance?`, `sensitive_words?`, `ip_not_allowed?` |
73
+ | `Luosimao::SMS::NetworkError` | Network failure (timeout, connection refused, invalid JSON). | - |
74
+ | `Luosimao::SMS::ArgumentError` | Invalid method arguments. | - |
77
75
 
78
- ### Error Handling
76
+ Example:
79
77
 
80
- The SDK raises errors on failure:
81
- - `Luosimao::SMS::APIError`: API returned an error code. You can check specific errors via methods like `auth_failed?`, `insufficient_balance?`, `sensitive_words?`, `ip_not_allowed?`.
82
- - `Luosimao::SMS::NetworkError`: Network-related errors (timeout, connection refused).
83
- - `Luosimao::SMS::ArgumentError`: Invalid arguments provided.
78
+ ```ruby
79
+ begin
80
+ client.send(mobile: '13800138000', message: 'Verification code 123456【Company】')
81
+ rescue Luosimao::SMS::APIError => e
82
+ puts "API Error [#{e.code}]: #{e.message}"
83
+ puts "Insufficient balance!" if e.insufficient_balance?
84
+ rescue Luosimao::SMS::NetworkError => e
85
+ puts "Network error: #{e.message}"
86
+ end
87
+ ```
84
88
 
85
89
  ### Development
86
90
 
87
- After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rspec` to run the tests.
91
+ ```bash
92
+ git clone https://github.com/luosimao-oss/luosimao-sms-ruby.git
93
+ cd luosimao-sms
94
+ bundle install
95
+ bundle exec rspec
96
+ ```
88
97
 
89
98
  ### Contributing
90
99
 
91
- Bug reports and pull requests are welcome on GitHub at https://github.com/luosimao-oss/luosimao-sms-ruby.
100
+ Contributions are welcome! Please feel free to submit a Pull Request.
92
101
 
93
102
  ### License
94
103
 
95
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
104
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
96
105
 
97
106
  ---
98
107
 
@@ -101,27 +110,19 @@ The gem is available as open source under the terms of the [MIT License](https:/
101
110
 
102
111
  螺丝帽 (Luosimao) 短信服务的 Ruby SDK。
103
112
 
104
- ### Installation(安装)
105
-
106
- 将以下代码添加到你的 `Gemfile`:
107
-
108
- ```ruby
109
- gem 'luosimao-sms'
110
- ```
111
-
112
- 然后执行:
113
+ ### 安装
113
114
 
114
115
  ```bash
115
- $ bundle install
116
+ gem install luosimao-sms
116
117
  ```
117
118
 
118
- 或者直接安装:
119
+ 或在 `Gemfile` 中添加:
119
120
 
120
- ```bash
121
- $ gem install luosimao-sms
121
+ ```ruby
122
+ gem 'luosimao-sms'
122
123
  ```
123
124
 
124
- ### Quick Start(快速开始)
125
+ ### 快速开始
125
126
 
126
127
  ```ruby
127
128
  require 'luosimao-sms'
@@ -140,50 +141,62 @@ response = client.send_batch(
140
141
 
141
142
  # 查询余额
142
143
  status = client.status
143
- puts status.deposit
144
+ puts "当前余额:#{status.deposit} 条"
144
145
  ```
145
146
 
146
- ### Configuration(配置项说明)
147
-
148
- 支持以下可选配置参数:
147
+ ### 配置参数
149
148
 
150
149
  ```ruby
151
150
  client = Luosimao::SMS::Client.new(
152
- api_key: 'your_api_key',
153
- timeout: 10, # 超时秒数,默认 30
154
- open_timeout: 5, # 连接超时,默认 10
155
- base_url: 'https://sms-api.luosimao.com' # 基础 URL
151
+ api_key: 'your_api_key', # 必填。未带 key- 前缀会自动补全。
152
+ timeout: 10, # 读取超时,默认 30 秒。
153
+ open_timeout: 5, # 连接超时,默认 10 秒。
154
+ base_url: 'https://sms-api.luosimao.com' # 可用于测试环境。
156
155
  )
157
156
  ```
158
157
 
159
- `api_key` 传入时会自动补全 `key-` 前缀(如果未带)。
158
+ ### 接口说明
160
159
 
161
- ### API Reference(接口说明)
160
+ | 方法 | 说明 |
161
+ |------|------|
162
+ | `client.send(mobile:, message:)` | 单发短信。返回 `Luosimao::SMS::Response`。 |
163
+ | `client.send_batch(mobiles:, message:, send_at: nil)` | 批量发送。`send_at` 传入 `Time` 对象可定时发送。 |
164
+ | `client.status` | 查询账户余额。返回 `Luosimao::SMS::StatusResponse`。 |
162
165
 
163
- #### `client.send(mobile:, message:)`
164
- 单发短信。返回 `Luosimao::SMS::Response` 对象。
166
+ ### 异常处理
165
167
 
166
- #### `client.send_batch(mobiles:, message:, send_at: nil)`
167
- 批量发送。返回 `Luosimao::SMS::Response` 对象。
168
+ | 异常类 | 说明 | 帮助方法 |
169
+ |--------|------|----------|
170
+ | `Luosimao::SMS::APIError` | API 返回错误码。 | `auth_failed?`, `insufficient_balance?`, `sensitive_words?`, `ip_not_allowed?` |
171
+ | `Luosimao::SMS::NetworkError` | 网络异常(超时、连接拒绝、非法 JSON)。 | - |
172
+ | `Luosimao::SMS::ArgumentError` | 参数错误。 | - |
168
173
 
169
- #### `client.status`
170
- 查询账户余额。返回 `Luosimao::SMS::StatusResponse` 对象。
174
+ 使用示例:
171
175
 
172
- ### Error Handling(异常处理)
173
-
174
- SDK 在遇到错误时会抛出异常:
175
- - `Luosimao::SMS::APIError`: 接口返回错误。支持使用 `auth_failed?`, `insufficient_balance?`, `sensitive_words?`, `ip_not_allowed?` 等方法检查具体错误。
176
- - `Luosimao::SMS::NetworkError`: 网络请求异常(超时、连接失败等)。
177
- - `Luosimao::SMS::ArgumentError`: 参数错误。
176
+ ```ruby
177
+ begin
178
+ client.send(mobile: '13800138000', message: '验证码123456【公司名】')
179
+ rescue Luosimao::SMS::APIError => e
180
+ puts "接口错误 [#{e.code}]:#{e.message}"
181
+ puts "余额不足!" if e.insufficient_balance?
182
+ rescue Luosimao::SMS::NetworkError => e
183
+ puts "网络异常:#{e.message}"
184
+ end
185
+ ```
178
186
 
179
- ### Development(本地开发)
187
+ ### 本地开发
180
188
 
181
- 检出代码后,运行 `bundle install` 安装依赖。然后运行 `bundle exec rspec` 执行测试用例。
189
+ ```bash
190
+ git clone https://github.com/luosimao-oss/luosimao-sms-ruby.git
191
+ cd luosimao-sms
192
+ bundle install
193
+ bundle exec rspec
194
+ ```
182
195
 
183
- ### Contributing(贡献指南)
196
+ ### 贡献指南
184
197
 
185
- 欢迎提交 Issue 和 Pull Request:https://github.com/luosimao-oss/luosimao-sms-ruby。
198
+ 欢迎提交 Issue 和 Pull Request
186
199
 
187
- ### License
200
+ ### 开源协议
188
201
 
189
- 遵循 [MIT License](https://opensource.org/licenses/MIT) 开源协议。
202
+ 本项目遵循 MIT 协议,详见 [LICENSE](LICENSE)
@@ -1,5 +1,5 @@
1
1
  module Luosimao
2
2
  module SMS
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luosimao-sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - luosimao-oss
@@ -67,7 +67,7 @@ files:
67
67
  - lib/luosimao/sms/error.rb
68
68
  - lib/luosimao/sms/response.rb
69
69
  - lib/luosimao/sms/version.rb
70
- homepage: https://github.com/luosimao-oss/luosimao-sms-ruby
70
+ homepage: https://github.com/luosimao-oss/sms-ruby
71
71
  licenses:
72
72
  - MIT
73
73
  metadata: {}