turbosms 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/turbosms/client.rb +16 -4
- data/lib/turbosms/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecc2f2bb8d81f81beae1bfd088b9bcf974f2e3c4
|
4
|
+
data.tar.gz: 63fa21be68b7b9e1ea83e56764748c778a9cf71c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48f995de4b6ad04cd021f34f922731a5ef5e40b8e7eb223b3916238cfe4ce7c7b0c943664f18a23ef8e2e92a31c87c9e63ecc93d111298da11f5de0f2e995bec
|
7
|
+
data.tar.gz: affa7612dced4b108c203bb4bde287aaab75bee7341814b2dc1d0fa5a05549fbe2b284608bfd90869aee8bb247b953dcb71883cccbe9a3c4f1dfd977bab0a519
|
data/lib/turbosms/client.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'savon'
|
2
2
|
|
3
3
|
module TurboSMS
|
4
|
+
COOKIE_EXPTIRATION_TIMEOUT = 60*60*12
|
5
|
+
|
4
6
|
class << self
|
5
7
|
|
6
8
|
private
|
@@ -10,7 +12,7 @@ module TurboSMS
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def authorized?
|
13
|
-
!@cookies.nil?
|
15
|
+
!@cookies.nil? and @cookies_expires_at > Time.now
|
14
16
|
end
|
15
17
|
|
16
18
|
def auth_message
|
@@ -21,7 +23,7 @@ module TurboSMS
|
|
21
23
|
def authorize
|
22
24
|
response = client.call(:auth, message: auth_message)
|
23
25
|
result = response.body[:auth_response][:auth_result]
|
24
|
-
|
26
|
+
store_cookies response.http.cookies if (result.length == 27) # Ridiculous # Вы успешно авторизировались
|
25
27
|
raise AuthError, result unless authorized?
|
26
28
|
end
|
27
29
|
|
@@ -31,9 +33,19 @@ module TurboSMS
|
|
31
33
|
response = client.call(method_name, args.merge(cookies: @cookies))
|
32
34
|
result = response.body[response_key][result_key]
|
33
35
|
result = result[:result_array] if result.instance_of?(Hash) and !result[:result_array].nil?
|
34
|
-
|
36
|
+
clear_cookie if !result.instance_of?(Array) and result.length == 20 # Ridiculous # Вы не авторизированы
|
35
37
|
result
|
36
38
|
end
|
37
39
|
|
40
|
+
def store_cookies(cookies)
|
41
|
+
@cookies = cookies
|
42
|
+
@cookies_expires_at = Time.now + COOKIE_EXPTIRATION_TIMEOUT
|
43
|
+
end
|
44
|
+
|
45
|
+
def clear_cookies
|
46
|
+
@cookies = nil
|
47
|
+
@cookies_expires_at = nil
|
48
|
+
end
|
49
|
+
|
38
50
|
end
|
39
|
-
end
|
51
|
+
end
|
data/lib/turbosms/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module TurboSMS
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
2
|
+
VERSION = '0.1.3'
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbosms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitalik Danchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|