sms-pilot-api-v1 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +7 -1
- data/README.md +10 -5
- data/bin/console +2 -5
- data/lib/sms_pilot/client.rb +6 -1
- data/lib/sms_pilot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef5f991fb1af59f48bbc7ccab3e1ab3b417c76fc22a584922fa5bca8879e294c
|
4
|
+
data.tar.gz: 83031cf779a24ed4b1d44de6d08f33ef611a0b9fdc63742c14ec792080c54fa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a60a7e124256682fd89d4d411c7402feb6597b0541493c2bd08b88b95a515cdf4ae9c0fb435939d7b6f98a56b2d9dd513cd344023bb2f446fbcffc8507eac0
|
7
|
+
data.tar.gz: d0a91bb376ef6090356040cc8eddca2272ce1917e044a7a7cea43f6fe812d265ea1c548eb63e95b5c163a1baed78758bb35a5a0075dea096674bbd4649f0a4ab
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sms-pilot-api-v1 (0.0.
|
4
|
+
sms-pilot-api-v1 (0.0.5)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
coderay (1.1.3)
|
9
10
|
diff-lcs (1.4.4)
|
11
|
+
method_source (1.0.0)
|
12
|
+
pry (0.14.1)
|
13
|
+
coderay (~> 1.1)
|
14
|
+
method_source (~> 1.0)
|
10
15
|
rake (13.0.3)
|
11
16
|
rspec (3.10.0)
|
12
17
|
rspec-core (~> 3.10.0)
|
@@ -26,6 +31,7 @@ PLATFORMS
|
|
26
31
|
x86_64-darwin-17
|
27
32
|
|
28
33
|
DEPENDENCIES
|
34
|
+
pry
|
29
35
|
rake (~> 13.0)
|
30
36
|
rspec (~> 3.0)
|
31
37
|
sms-pilot-api-v1!
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ from GitHub:
|
|
18
18
|
gem "sms-pilot-api-v1", git: "https://github.com/sergeypedan/sms-pilot-api-v1.git"
|
19
19
|
```
|
20
20
|
|
21
|
-
##
|
21
|
+
## Playground
|
22
22
|
|
23
23
|
Test sending SMS from console with a test API key (find it at the end of this page):
|
24
24
|
|
@@ -27,14 +27,18 @@ cd $(bundle info sms-pilot-api-v1 --path)
|
|
27
27
|
bin/console
|
28
28
|
```
|
29
29
|
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
30
33
|
### Initialize
|
31
34
|
|
32
35
|
```ruby
|
33
36
|
require "sms_pilot"
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
key = "XXXXXXXXXXXXYYYYYYYYYYYYZZZZZZZZXXXXXXXXXXXXYYYYYYYYYYYYZZZZZZZZ"
|
39
|
+
|
40
|
+
client = SmsPilot::Client.new(api_key: key)
|
41
|
+
client = SmsPilot::Client.new(api_key: key, locale: :en) # Available locales are [:en, :ru]
|
38
42
|
```
|
39
43
|
|
40
44
|
### Before sending
|
@@ -59,7 +63,8 @@ client.url # => nil
|
|
59
63
|
### Sending SMS
|
60
64
|
|
61
65
|
```ruby
|
62
|
-
client.send_sms("+7 (902) 123-45-67", "Привет, мир!")
|
66
|
+
client.send_sms("+7 (902) 123-45-67", "Привет, мир!")
|
67
|
+
# => true
|
63
68
|
```
|
64
69
|
|
65
70
|
Returns result of `sms_sent?`, so it’s either `true` or `false`.
|
data/bin/console
CHANGED
@@ -8,8 +8,5 @@ require "sms_pilot"
|
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
9
9
|
|
10
10
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|
11
|
+
require "pry"
|
12
|
+
Pry.start
|
data/lib/sms_pilot/client.rb
CHANGED
@@ -101,14 +101,19 @@ module SmsPilot
|
|
101
101
|
|
102
102
|
|
103
103
|
# @param api_key [String]
|
104
|
+
# @param locale [Symbol]
|
105
|
+
#
|
104
106
|
# @return [SmsPilot::Client]
|
105
107
|
# @raise [SmsPilot::InvalidAPIkeyError] if you pass anything but a non-empty String
|
108
|
+
# @raise [SmsPilot::InvalidLocaleError] if you pass anything but <tt>:ru</tt> or <tt>:en</tt>
|
109
|
+
#
|
106
110
|
# @see https://smspilot.ru/my-settings.php Get your production API key here
|
107
111
|
# @see https://smspilot.ru/apikey.php Get your development API key here
|
108
112
|
# @note Current development API key is <tt>"XXXXXXXXXXXXYYYYYYYYYYYYZZZZZZZZXXXXXXXXXXXXYYYYYYYYYYYYZZZZZZZZ"</tt>
|
109
113
|
#
|
110
114
|
# @example
|
111
115
|
# client = SmsPilot::Client.new(api_key: ENV["SMS_PILOT_API_KEY"])
|
116
|
+
# client = SmsPilot::Client.new(api_key: ENV["SMS_PILOT_API_KEY"], locale: :en)
|
112
117
|
#
|
113
118
|
def initialize(api_key:, locale: AVAILABLE_LOCALES[0])
|
114
119
|
@api_key = validate_api_key!(api_key)
|
@@ -263,7 +268,7 @@ module SmsPilot
|
|
263
268
|
# client.sms_cost #=> 2.63
|
264
269
|
#
|
265
270
|
def sms_cost
|
266
|
-
@response_data["cost"] if sms_sent?
|
271
|
+
@response_data["cost"]&.to_f if sms_sent?
|
267
272
|
end
|
268
273
|
|
269
274
|
|
data/lib/sms_pilot/version.rb
CHANGED