sms_aero 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -3
- data/CHANGELOG.md +7 -0
- data/README.md +11 -0
- data/lib/sms_aero/operations/hlr.rb +32 -0
- data/lib/sms_aero/types/birthday.rb +1 -1
- data/lib/sms_aero/types/future.rb +1 -1
- data/sms_aero.gemspec +1 -1
- data/spec/sms_aero/operations/hlr_spec.rb +88 -0
- data/spec/sms_aero/types/sign_status_spec.rb +4 -4
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11a7f4bcfe9374590b97682e24add8d2a61ff4f1
|
4
|
+
data.tar.gz: f16f9215a7b84ab1a0906af3515be48461022012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aad6a6ba533cc42e810959fe7819f6c4d5b5f3d9b7c212b487ed5807007a27fce2d50d7a20433b334be9173b59db753f2737f3fa1ae6f7471a6f2c39c6ba74da
|
7
|
+
data.tar.gz: 16f5ee1c830ba19bcfa9b7879caeb83c1b798f711428dc97834906eba4bb7931385d6597a442046a472fe80ceb4d9bb2470c730379c1d7b4c244d67fdf08f394
|
data/.rubocop.yml
CHANGED
@@ -12,6 +12,9 @@ Metrics/LineLength:
|
|
12
12
|
- http
|
13
13
|
- https
|
14
14
|
|
15
|
+
Layout/SpaceInLambdaLiteral:
|
16
|
+
Enabled: false
|
17
|
+
|
15
18
|
Style/Lambda:
|
16
19
|
Enabled: false
|
17
20
|
|
@@ -21,13 +24,13 @@ Style/StringLiterals:
|
|
21
24
|
Style/FrozenStringLiteralComment:
|
22
25
|
Enabled: false
|
23
26
|
|
24
|
-
Style/
|
27
|
+
Style/DateTime:
|
25
28
|
Enabled: false
|
26
29
|
|
27
|
-
Style/
|
30
|
+
Style/Documentation:
|
28
31
|
Enabled: false
|
29
32
|
|
30
|
-
Style/
|
33
|
+
Style/ClassAndModuleChildren:
|
31
34
|
Enabled: false
|
32
35
|
|
33
36
|
Style/PercentLiteralDelimiters:
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [0.0.10] - [2017-12-03]
|
8
|
+
|
9
|
+
### Added
|
10
|
+
- checking existance & availability of phone number using methods `#hlr` and `#hlr_status id` (@Earendil95)
|
11
|
+
|
7
12
|
## [0.0.9] - [2017-06-23]
|
8
13
|
|
9
14
|
### Fixed
|
@@ -19,3 +24,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
19
24
|
[dry-types]: https://github.com/dry-rb/dry-types
|
20
25
|
[0.0.8]: https://github.com/nepalez/sms_aero/compare/v0.0.7...v0.0.8
|
21
26
|
[0.0.9]: https://github.com/nepalez/sms_aero/compare/v0.0.8...v0.0.9
|
27
|
+
[0.0.10]: https://github.com/nepalez/sms_aero/compare/v0.0.8...v0.0.10
|
28
|
+
|
data/README.md
CHANGED
@@ -127,3 +127,14 @@ answer = client.delete_phone phone: "+7 (999) 123-4567",
|
|
127
127
|
|
128
128
|
answer.result # => "accepted"
|
129
129
|
```
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
# checking existance & availability of phone number
|
133
|
+
answer = client.hlr phone: "+7 (999) 123-4567"
|
134
|
+
answer.result # => "accepted"
|
135
|
+
id = answer.id # => "12345", id of request
|
136
|
+
|
137
|
+
answer = client.hlr_status id
|
138
|
+
answer.result # => "accepted"
|
139
|
+
answer.status # => any of :available, :unavailable or :nonexistent
|
140
|
+
```
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class SmsAero
|
2
|
+
HLR_STATUSES = {
|
3
|
+
1 => :available,
|
4
|
+
2 => :unavailable,
|
5
|
+
3 => :nonexistent
|
6
|
+
}.freeze
|
7
|
+
|
8
|
+
operation :hlr do
|
9
|
+
documentation "https://smsaero.ru/api/description/#hlr"
|
10
|
+
|
11
|
+
path { "hlr" }
|
12
|
+
|
13
|
+
query { attribute :phone, Types::Phone }
|
14
|
+
|
15
|
+
response :success, 200, format: :json, model: Answer do
|
16
|
+
attribute :id, proc(&:to_s)
|
17
|
+
attribute :success, default: proc { id != "" }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
operation :hlr_status do
|
22
|
+
documentation "https://smsaero.ru/api/description/#hlr"
|
23
|
+
|
24
|
+
path { "hlrStatus" }
|
25
|
+
|
26
|
+
query { attribute :id, Types::Coercible::String.constrained(filled: true) }
|
27
|
+
|
28
|
+
response :success, 200, format: :json, model: Answer do
|
29
|
+
attribute :status, -> (s) { HLR_STATUSES[s.to_i] }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/sms_aero.gemspec
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
describe SmsAero do
|
2
|
+
let(:settings) { { user: "LOGIN", password: "PASSWORD" } }
|
3
|
+
let(:client) { described_class.new(settings) }
|
4
|
+
|
5
|
+
before { stub_request(:any, //).to_return(body: answer.to_json) }
|
6
|
+
|
7
|
+
describe "#hlr" do
|
8
|
+
let(:params) { { phone: "+7(002)034-5678" } }
|
9
|
+
let(:answer) { { result: "accepted", id: 123 } }
|
10
|
+
let(:url) do
|
11
|
+
"https://gate.smsaero.ru/hlr?answer=json&user=LOGIN&" \
|
12
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&phone=70020345678"
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { client.hlr params }
|
16
|
+
|
17
|
+
it "sends a request" do
|
18
|
+
subject
|
19
|
+
expect(a_request(:post, url)).to have_been_made
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns success" do
|
23
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
24
|
+
expect(subject.result).to eq "accepted"
|
25
|
+
expect(subject.id).to eq "123"
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with invalid phone" do
|
29
|
+
let(:params) { { phone: "123" } }
|
30
|
+
|
31
|
+
it "raises an exception" do
|
32
|
+
expect { subject }.to raise_error(TypeError, /123/)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "without a phone" do
|
37
|
+
let(:params) { {} }
|
38
|
+
|
39
|
+
it "raises an exception" do
|
40
|
+
expect { subject }.to raise_error(ArgumentError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#hlr_status" do
|
46
|
+
let(:params) { { id: 1 } }
|
47
|
+
let(:status) { 1 }
|
48
|
+
let(:answer) { { result: "accepted", status: status } }
|
49
|
+
let(:url) do
|
50
|
+
"https://gate.smsaero.ru/hlrStatus?answer=json&user=LOGIN&" \
|
51
|
+
"password=319f4d26e3c536b5dd871bb2c52e3178&id=1"
|
52
|
+
end
|
53
|
+
|
54
|
+
subject { client.hlr_status params }
|
55
|
+
|
56
|
+
it "sends a request" do
|
57
|
+
subject
|
58
|
+
expect(a_request(:post, url)).to have_been_made
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns success" do
|
62
|
+
expect(subject).to be_kind_of SmsAero::Answer
|
63
|
+
expect(subject.result).to eq "accepted"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "converts status to sym" do
|
67
|
+
expect(subject.status).to eq :available
|
68
|
+
end
|
69
|
+
|
70
|
+
context "other statuses" do
|
71
|
+
context "unavailable" do
|
72
|
+
let(:status) { 2 }
|
73
|
+
|
74
|
+
it "converts status to sym" do
|
75
|
+
expect(subject.status).to eq :unavailable
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "nonexistent" do
|
80
|
+
let(:status) { 3 }
|
81
|
+
|
82
|
+
it "converts status to sym" do
|
83
|
+
expect(subject.status).to eq :nonexistent
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -2,18 +2,18 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe SmsAero::Types::SignStatus do
|
4
4
|
context "valid status:" do
|
5
|
-
let(:
|
5
|
+
let(:items) { %w(accepted approved rejected pending) }
|
6
6
|
|
7
7
|
it "returns a status" do
|
8
|
-
|
8
|
+
items.each { |item| expect(described_class[item]).to eq item }
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
context "invalid status:" do
|
13
|
-
let(:
|
13
|
+
let(:item) { "wrong" }
|
14
14
|
|
15
15
|
it "fails" do
|
16
|
-
expect { described_class[
|
16
|
+
expect { described_class[item] }.to raise_error(StandardError, /wrong/)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sms_aero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin (nepalez)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-types
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/sms_aero/operations/check_tariff.rb
|
143
143
|
- lib/sms_aero/operations/delete_group.rb
|
144
144
|
- lib/sms_aero/operations/delete_phone.rb
|
145
|
+
- lib/sms_aero/operations/hlr.rb
|
145
146
|
- lib/sms_aero/operations/send_sms.rb
|
146
147
|
- lib/sms_aero/operations/send_to_group.rb
|
147
148
|
- lib/sms_aero/types/birthday.rb
|
@@ -165,6 +166,7 @@ files:
|
|
165
166
|
- spec/sms_aero/operations/check_tariff_spec.rb
|
166
167
|
- spec/sms_aero/operations/delete_group_spec.rb
|
167
168
|
- spec/sms_aero/operations/delete_phone_spec.rb
|
169
|
+
- spec/sms_aero/operations/hlr_spec.rb
|
168
170
|
- spec/sms_aero/operations/send_sms_spec.rb
|
169
171
|
- spec/sms_aero/operations/send_to_group_spec.rb
|
170
172
|
- spec/sms_aero/types/birthday_spec.rb
|
@@ -194,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
196
|
version: '0'
|
195
197
|
requirements: []
|
196
198
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.6.
|
199
|
+
rubygems_version: 2.6.14
|
198
200
|
signing_key:
|
199
201
|
specification_version: 4
|
200
202
|
summary: HTTP(s) client to SMS Aero API
|
@@ -211,6 +213,7 @@ test_files:
|
|
211
213
|
- spec/sms_aero/operations/check_tariff_spec.rb
|
212
214
|
- spec/sms_aero/operations/delete_group_spec.rb
|
213
215
|
- spec/sms_aero/operations/delete_phone_spec.rb
|
216
|
+
- spec/sms_aero/operations/hlr_spec.rb
|
214
217
|
- spec/sms_aero/operations/send_sms_spec.rb
|
215
218
|
- spec/sms_aero/operations/send_to_group_spec.rb
|
216
219
|
- spec/sms_aero/types/birthday_spec.rb
|