terasms 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26b7495307de0b909a483c6f1739cf624913dd544254fd547f68d74cbac3d192
4
- data.tar.gz: 2057616cc214fa59be511a74e28402fbc2de2ca5181f85baf96bdf7210cca08b
3
+ metadata.gz: 8417b366f161a1c4eb3520cfbfca4c78e91a2fb22ff725ec3e3d349bd2e9d0c6
4
+ data.tar.gz: 041b87d001e9677c37c2cc39100186adb64ef6c04817a1b22a23d5b09c6a6211
5
5
  SHA512:
6
- metadata.gz: 976ed8292ae3cfa1de361b5aae2a3e63946a951271e4acfe60fa48a90ba79bc80449af94183db1e1c1e496cfc6cc88c7a714bfea2355a37ccd81a15ef9f40ecf
7
- data.tar.gz: bf36315b1a295bab2f7b1e4e2ebac03266106ea1c3905e3f2cc5271b73661d04cdbc4e306c6c56fcf129f47bf85d53b32d78ebf78205eb4084ae3304816a5da2
6
+ metadata.gz: 31b75cfac7560ec2aca18ecd2b903c12a62d2e6f97a5cd57709eaaeb88938b6d4c12440fefcfd1e60790cb96277c55a21f7e8915561083f9c8db896920067dd0
7
+ data.tar.gz: 18bfa0cc7172d731857cf22b23026ba46c826e6d79646e3bf4c94dc41ffc6f4d326f9871ba3aeaff42ea70e1197e06a2242392116f33ca887d8cce2412f7011d
data/README.md CHANGED
@@ -3,12 +3,24 @@
3
3
  ### Description
4
4
  Sending messages via Terasms
5
5
 
6
+ ### Install:
7
+
8
+ ```ruby
9
+ gem install terasms
10
+ ```
11
+ or
12
+ ```ruby
13
+ gem 'terasms'
14
+ ```
6
15
  ### Usage:
16
+
7
17
  ```ruby
8
18
  require 'terasms'
9
19
 
10
20
  Terasms.configure do |config|
11
- config.url = "https://auth.terasms.ru/outbox/send"
21
+ config.url = "https://auth.terasms.ru/outbox/send/json"
22
+ config.balance_url = "https://auth.terasms.ru/outbox/balance/json/"
23
+ config.status_url = "https://auth.terasms.ru/outbox/getstatus/json"
12
24
  config.login = "Your_user_name"
13
25
  config.password = "Passwd"
14
26
  config.sign = "your_token"
@@ -17,7 +29,24 @@ Terasms.configure do |config|
17
29
  end
18
30
 
19
31
  api = Terasms::Sms.new
20
- result = api.send({target: "+77501112233", message: "Привет Мир! Тест рассылки смс"})
32
+
33
+ puts api.balance # => {"status"=>"success", "result"=>{"status"=>0, "status_description"=>"OK", "balance"=>-36534.651, "pay_type"=>"after"}}
34
+
35
+ message = api.send({target: "+77501112233", message: "Hello Yarkiy world!"})
36
+
37
+ # =>
38
+ {"status"=>"success",
39
+ "result"=>
40
+ {"status"=>0,
41
+ "status_description"=>"OK",
42
+ "message_infos"=>
43
+ [{"msisdn"=>"+79500466321", "id"=>"1042924450", "status"=>0, "price"=>0}]},
44
+ "id"=>"1042924450"}
45
+
46
+ message_id = message["id"] # => 1042924450
47
+
48
+ puts "Message status: #{api.status(1042924450)}" #=> {"result"=>"success", "status"=>"12", "status_desc"=>"delivered"}
49
+
21
50
  ```
22
51
  ### License
23
- MIT License. Copyright 2019 isheninp@gmail.com
52
+ MIT License. Copyright 2019 Pavel Ishenin / isheninp@gmail.com
@@ -25,7 +25,7 @@ module Terasms
25
25
  when 'POST'
26
26
  http.post(uri.request_uri, body, headers)
27
27
  else
28
- raise 'unknown protocol'
28
+ raise 'unknown http method'
29
29
  end
30
30
  result = case type
31
31
  when 'json'
data/lib/terasms.rb CHANGED
@@ -153,14 +153,6 @@ module Terasms
153
153
  submit(Terasms.config.status_url, {}, 'POST', 'json', Terasms.config.to_h.slice(:login, :password, :sign).merge({'message_ids': array_of_id}).to_json)
154
154
  end
155
155
 
156
- def status_ id
157
- begin
158
- {"result"=> "success"}.merge(statuses([id])["result"]["statuses"].last.slice("status", "status_desc"))
159
- rescue => error
160
- {"result"=> "error", "info" => error.to_s}
161
- end
162
- end
163
-
164
156
  def status id
165
157
  begin
166
158
  raise 'wrong message id' if statuses([id])["result"]["statuses"] == []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terasms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Ishenin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-22 00:00:00.000000000 Z
11
+ date: 2019-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Terasms http rest api '
14
14
  email: isheninp@gmail.com