sms-pilot-api-v1 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb76209647bdda0c204159de74aeb9afd98cb01b6d8979ae9857407e76ff61b1
4
- data.tar.gz: 6bcea2c04668198bcbf07babcfec333e90e1cb920a06eb9cb371d2a291f1ca66
3
+ metadata.gz: 2cdf5eab949b7c36ae220eec407cd1afce5e9fb5df2b7c09c8b7e05327bc67f5
4
+ data.tar.gz: a001b60a5975b0ed50aa69b4f2b66e3d974e001cacf6af949a60617a234d6fe6
5
5
  SHA512:
6
- metadata.gz: b21cecdb44421ffe495e0963b9928dedab5e8740680f94937b85eceb1de256bdef23d967e8012e46c124f3a24f27f3fb8eedd541391964ec6dcdd83c21af7300
7
- data.tar.gz: a693db49eac9e534a6be8c3132804376783a42c56ae532782cd6459f9c516c6f4610ff234d4a9cb522fe30019c64724c042a649e43a475c6c10bbe7e65baf27e
6
+ metadata.gz: 7d8a78e4d68cf605f974feb7c3068245609f1fc2a2765d479c0badf013c6b43fb3b9e3480c97039befc09a9f12208c0ef3d098395c79d86a948ba040f6176763
7
+ data.tar.gz: 02da8904baac9232c9d4c4e6587f4dc1814a20aec9c2558ba8240db2ef8b324af72553278fd818577a32bccfa63dea6bf98c48272047ae67533cdcd687e2de1c
data/CHANGELOG.md CHANGED
@@ -1,12 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.9] - 10 May 2021
4
+
5
+ - Passes `charset` attribute to the API in [`#build_uri`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:build_uri)
6
+ - Passes `lang` attribute to the API in [`#build_uri`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:build_uri)
7
+ - Stores constant request params in constants
8
+ - 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
+
10
+ ## [0.0.8] - 10 May 2021
11
+
12
+ - Adds [`#broadcast_id`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:broadcast_id) method
13
+ - Adds [roadmap section](https://github.com/sergeypedan/sms-pilot-api-v1#roadmap) in the Readme
14
+
3
15
  ## [0.0.7] - 9 May 2021
4
16
 
5
17
  - Returns original values from validation methods
6
18
  - Offloads parsing response body to a method
7
19
  - Improves documentation
8
20
  - Adds CodeClimate badges
9
- - Writes tests for `#initialize` and `#api_key`
21
+ - Writes tests for [`#initialize`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:initialize)
22
+ - Writes tests for [`#api_key`](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot%2FClient:api_key)
10
23
 
11
24
  ## [0.0.6] - 9 May 2021
12
25
 
@@ -20,7 +33,7 @@
20
33
  ## [0.0.4] - 9 May 2021
21
34
 
22
35
  - Drop dependence on HTTP.rb gem
23
- - Corrects what `#send_sms` returns (could return String errors instead of Booleans)
36
+ - 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)
24
37
  - Adds extensive [documentation](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot/Client) via YARD & RubyDoc
25
38
 
26
39
  ## [0.0.3] - 6 May 2021
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sms-pilot-api-v1 (0.0.6)
4
+ sms-pilot-api-v1 (0.0.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -108,7 +108,7 @@ client.url # => "https://smspilot.ru/api.php?apikey=1234567890&form
108
108
  ```ruby
109
109
  client.api_key # => "YOUR API KEY"
110
110
  client.balance # => nil
111
- client.broadcast_id # => 10000
111
+ client.broadcast_id # => nil
112
112
  client.error # => "Неправильный API-ключ (см. настройки API в личном кабинете) (код ошибки: 101)"
113
113
  client.phone # => "79021234567"
114
114
  client.rejected? # => true
@@ -128,7 +128,7 @@ client.url # => "https://smspilot.ru/api.php?apikey=1234567890&form
128
128
  ```ruby
129
129
  client.api_key # => "YOUR API KEY"
130
130
  client.balance # => nil
131
- client.broadcast_id # => 10000
131
+ client.broadcast_id # => nil
132
132
  client.error # => "HTTP request failed with code 404"
133
133
  client.phone # => "79021234567"
134
134
  client.rejected? # => false
@@ -190,3 +190,13 @@ SMS rejected:
190
190
  ## Documentation
191
191
 
192
192
  See [structured documentation](https://rubydoc.info/github/sergeypedan/sms-pilot-api-v1/master/SmsPilot/Client) at RubyDoc.
193
+
194
+
195
+ ## Roadmap
196
+
197
+ 1. Switch to POST to escape 1024 symbolos GET request limit
198
+ 1. Support passing `sender` to the API
199
+ 1. Switch to result object pattern
200
+ 1. Проверка статусов SMS
201
+ 1. Проверка баланса
202
+ 1. Информация о пользователе
@@ -76,6 +76,9 @@ module SmsPilot
76
76
  #
77
77
  AVAILABLE_LOCALES = [:ru, :en].freeze
78
78
 
79
+ REQUEST_ACCEPT_FORMAT = "json".freeze
80
+ REQUEST_CHARSET = "utf-8".freeze
81
+
79
82
  attr_reader :api_key
80
83
  attr_reader :error
81
84
  attr_reader :locale
@@ -184,6 +187,30 @@ module SmsPilot
184
187
  end
185
188
 
186
189
 
190
+ # SMS delivery status, as returned by the API
191
+ #
192
+ # @return [nil, Integer] <tt>nil</tt> is returned before sending SMS or if the request was rejected. Otherwise an <tt>Integer</tt> in the range of [-2..3] is returned.
193
+ # @see https://smspilot.ru/apikey.php#status List of available statuses at API documentation website
194
+ #
195
+ # Code | Name | Final? | Description
196
+ # ----:|:--------------|:-------|:-------------
197
+ # -2 | Ошибка | Да | Ошибка, неправильные параметры запроса
198
+ # -1 | Не доставлено | Да | Сообщение не доставлено (не в сети, заблокирован, не взял трубку), PING — не в сети, HLR — не обслуживается (заблокирован)
199
+ # 0 | Новое | Нет | Новое сообщение/запрос, ожидает обработки у нас на сервере
200
+ # 1 | В очереди | Нет | Сообщение или запрос ожидают отправки на сервере оператора
201
+ # 2 | Доставлено | Да | Доставлено, звонок совершен, PING — в сети, HLR — обслуживается
202
+ # 3 | Отложено | Нет | Отложенная отправка, отправка сообщения/запроса запланирована на другое время
203
+ #
204
+ # @example
205
+ # client.broadcast_status #=> 2
206
+ #
207
+ # @see #sms_status
208
+ #
209
+ def broadcast_status
210
+ @response_data.dig("send", 0, "status")&.to_i if sms_sent?
211
+ end
212
+
213
+
187
214
  # Numerical code of the error that occured when sending the SMS. In the range from 0 to 715 (which may change).
188
215
  #
189
216
  # @return [nil, Integer] <tt>nil</tt> is returned before sending SMS. Otherwise <tt>Integer</tt>
@@ -300,25 +327,10 @@ module SmsPilot
300
327
  end
301
328
 
302
329
 
303
- # SMS delivery status, as returned by the API
304
- #
305
- # @return [nil, Integer] <tt>nil</tt> is returned before sending SMS or if the request was rejected. Otherwise an <tt>Integer</tt> in the range of [-2..3] is returned.
306
- # @see https://smspilot.ru/apikey.php#status List of available statuses at API documentation website
307
- #
308
- # Code | Name | Final? | Description
309
- # ----:|:--------------|:-------|:-------------
310
- # -2 | Ошибка | Да | Ошибка, неправильные параметры запроса
311
- # -1 | Не доставлено | Да | Сообщение не доставлено (не в сети, заблокирован, не взял трубку), PING — не в сети, HLR — не обслуживается (заблокирован)
312
- # 0 | Новое | Нет | Новое сообщение/запрос, ожидает обработки у нас на сервере
313
- # 1 | В очереди | Нет | Сообщение или запрос ожидают отправки на сервере оператора
314
- # 2 | Доставлено | Да | Доставлено, звонок совершен, PING — в сети, HLR — обслуживается
315
- # 3 | Отложено | Нет | Отложенная отправка, отправка сообщения/запроса запланирована на другое время
316
- #
317
- # @example
318
- # client.sms_status #=> 2
330
+ # @deprecated (in favor of {#broadcast_status})
319
331
  #
320
332
  def sms_status
321
- @response_data.dig("send", 0, "status")&.to_i if sms_sent?
333
+ broadcast_status
322
334
  end
323
335
 
324
336
 
@@ -353,11 +365,20 @@ module SmsPilot
353
365
  #
354
366
  private def build_uri(phone, text)
355
367
  URI.parse(API_ENDPOINT).tap do |uri|
356
- uri.query = URI.encode_www_form({ apikey: @api_key, format: :json, send: text, to: phone })
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
+ })
357
376
  end
358
377
  end
359
378
 
360
379
 
380
+
381
+
361
382
  # Cleans up your phone from anything but digits. Also replaces 8 to 7 if it is the first digit.
362
383
  #
363
384
  # @private
@@ -3,6 +3,6 @@
3
3
  module SmsPilot
4
4
 
5
5
  # Gem version
6
- VERSION = "0.0.8"
6
+ VERSION = "0.0.9"
7
7
 
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms-pilot-api-v1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Pedan