mpi_client 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mpi_client/error_parser.rb +2 -1
- data/lib/mpi_client/request.rb +23 -1
- data/lib/mpi_client.rb +1 -0
- metadata +2 -2
@@ -6,7 +6,8 @@ module MPIClient
|
|
6
6
|
|
7
7
|
def self.parse(error_message, error_code)
|
8
8
|
result = Hash.new
|
9
|
-
|
9
|
+
base_message = get_base_message(error_message, error_code)
|
10
|
+
result[:base] = base_message if base_message
|
10
11
|
error_message.scan(/(?:\ |\()([A-Z].*?)\./) do |error_field, second_field|
|
11
12
|
field_name = error_field[/^.*\ \[(.*)\].*$/, 1]
|
12
13
|
error_str = error_field.gsub(/\ \[.*\]/,'')
|
data/lib/mpi_client/request.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module MPIClient
|
2
2
|
class Request
|
3
|
-
|
3
|
+
FILTERED_FIELDS = %w(Password PublicCertificate PrivateKey)
|
4
|
+
CLIENT_METHODS = %w(create_account get_account_info update_account delete_account verify)
|
4
5
|
|
5
6
|
def initialize
|
6
7
|
@connection = Network::Connection.new(MPIClient.server_url)
|
8
|
+
@connection.logger = MPIClient.logger if MPIClient.logger
|
9
|
+
set_logger_filters
|
7
10
|
end
|
8
11
|
|
9
12
|
def method_missing(method, *args)
|
@@ -11,6 +14,25 @@ module MPIClient
|
|
11
14
|
end
|
12
15
|
|
13
16
|
private
|
17
|
+
def set_logger_filters
|
18
|
+
filter = lambda {|data| filter_xml_data(data, FILTERED_FIELDS) }
|
19
|
+
@connection.request_filter = @connection.response_filter = filter
|
20
|
+
end
|
21
|
+
|
22
|
+
def filter_xml_data(request, *filtered_params)
|
23
|
+
filter_data(request, filtered_params) do |data, param|
|
24
|
+
data.gsub!(%r{<(#{param})>(.*?)</#{param}>}, '<\1>[FILTERED]</\1>')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def filter_data(data, *filtered_params)
|
29
|
+
data = data.dup
|
30
|
+
filtered_params.flatten.each do |param|
|
31
|
+
yield(data, param)
|
32
|
+
end
|
33
|
+
data
|
34
|
+
end
|
35
|
+
|
14
36
|
def submit_request(request_type, *args)
|
15
37
|
parse_response(@connection.post(prepare_request_data(request_type, *args)))
|
16
38
|
end
|
data/lib/mpi_client.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpi_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Plashchynski
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-10-
|
13
|
+
date: 2009-10-29 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|