mpi_client 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ module MPIClient
2
+ module ErrorParser
3
+ def self.get_base_message(error_message, error_code)
4
+ error_message[/^(.*?)(?:\ \(|$)/, 1] unless error_code == 'C5'
5
+ end
6
+
7
+ def self.parse(error_message, error_code)
8
+ result = Hash.new
9
+ result[:base] = get_base_message(error_message, error_code)
10
+ error_message.scan(/(?:\ |\()([A-Z].*?)\./) do |error_field, second_field|
11
+ field_name = error_field[/^.*\ \[(.*)\].*$/, 1]
12
+ error_str = error_field.gsub(/\ \[.*\]/,'')
13
+ result[OptionTranslator.to_client(field_name.to_sym)] = error_str
14
+ end
15
+ result
16
+ end
17
+ end
18
+ end
@@ -9,7 +9,7 @@ module MPIClient
9
9
  :country_code => :CountryCode,
10
10
  :password => :Password,
11
11
  :certificate => :PublicCertificate,
12
- :private_key => :PrivateKey,
12
+ :private_key => :PrivateKey,
13
13
  :directory_server_url => :DirectoryServerURL,
14
14
  :country_code => :CountryCode,
15
15
  :brand => :CardType,
@@ -35,7 +35,8 @@ module MPIClient
35
35
  if error = doc.xpath("//Error").first
36
36
  response = {
37
37
  :error_message => error.text,
38
- :error_code => error[:code]
38
+ :error_code => error[:code],
39
+ :errors => ErrorParser.parse(error.text, error[:code]),
39
40
  }
40
41
  else
41
42
  response = Hash[*doc.xpath("//Transaction/*").collect{|a| [OptionTranslator.to_client(a.name.to_sym), a.text] }.flatten]
data/lib/mpi_client.rb CHANGED
@@ -10,5 +10,6 @@ module MPIClient
10
10
  autoload :OptionTranslator, 'mpi_client/option_translator'
11
11
  autoload :Request, 'mpi_client/request'
12
12
  autoload :Response, 'mpi_client/response'
13
+ autoload :ErrorParser, 'mpi_client/error_parser'
13
14
  autoload :Verification, 'mpi_client/verification'
14
15
  end
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.5
4
+ version: 0.0.6
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-26 00:00:00 +02:00
13
+ date: 2009-10-28 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -55,6 +55,7 @@ files:
55
55
  - lib/mpi_client/option_translator.rb
56
56
  - lib/mpi_client/request.rb
57
57
  - lib/mpi_client/response.rb
58
+ - lib/mpi_client/error_parser.rb
58
59
  - lib/mpi_client/verification/request.rb
59
60
  - lib/mpi_client/verification/response.rb
60
61
  - lib/mpi_client/verification.rb
@@ -83,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
84
  requirements: []
84
85
 
85
86
  rubyforge_project:
86
- rubygems_version: 1.3.4
87
+ rubygems_version: 1.3.5
87
88
  signing_key:
88
89
  specification_version: 3
89
90
  summary: MPI client library