sms-pilot-api-v1 0.0.9 → 0.0.10
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 +47 -10
- data/Gemfile +6 -2
- data/Gemfile.lock +14 -2
- data/README.md +1 -0
- data/lib/sms_pilot/client.rb +37 -12
- data/lib/sms_pilot/errors.rb +5 -4
- data/lib/sms_pilot/version.rb +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: e18ed848bce6fc14c2011704a417ebcd18b26a2364d6eded6f70c4bf8e0fd37a
|
4
|
+
data.tar.gz: 8c0fc16b26a26194ebd2543aa231f0b41b74181141de85f4530114c2045c55ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64fad357cc93e5b0901db4c15a6965881e205fbb45ef3637d196d280ef11e089595e8e402ad81030883f51472c33716f239381343a05b58d01a334879b46678a
|
7
|
+
data.tar.gz: 172f139edc7163d805edd08a891cbeb1e1789832693b706fe99f5fc76b41f4b40fdc6aada62977b1c84df7d69a0539dad76df465aee66371ca3d144a39ca7444
|
data/CHANGELOG.md
CHANGED
@@ -1,41 +1,78 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [0.0.
|
3
|
+
## [0.0.10] - 2021-05-11
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Accepts sender name in [`#initialize`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:initialize)
|
8
|
+
- Tests for `send_sms`
|
9
|
+
|
10
|
+
## [0.0.9] - 2021-05-10
|
11
|
+
|
12
|
+
### Added
|
4
13
|
|
5
14
|
- Passes `charset` attribute to the API in [`#build_uri`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:build_uri)
|
6
15
|
- Passes `lang` attribute to the API in [`#build_uri`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:build_uri)
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
7
19
|
- Stores constant request params in constants
|
20
|
+
|
21
|
+
### Deprecated
|
22
|
+
|
8
23
|
- Deprecates [`#sms_status`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:sms_status) in favor of [`#broadcast_status`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:broadcast_status)
|
9
24
|
|
10
|
-
## [0.0.8] - 10
|
25
|
+
## [0.0.8] - 2021-05-10
|
26
|
+
|
27
|
+
### Added
|
11
28
|
|
12
|
-
-
|
13
|
-
-
|
29
|
+
- [`#broadcast_id`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:broadcast_id) method
|
30
|
+
- [roadmap section](https://github.com/sergeypedan/sms-pilot-api-v1#roadmap) in the Readme
|
14
31
|
|
15
|
-
## [0.0.7] -
|
32
|
+
## [0.0.7] - 2021-05-09
|
33
|
+
|
34
|
+
### Changed
|
16
35
|
|
17
36
|
- Returns original values from validation methods
|
18
37
|
- Offloads parsing response body to a method
|
19
38
|
- Improves documentation
|
39
|
+
|
40
|
+
### Added
|
41
|
+
|
20
42
|
- Adds CodeClimate badges
|
21
43
|
- Writes tests for [`#initialize`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:initialize)
|
22
44
|
- Writes tests for [`#api_key`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:api_key)
|
23
45
|
|
24
|
-
## [0.0.6] -
|
46
|
+
## [0.0.6] - 2021-05-09
|
47
|
+
|
48
|
+
### Fixed
|
25
49
|
|
26
50
|
- Corrects cost type
|
51
|
+
|
52
|
+
### Changed
|
53
|
+
|
27
54
|
- Switches to PRY in console
|
28
55
|
|
29
|
-
## [0.0.5] -
|
56
|
+
## [0.0.5] - 2021-05-09
|
57
|
+
|
58
|
+
### Added
|
30
59
|
|
31
60
|
- Adds locale support (RU / EN)
|
32
61
|
|
33
|
-
## [0.0.4] -
|
62
|
+
## [0.0.4] - 2021-05-09
|
63
|
+
|
64
|
+
### Fixed
|
34
65
|
|
35
|
-
- Drop dependence on HTTP.rb gem
|
36
66
|
- Corrects what [`#send_sms`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:send_sms) returns (could return String errors instead of Booleans)
|
67
|
+
|
68
|
+
### Changed
|
69
|
+
|
70
|
+
- Drop dependence on HTTP.rb gem
|
71
|
+
|
72
|
+
### Added
|
73
|
+
|
37
74
|
- Adds extensive [documentation](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot/Client) via YARD & RubyDoc
|
38
75
|
|
39
|
-
## [0.0.3] -
|
76
|
+
## [0.0.3] - 2021-05-06
|
40
77
|
|
41
78
|
- Initial release
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,13 +6,20 @@ PATH
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
addressable (2.7.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
9
11
|
coderay (1.1.3)
|
12
|
+
crack (0.4.5)
|
13
|
+
rexml
|
10
14
|
diff-lcs (1.4.4)
|
15
|
+
hashdiff (1.0.1)
|
11
16
|
method_source (1.0.0)
|
12
17
|
pry (0.14.1)
|
13
18
|
coderay (~> 1.1)
|
14
19
|
method_source (~> 1.0)
|
20
|
+
public_suffix (4.0.6)
|
15
21
|
rake (13.0.3)
|
22
|
+
rexml (3.2.5)
|
16
23
|
rspec (3.10.0)
|
17
24
|
rspec-core (~> 3.10.0)
|
18
25
|
rspec-expectations (~> 3.10.0)
|
@@ -26,15 +33,20 @@ GEM
|
|
26
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
34
|
rspec-support (~> 3.10.0)
|
28
35
|
rspec-support (3.10.2)
|
36
|
+
webmock (3.12.2)
|
37
|
+
addressable (>= 2.3.6)
|
38
|
+
crack (>= 0.3.2)
|
39
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
29
40
|
|
30
41
|
PLATFORMS
|
31
42
|
x86_64-darwin-17
|
32
43
|
|
33
44
|
DEPENDENCIES
|
34
45
|
pry
|
35
|
-
rake
|
36
|
-
rspec
|
46
|
+
rake
|
47
|
+
rspec
|
37
48
|
sms-pilot-api-v1!
|
49
|
+
webmock
|
38
50
|
|
39
51
|
BUNDLED WITH
|
40
52
|
2.2.17
|
data/README.md
CHANGED
data/lib/sms_pilot/client.rb
CHANGED
@@ -131,13 +131,15 @@ module SmsPilot
|
|
131
131
|
#
|
132
132
|
# @example
|
133
133
|
# client.send_sms("+7 (902) 123-45-67", "Привет, мир!") # => true
|
134
|
+
# client.send_sms("+7 (902) 123-45-67", "Привет, мир!", "ФССПРФ") # => true
|
134
135
|
#
|
135
|
-
def send_sms(phone, message)
|
136
|
+
def send_sms(phone, message, sender_name = nil)
|
136
137
|
validate_phone! phone
|
137
138
|
validate_message! message
|
139
|
+
validate_sender_name! sender_name
|
138
140
|
|
139
141
|
@phone = normalize_phone(phone)
|
140
|
-
@uri = build_uri(@phone, message)
|
142
|
+
@uri = build_uri(@phone, message, sender_name)
|
141
143
|
|
142
144
|
response = persist_response_details Net::HTTP.get_response(@uri)
|
143
145
|
|
@@ -358,21 +360,29 @@ module SmsPilot
|
|
358
360
|
# @return [URI]
|
359
361
|
# @raise [URI::InvalidURIError] but is almost impossible, because we provide the URL ourselves
|
360
362
|
#
|
363
|
+
# @param [String] phone
|
364
|
+
# @param [String] text
|
365
|
+
# @param [nil, String] sender_name
|
366
|
+
#
|
361
367
|
# @see #api_key
|
362
368
|
# @see #phone
|
363
369
|
# @see #validate_phone!
|
364
370
|
# @see #validate_message!
|
365
|
-
#
|
366
|
-
|
371
|
+
# @see #validate_sender_name!
|
372
|
+
#
|
373
|
+
private def build_uri(phone, text, sender_name)
|
374
|
+
attributes = {
|
375
|
+
apikey: @api_key,
|
376
|
+
charset: REQUEST_CHARSET,
|
377
|
+
format: REQUEST_ACCEPT_FORMAT,
|
378
|
+
lang: @locale,
|
379
|
+
send: text,
|
380
|
+
to: phone
|
381
|
+
}
|
382
|
+
attributes = attributes.merge({ sender: sender_name }) if sender_name
|
383
|
+
|
367
384
|
URI.parse(API_ENDPOINT).tap do |uri|
|
368
|
-
uri.query = URI.encode_www_form(
|
369
|
-
apikey: @api_key,
|
370
|
-
charset: REQUEST_CHARSET,
|
371
|
-
format: REQUEST_ACCEPT_FORMAT,
|
372
|
-
lang: @locale,
|
373
|
-
send: text,
|
374
|
-
to: phone
|
375
|
-
})
|
385
|
+
uri.query = URI.encode_www_form(attributes)
|
376
386
|
end
|
377
387
|
end
|
378
388
|
|
@@ -476,6 +486,21 @@ module SmsPilot
|
|
476
486
|
phone
|
477
487
|
end
|
478
488
|
|
489
|
+
|
490
|
+
# Validates sender name
|
491
|
+
# @private
|
492
|
+
#
|
493
|
+
# @param [nil, String] sender_name
|
494
|
+
# @return [String] the original value passed into the method, only if it was valid
|
495
|
+
#
|
496
|
+
# @raise [SmsPilot::InvalidSenderNameError] if you pass anything but <tt>nil</tt> or non-empty <tt>String</tt>
|
497
|
+
#
|
498
|
+
private def validate_sender_name!(sender_name)
|
499
|
+
fail SmsPilot::InvalidSenderNameError, "sender name must be either nil or String" unless [NilClass, String].include? sender_name.class
|
500
|
+
fail SmsPilot::InvalidSenderNameError, "sender name cannot be empty" if sender_name == ""
|
501
|
+
sender_name
|
502
|
+
end
|
503
|
+
|
479
504
|
# @!endgroup
|
480
505
|
|
481
506
|
end
|
data/lib/sms_pilot/errors.rb
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
module SmsPilot
|
4
4
|
|
5
|
-
class InvalidAPIkeyError
|
6
|
-
class
|
7
|
-
class
|
8
|
-
class
|
5
|
+
class InvalidAPIkeyError < ArgumentError; end
|
6
|
+
class InvalidLocaleError < ArgumentError; end
|
7
|
+
class InvalidMessageError < ArgumentError; end
|
8
|
+
class InvalidPhoneError < ArgumentError; end
|
9
|
+
class InvalidSenderNameError < ArgumentError; end
|
9
10
|
|
10
11
|
end
|
data/lib/sms_pilot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sms-pilot-api-v1
|
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
|
- Sergey Pedan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Simple wrapper around SMS pilot API v1. Version 1 because it returns
|
14
14
|
more data within its standard response
|