sms_traffic_sdk 0.2.0 → 0.3.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 +18 -0
- data/README.md +5 -0
- data/lib/sms_traffic/client/reply.rb +11 -1
- data/lib/sms_traffic/configuration.rb +1 -1
- data/lib/sms_traffic/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73b544fc8bce8a1627dca1e7be082da47adbb4116bc6d47a4fdb9cd50bbc2e3c
|
|
4
|
+
data.tar.gz: d653685da42c1e33a1d06a300edf98d8f5f83e5b6da969f57e41eb4b444692b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75efe5af30bde21435b11fde083721a9cc9b701dbb3f3eab506670694a9b6b863b2c143a288793b27e63607ef138c2ffd8b31d7a3387821ac439b2765ffeed16
|
|
7
|
+
data.tar.gz: 640e577af992334877dcaf3c0839e005cf2929e5fa21c9ac9bb0f4fb4f94a64f446ad428e3764fdaf152444bf7e33b01f5b967414e1a78928bc39c502aab9895
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 - 2026-11-03
|
|
4
|
+
|
|
5
|
+
### Breaking changes
|
|
6
|
+
|
|
7
|
+
- `nokogiri` is no longer a dependency. Applications that relied on Nokogiri being installed through this gem must
|
|
8
|
+
depend on it themselves.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- The default XML parser is `Nori.new(advanced_typecasting: false, parser: :rexml)`. Every fixture parses to the
|
|
13
|
+
same hash as with Nokogiri. `rexml` (`>= 3.3.9`, after the 2024 DoS fixes) is a new runtime dependency; a custom
|
|
14
|
+
`xml_parser` is still possible.
|
|
15
|
+
- A body that is not well-formed XML (an HTML error page, plain text, a truncated reply) keeps the 0.2.0 behavior:
|
|
16
|
+
the reply is empty, so `Sms#deliver` returns `false` and `Client.*` return a reply with an empty hash.
|
|
17
|
+
- Runtime dependency lower bounds are tested: `gemfiles/minimum.gemfile` pins `nori` 2.8.0, `rexml` 3.3.9 and
|
|
18
|
+
`bigdecimal` 3.1.0, and the suite passes with them. CI runs it as `test-minimum` on Ruby 3.1 and 3.4; `publish`
|
|
19
|
+
waits for it.
|
|
20
|
+
|
|
3
21
|
## 0.2.0 - 2026-11-03
|
|
4
22
|
|
|
5
23
|
### Added
|
data/README.md
CHANGED
|
@@ -136,6 +136,11 @@ on the backup host. The request is repeated after `SocketError`, `Errno::ECONNRE
|
|
|
136
136
|
`Client.deliver` does not, since the provider may already have queued the SMS. The error of the last attempt is raised. With `debug`, the retry is
|
|
137
137
|
logged in one line without credentials.
|
|
138
138
|
|
|
139
|
+
### XML parser
|
|
140
|
+
|
|
141
|
+
Replies are parsed with Nori and its pure-Ruby REXML backend, so no native extension is needed. To use another
|
|
142
|
+
parser, set `config.xml_parser` to any object that responds to `parse(xml)` and returns a Hash.
|
|
143
|
+
|
|
139
144
|
### Errors
|
|
140
145
|
|
|
141
146
|
All errors inherit from `SmsTraffic::Error`:
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# Nori loads REXML lazily on the first parse; Reply#parse rescues its exception even with a custom parser.
|
|
2
|
+
require 'rexml/parsers/baseparser'
|
|
3
|
+
|
|
1
4
|
module SmsTraffic
|
|
2
5
|
class Client
|
|
3
6
|
class Reply
|
|
@@ -8,7 +11,7 @@ module SmsTraffic
|
|
|
8
11
|
|
|
9
12
|
def initialize(xml, xml_parser: SmsTraffic.configuration.xml_parser)
|
|
10
13
|
@xml = xml.gsub(/\s+/, ' ')
|
|
11
|
-
parsed = fetch_value(
|
|
14
|
+
parsed = fetch_value(parse(xml_parser), :reply)
|
|
12
15
|
@to_h = parsed.is_a?(Hash) ? parsed : {}
|
|
13
16
|
end
|
|
14
17
|
|
|
@@ -31,6 +34,13 @@ module SmsTraffic
|
|
|
31
34
|
|
|
32
35
|
private
|
|
33
36
|
|
|
37
|
+
# A body that is not well-formed XML is an empty reply, as before the REXML parser.
|
|
38
|
+
def parse(xml_parser)
|
|
39
|
+
xml_parser.parse(@xml)
|
|
40
|
+
rescue REXML::ParseException
|
|
41
|
+
{}
|
|
42
|
+
end
|
|
43
|
+
|
|
34
44
|
def fetch_value(source, key)
|
|
35
45
|
return unless source.is_a?(Hash)
|
|
36
46
|
|
|
@@ -17,7 +17,7 @@ module SmsTraffic
|
|
|
17
17
|
|
|
18
18
|
def reset!
|
|
19
19
|
ATTRIBUTES.each { |attribute| public_send("#{attribute}=", DEFAULTS[attribute]) }
|
|
20
|
-
self.xml_parser = Nori.new(advanced_typecasting: false)
|
|
20
|
+
self.xml_parser = Nori.new(advanced_typecasting: false, parser: :rexml)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def validate!
|
data/lib/sms_traffic/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sms_traffic_sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Rybolovlev
|
|
@@ -25,33 +25,33 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '3.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: nori
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '2.8'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '2.8'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rexml
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 3.3.9
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - "
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 3.3.9
|
|
55
55
|
description: |-
|
|
56
56
|
Ruby Gem as a SDK for interacting with the SMS Traffic HTTP API (smstraffic.ru/api).
|
|
57
57
|
This gem provides a convenient way to integrate SMS Traffic services into Ruby applications,
|