laximo 0.5.2 → 0.6.0
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/README.md +16 -1
- data/lib/laximo/options.rb +21 -0
- data/lib/laximo/request.rb +39 -8
- data/lib/laximo/respond.rb +7 -2
- data/lib/laximo/version.rb +1 -1
- 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: 4fcfbd57c0d9ef6284903aafa0de563f8a55a447
|
|
4
|
+
data.tar.gz: 8af6e937f01403fc698c01730844538bcfb30af2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90fb0f07fb837e466cdb9df2e736ac9eb684e54d832bb2d9702812fb7383c1cd471af11c6e46376321db49585bdc2a16de80bf55a767d7bac18953f3b80e02d4
|
|
7
|
+
data.tar.gz: d9492e42c82f47283a7a6b69f0ebb84fe8b98b148a46759d18e007eca6f5e8fdcace6c28e9935720cfcbb4f25527ade67e3e96371ed609d7c98859bf6ce08125
|
data/README.md
CHANGED
|
@@ -17,6 +17,17 @@ Laximo.options.ssl_key ::File.join(Rails.root, 'db', 'ssl', 'client.k
|
|
|
17
17
|
Laximo.options.ssl_cert ::File.join(Rails.root, 'db', 'ssl', 'client.pem')
|
|
18
18
|
Laximo.options.ssl_verify false
|
|
19
19
|
|
|
20
|
+
Laximo.options.timeout 10
|
|
21
|
+
Laximo.options.debug false
|
|
22
|
+
```
|
|
23
|
+
или для авторизации по подписке
|
|
24
|
+
```ruby
|
|
25
|
+
Laximo.options.use_ssl true
|
|
26
|
+
Laximo.options.use_login true
|
|
27
|
+
Laximo.options.login 'mylogin' # имейте в виду, что такие параметры
|
|
28
|
+
Laximo.options.password 'mypassword' # должны быть вынесены в переменные окружения
|
|
29
|
+
Laximo.options.ssl_verify false
|
|
30
|
+
|
|
20
31
|
Laximo.options.timeout 10
|
|
21
32
|
Laximo.options.debug false
|
|
22
33
|
```
|
|
@@ -26,6 +37,9 @@ Laximo.options.debug false
|
|
|
26
37
|
* `Laximo.options.ssl_cert "путь_к_файлу"` — путь к закрытому ключу ssl-сертификата
|
|
27
38
|
* `Laximo.options.ssl_cert true/false` — проверять или нет валидность сертификата. **В случае самоподписанного сертификата, проверку на валидность необходимо отключить**
|
|
28
39
|
* `Laximo.options.use_ssl true/false` - использовать ssl-соединение или нет
|
|
40
|
+
* `Laximo.options.use_login true/false` - использовать авторизацию по подписке или нет
|
|
41
|
+
* `Laximo.options.login` - логин для авторизации по подписке
|
|
42
|
+
* `Laximo.options.password` - пароль для авторизации по подписке
|
|
29
43
|
* `Laximo.options.timeout 30` - таймаут соединения в секундах (по-умочланию, 10)
|
|
30
44
|
* `Laximo.options.user_agent "Ваш_юзер_агент"` - задание произвольного юзер-агента (по-умолчанию, "LaximoRuby [версия_библиотеки]")
|
|
31
45
|
* `Laximo.options.debug true/false` - включение/отключение режима отладки (по-умолчанию, выключено)
|
|
@@ -107,10 +121,11 @@ res.error # <Laximo::SoapInvalidParameterError: UnitId>
|
|
|
107
121
|
res.result # []
|
|
108
122
|
```
|
|
109
123
|
|
|
110
|
-
Помимо
|
|
124
|
+
Помимо перечисленного списка ошибок, в ответе могут быть возвращены стандартные ошибки библиотеки `Net::HTTP` и интерпретатора Ruby.
|
|
111
125
|
|
|
112
126
|
### Лицензия
|
|
113
127
|
|
|
114
128
|
Автор: [Tyralion](mailto:piliaiev@gmail.com)
|
|
129
|
+
[Список контрибьюторов](https://github.com/dancingbytes/laximo/graphs/contributors)
|
|
115
130
|
|
|
116
131
|
Copyright (c) 2015-2016 DansingBytes.ru, под лицензией BSD
|
data/lib/laximo/options.rb
CHANGED
|
@@ -5,6 +5,27 @@ module Laximo
|
|
|
5
5
|
|
|
6
6
|
extend self
|
|
7
7
|
|
|
8
|
+
def use_login(str = nil)
|
|
9
|
+
|
|
10
|
+
return @use_login if str.nil?
|
|
11
|
+
@use_login = str === true
|
|
12
|
+
|
|
13
|
+
end # use login
|
|
14
|
+
|
|
15
|
+
def login(str = nil)
|
|
16
|
+
|
|
17
|
+
return @login if str.nil?
|
|
18
|
+
@login = str
|
|
19
|
+
|
|
20
|
+
end # login
|
|
21
|
+
|
|
22
|
+
def password(str = nil)
|
|
23
|
+
|
|
24
|
+
return @password if str.nil?
|
|
25
|
+
@password = str
|
|
26
|
+
|
|
27
|
+
end # password
|
|
28
|
+
|
|
8
29
|
def ssl_key(str = nil)
|
|
9
30
|
|
|
10
31
|
return @ssl_key if str.nil?
|
data/lib/laximo/request.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
module Laximo
|
|
3
3
|
|
|
4
4
|
REQUEST_MSG = %q(<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -12,6 +12,19 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
|
|
|
12
12
|
</SOAP-ENV:Body>
|
|
13
13
|
</SOAP-ENV:Envelope>).freeze
|
|
14
14
|
|
|
15
|
+
REQUEST_LOGIN_MSG = %q(<?xml version="1.0" encoding="UTF-8"?>
|
|
16
|
+
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
|
17
|
+
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
18
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
|
|
19
|
+
<SOAP-ENV:Body>
|
|
20
|
+
<ns5692:QueryDataLogin xmlns:ns5692="%{act}">
|
|
21
|
+
<request xsi:type="xsd:string">%{msg}</request>
|
|
22
|
+
<login xsi:type="xsd:string">%{login}</login>
|
|
23
|
+
<hmac xsi:type="xsd:string">%{hash}</hmac>
|
|
24
|
+
</ns5692:QueryDataLogin>
|
|
25
|
+
</SOAP-ENV:Body>
|
|
26
|
+
</SOAP-ENV:Envelope>).freeze
|
|
27
|
+
|
|
15
28
|
class Request
|
|
16
29
|
|
|
17
30
|
def initialize(soap_endpoint, soap_action)
|
|
@@ -30,13 +43,22 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
|
|
|
30
43
|
|
|
31
44
|
def call(msg)
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
if ::Laximo.options.use_login
|
|
47
|
+
@request.body = REQUEST_LOGIN_MSG % {
|
|
48
|
+
msg: msg,
|
|
49
|
+
act: @soap_action,
|
|
50
|
+
login: ::Laximo.options.login,
|
|
51
|
+
hash: hash(msg, ::Laximo.options.password)
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
@request.body = REQUEST_MSG % {
|
|
55
|
+
msg: msg,
|
|
56
|
+
act: @soap_action
|
|
57
|
+
}
|
|
58
|
+
end
|
|
37
59
|
|
|
38
60
|
begin
|
|
39
|
-
@http.request
|
|
61
|
+
@http.request @request
|
|
40
62
|
rescue => ex
|
|
41
63
|
ex
|
|
42
64
|
end
|
|
@@ -50,10 +72,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
|
|
|
50
72
|
@http.set_debug_output($stdout) if ::Laximo.options.debug?
|
|
51
73
|
|
|
52
74
|
@http.use_ssl = ::Laximo.options.use_ssl
|
|
53
|
-
@http.key = ::Laximo.options.ssl_key
|
|
54
|
-
@http.cert = ::Laximo.options.ssl_cert
|
|
55
75
|
@http.verify_mode = ::Laximo.options.ssl_verify
|
|
56
76
|
|
|
77
|
+
unless ::Laximo.options.use_login
|
|
78
|
+
@http.key = ::Laximo.options.ssl_key
|
|
79
|
+
@http.cert = ::Laximo.options.ssl_cert
|
|
80
|
+
end
|
|
81
|
+
|
|
57
82
|
@http.open_timeout = ::Laximo.options.timeout
|
|
58
83
|
@http.read_timeout = ::Laximo.options.timeout
|
|
59
84
|
@http.ssl_timeout = ::Laximo.options.timeout
|
|
@@ -73,6 +98,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
|
|
|
73
98
|
|
|
74
99
|
end # set_request_params
|
|
75
100
|
|
|
101
|
+
def hash(command, password)
|
|
102
|
+
|
|
103
|
+
Digest::MD5::hexdigest "#{command}#{password}"
|
|
104
|
+
|
|
105
|
+
end # hash
|
|
106
|
+
|
|
76
107
|
end # Request
|
|
77
108
|
|
|
78
109
|
end # Laximo
|
data/lib/laximo/respond.rb
CHANGED
|
@@ -6,6 +6,7 @@ module Laximo
|
|
|
6
6
|
class Base
|
|
7
7
|
|
|
8
8
|
RESPONSE_RESULT = '//QueryDataResponse/return'.freeze
|
|
9
|
+
RESPONSE_LOGIN_RESULT = '//QueryDataLoginResponse/return'.freeze
|
|
9
10
|
RESPONSE_SOAP_ERROR = '//Fault/faultstring'.freeze
|
|
10
11
|
|
|
11
12
|
def initialize(request)
|
|
@@ -122,11 +123,15 @@ module Laximo
|
|
|
122
123
|
doc = ::Nokogiri::XML(http.body)
|
|
123
124
|
doc.remove_namespaces!
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
if ::Laximo.options.use_login
|
|
127
|
+
res = doc.xpath(RESPONSE_LOGIN_RESULT).children[0].to_s
|
|
128
|
+
else
|
|
129
|
+
res = doc.xpath(RESPONSE_RESULT).children[0].to_s
|
|
130
|
+
end
|
|
126
131
|
|
|
127
132
|
@error = nil
|
|
128
133
|
@result = parsing_result(
|
|
129
|
-
|
|
134
|
+
::Nokogiri::XML(unescape(res))
|
|
130
135
|
) || []
|
|
131
136
|
|
|
132
137
|
rescue => ex
|
data/lib/laximo/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: laximo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan Pilyaev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|