smsru-ruby 2.0.1 → 3.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 +23 -2
- data/README.md +4 -3
- data/lib/sms_ru/client.rb +2 -2
- data/lib/sms_ru/coerce.rb +3 -3
- data/lib/sms_ru/data.rb +3 -3
- data/lib/sms_ru/statuses.rb +2 -2
- data/lib/sms_ru/version.rb +1 -1
- data/lib/sms_ru/webhook.rb +3 -3
- data/smsru-ruby.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9fa32fb7428f230423bda4d5a4b8e776c719df31daebe9ffb30e488e8bc7c620
|
|
4
|
+
data.tar.gz: 8dd26fbc54609529e34df51e2ff374e64d3657be1187e2ff76a9d33dbbcbb7ed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4fb447fbe3057aaab9b6e92ee90645bb2294ef0b7a75fc697c4befd820e77f9115f485b1f4c12ac05c624a0b5224ab82b8b5f375fa7ee958b7eeb39b793f7d9
|
|
7
|
+
data.tar.gz: 235d9ca8fba5a74229ee3416a2fc58bc704aabb2f1b93d8bf18daff8916f948d10d2f56ef7aaa6a5ee3522e059515832dce806fe3fe755adbcdba09c82bea509
|
data/CHANGELOG.md
CHANGED
|
@@ -5,8 +5,28 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
The public API that Semantic Versioning covers is every constant and method
|
|
9
|
+
under `SmsRu` that YARD documents as public: the `SmsRu` client and its `auth`,
|
|
10
|
+
`callbacks`, `call_check`, `my`, and `stoplist` sub-resources, the result and
|
|
11
|
+
event `Data` classes, the `SmsRu::Statuses` constants and predicates, the error
|
|
12
|
+
hierarchy under `SmsRu::Error`, and `SmsRu::Webhook.parse`. Anything marked
|
|
13
|
+
`@api private`, including `SmsRu::Coerce` and the sub-resource constructors, may
|
|
14
|
+
change in any release. The minimum supported Ruby version is part of the public
|
|
15
|
+
API: raising it takes a MAJOR release.
|
|
16
|
+
|
|
8
17
|
## [Unreleased]
|
|
9
18
|
|
|
19
|
+
## [3.0.0] - 2026-09-07
|
|
20
|
+
|
|
21
|
+
### Removed
|
|
22
|
+
|
|
23
|
+
- Ruby 3.2 support. The minimum supported Ruby is now 3.3.
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- This changelog now declares which constants and methods Semantic Versioning
|
|
28
|
+
covers, so a version range says something checkable about what may change.
|
|
29
|
+
|
|
10
30
|
## [2.0.1] - 2026-07-31
|
|
11
31
|
|
|
12
32
|
### Added
|
|
@@ -26,7 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
26
46
|
|
|
27
47
|
### Changed
|
|
28
48
|
|
|
29
|
-
- **
|
|
49
|
+
- **Breaking:** Renamed the gem from `smsru_ruby` to `smsru-ruby` for
|
|
30
50
|
consistency with the `-ruby` suffix convention. Update your `Gemfile`
|
|
31
51
|
(`gem "smsru-ruby"`) and requires (`require "smsru-ruby"`). The Ruby API is
|
|
32
52
|
unchanged. The top-level class is still `SmsRu`.
|
|
@@ -62,7 +82,8 @@ same API, reworked to be idiomatic Ruby. How it differs from the original:
|
|
|
62
82
|
SMS.ru's loosely-typed JSON is normalized to the declared types at the parse
|
|
63
83
|
boundary, so result objects never surface raw wire values.
|
|
64
84
|
|
|
65
|
-
[Unreleased]: https://github.com/svyatov/smsru-ruby/compare/
|
|
85
|
+
[Unreleased]: https://github.com/svyatov/smsru-ruby/compare/v3.0.0...HEAD
|
|
86
|
+
[3.0.0]: https://github.com/svyatov/smsru-ruby/compare/v2.0.1...v3.0.0
|
|
66
87
|
[2.0.1]: https://github.com/svyatov/smsru-ruby/compare/v2.0.0...v2.0.1
|
|
67
88
|
[2.0.0]: https://github.com/svyatov/smsru-ruby/compare/v1.0.0...v2.0.0
|
|
68
89
|
[1.0.0]: https://github.com/svyatov/smsru-ruby/releases/tag/v1.0.0
|
data/README.md
CHANGED
|
@@ -297,6 +297,8 @@ SmsRu::Error # base class
|
|
|
297
297
|
└─ SmsRu::InsufficientFundsError # not enough money (code 201)
|
|
298
298
|
```
|
|
299
299
|
|
|
300
|
+
Rescue whichever level of that hierarchy your code needs, around any call.
|
|
301
|
+
|
|
300
302
|
```ruby
|
|
301
303
|
begin
|
|
302
304
|
client.deliver("79991234567", "Hi")
|
|
@@ -316,9 +318,8 @@ reported on each `SmsRu::Sms` in `result.messages` (see above).
|
|
|
316
318
|
|
|
317
319
|
## Development
|
|
318
320
|
|
|
319
|
-
Ruby 3.
|
|
320
|
-
|
|
321
|
-
`ruby-head`, `4.0`, `3.4`, `3.3`, and `3.2`.
|
|
321
|
+
Ruby 3.3 or newer is required. CI runs against `ruby-head`, `4.0`, `3.4`, and
|
|
322
|
+
`3.3`.
|
|
322
323
|
|
|
323
324
|
```sh
|
|
324
325
|
bin/setup # install dependencies
|
data/lib/sms_ru/client.rb
CHANGED
|
@@ -20,7 +20,7 @@ class SmsRu
|
|
|
20
20
|
# @param retries [Integer] retry attempts on transport failure (0 disables; PHP default is 5)
|
|
21
21
|
# @param from [String, nil] default sender name for #deliver (overridable per call)
|
|
22
22
|
# @param logger [Logger, nil] optional logger; logs the request path and transport
|
|
23
|
-
# failures only
|
|
23
|
+
# failures only, never the api_id, phone numbers, or message text
|
|
24
24
|
def initialize(api_id, timeout: 30, test: false, retries: 5, from: nil, logger: nil)
|
|
25
25
|
@api_id = api_id
|
|
26
26
|
@timeout = timeout
|
|
@@ -39,7 +39,7 @@ class SmsRu
|
|
|
39
39
|
# forms, must be omitted for the Hash form
|
|
40
40
|
# @param from [String, nil] an approved sender name
|
|
41
41
|
# @param time [Integer, nil] schedule the send at this UNIX timestamp
|
|
42
|
-
# @param ttl [Integer, nil] message lifetime in minutes (1
|
|
42
|
+
# @param ttl [Integer, nil] message lifetime in minutes (1 to 1440); undelivered
|
|
43
43
|
# messages are discarded after this period
|
|
44
44
|
# @param daytime [Boolean] when true, defer night-time sends to the recipient's daytime
|
|
45
45
|
# @param translit [Boolean] transliterate Cyrillic to Latin
|
data/lib/sms_ru/coerce.rb
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
class SmsRu
|
|
4
4
|
# Normalizes loosely-typed SMS.ru JSON values into the types the result
|
|
5
|
-
# objects declare. SMS.ru is inconsistent on the wire
|
|
5
|
+
# objects declare. SMS.ru is inconsistent on the wire: `/my/limit` returns
|
|
6
6
|
# `total_limit` as the string `"10"` but `used_today` as the number `0`, and
|
|
7
|
-
# some counters arrive as `null
|
|
7
|
+
# some counters arrive as `null`. Each field is coerced here rather than
|
|
8
8
|
# trusted as-is.
|
|
9
9
|
#
|
|
10
10
|
# Each type has two helpers: the `?` variant returns nil for a
|
|
11
11
|
# missing/blank/unparseable value (for the nullable fields), while the plain
|
|
12
12
|
# variant falls back to a default (`""`/`0`/`0.0`, overridable) for the fields
|
|
13
|
-
# the API always populates
|
|
13
|
+
# the API always populates, so call sites declare their nullability by name.
|
|
14
14
|
#
|
|
15
15
|
# @api private
|
|
16
16
|
module Coerce
|
data/lib/sms_ru/data.rb
CHANGED
|
@@ -155,7 +155,7 @@ class SmsRu
|
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
# Result of SmsRu#call (flash call). `code` is the last 4 digits of the number
|
|
158
|
-
# that calls the user
|
|
158
|
+
# that calls the user, which is what they read off the incoming call and enter.
|
|
159
159
|
#
|
|
160
160
|
# @!attribute [r] code
|
|
161
161
|
# @return [String] the 4-digit code (the calling number's last 4 digits)
|
|
@@ -212,7 +212,7 @@ class SmsRu
|
|
|
212
212
|
def available_today = total_free - used_today
|
|
213
213
|
end
|
|
214
214
|
|
|
215
|
-
# Result of SmsRu::CallCheck#add
|
|
215
|
+
# Result of SmsRu::CallCheck#add: the number the user must call to authorize.
|
|
216
216
|
#
|
|
217
217
|
# @!attribute [r] check_id
|
|
218
218
|
# @return [String] the check id to poll with SmsRu::CallCheck#status
|
|
@@ -235,7 +235,7 @@ class SmsRu
|
|
|
235
235
|
end
|
|
236
236
|
end
|
|
237
237
|
|
|
238
|
-
# Result of SmsRu::CallCheck#status
|
|
238
|
+
# Result of SmsRu::CallCheck#status: whether the authorizing call has arrived.
|
|
239
239
|
#
|
|
240
240
|
# @!attribute [r] status_code
|
|
241
241
|
# @return [Integer] the check status code (401 once confirmed)
|
data/lib/sms_ru/statuses.rb
CHANGED
|
@@ -41,10 +41,10 @@ class SmsRu
|
|
|
41
41
|
# @return [Boolean] true once the message reached the handset (code 103)
|
|
42
42
|
def delivered? = status_code == Statuses::DELIVERED
|
|
43
43
|
|
|
44
|
-
# @return [Boolean] true while the message is still in transit (codes 100
|
|
44
|
+
# @return [Boolean] true while the message is still in transit (codes 100 to 102)
|
|
45
45
|
def pending? = !status_code.nil? && Statuses::PENDING.include?(status_code)
|
|
46
46
|
|
|
47
|
-
# @return [Boolean] true when the message will not be delivered (codes 104
|
|
47
|
+
# @return [Boolean] true when the message will not be delivered (codes 104 to 108, and 150)
|
|
48
48
|
def failed? = !status_code.nil? && Statuses::FAILED.include?(status_code)
|
|
49
49
|
end
|
|
50
50
|
end
|
data/lib/sms_ru/version.rb
CHANGED
data/lib/sms_ru/webhook.rb
CHANGED
|
@@ -8,14 +8,14 @@ class SmsRu
|
|
|
8
8
|
#
|
|
9
9
|
# The `data` param arrives as a Hash in bare Rack and an Array in PHP-style
|
|
10
10
|
# clients. In Rails it is an `ActionController::Parameters`, which is **not** a
|
|
11
|
-
# Hash
|
|
11
|
+
# Hash. Convert it with `.to_unsafe_h` first, or the numeric-key ordering the
|
|
12
12
|
# signature depends on is skipped and {valid?} rejects the payload. The
|
|
13
13
|
# payload is signature-verified, so `to_unsafe_h` is safe here (`.to_h` would
|
|
14
14
|
# drop unpermitted keys).
|
|
15
15
|
#
|
|
16
|
-
# {parse} returns one typed event per record
|
|
16
|
+
# {parse} returns one typed event per record: a {SmsRu::Events::SmsStatus},
|
|
17
17
|
# {SmsRu::Events::CallcheckStatus}, {SmsRu::Events::Test}, or
|
|
18
|
-
# {SmsRu::Events::Unknown}
|
|
18
|
+
# {SmsRu::Events::Unknown}. A case match handles them best:
|
|
19
19
|
#
|
|
20
20
|
# data = params[:data].to_unsafe_h # Rails; pass params["data"] as-is in bare Rack
|
|
21
21
|
# return head(:forbidden) unless SmsRu::Webhook.valid?(data, params[:hash], api_id)
|
data/smsru-ruby.gemspec
CHANGED
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
spec.homepage = "https://github.com/svyatov/smsru-ruby"
|
|
16
16
|
spec.license = "MIT"
|
|
17
17
|
|
|
18
|
-
spec.required_ruby_version = ">= 3.
|
|
18
|
+
spec.required_ruby_version = ">= 3.3.0"
|
|
19
19
|
|
|
20
20
|
spec.require_paths = ["lib"]
|
|
21
21
|
spec.files = Dir["lib/**/*.rb"] + Dir["sig/**/*"] +
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smsru-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Leonid Svyatov
|
|
@@ -67,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
67
67
|
requirements:
|
|
68
68
|
- - ">="
|
|
69
69
|
- !ruby/object:Gem::Version
|
|
70
|
-
version: 3.
|
|
70
|
+
version: 3.3.0
|
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - ">="
|