moneta-api 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moneta/api/connection_exception.rb +5 -0
- data/lib/moneta/api/exception.rb +5 -1
- data/lib/moneta/api/http_exception.rb +21 -1
- data/lib/moneta/api/runtime_exception.rb +24 -1
- data/lib/moneta/api/service_methods.rb +11 -2
- data/lib/moneta/api/types/confirm_transaction_batch_request_type.rb +3 -4
- data/lib/moneta/api/version.rb +1 -1
- data/lib/moneta/api.rb +1 -0
- data/spec/lib/moneta/api/connection_exception_spec.rb +9 -0
- data/spec/lib/moneta/api/http_exception_spec.rb +19 -0
- data/spec/lib/moneta/api/runtime_exception_spec.rb +21 -0
- data/spec/lib/moneta/api/service_spec.rb +1 -1
- data/spec/lib/moneta/api/types/confirm_transaction_batch_request_type_spec.rb +19 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b259ad7ef797550ed047b3c8574a71e52b97f2e
|
4
|
+
data.tar.gz: ebc37bd7040d7fce6868e23d90704000827a5f7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3a331bb23264266da8355fac205bb0287b253e84e6e03a1dd1e9134a433db26bd6d9557814d6c56e55e5b824a625794fa861f2729284133300163474b111a07
|
7
|
+
data.tar.gz: fe34ca732de7d0a369e3637ad99574d3c0efda9de2229a4145e6162342089276cc6ff7fe4bc6cf3cf7e0b4603b1383c7587d21a10e289f03df65409862cc5414
|
data/lib/moneta/api/exception.rb
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
module Moneta
|
2
2
|
module Api
|
3
|
-
class HTTPException < Exception
|
3
|
+
class HTTPException < Exception
|
4
|
+
attr_reader :code
|
5
|
+
|
6
|
+
def initialize(code, message)
|
7
|
+
super(message)
|
8
|
+
|
9
|
+
@code = code
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def inspect
|
14
|
+
"#{ @code }: #{ message }"
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
{
|
19
|
+
code: code,
|
20
|
+
message: message,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
4
24
|
end
|
5
25
|
end
|
@@ -1,5 +1,28 @@
|
|
1
1
|
module Moneta
|
2
2
|
module Api
|
3
|
-
class RuntimeException < Exception
|
3
|
+
class RuntimeException < Exception
|
4
|
+
attr_reader :code, :detail
|
5
|
+
|
6
|
+
def initialize(code, message, detail)
|
7
|
+
super(message)
|
8
|
+
|
9
|
+
@code = code
|
10
|
+
@detail = detail
|
11
|
+
end
|
12
|
+
|
13
|
+
def inspect
|
14
|
+
error = [ "#{ @code }: #{ message }" ]
|
15
|
+
error += detail.collect { |key, value| "#{ key }: #{ Array(value).join($/) }" }
|
16
|
+
error.join($/)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_hash
|
20
|
+
{
|
21
|
+
code: code,
|
22
|
+
message: message,
|
23
|
+
detail: detail
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
4
27
|
end
|
5
28
|
end
|
@@ -192,9 +192,18 @@ module Moneta
|
|
192
192
|
|
193
193
|
ResponseFactory.build(response)
|
194
194
|
rescue Savon::SOAPFault => e
|
195
|
-
|
195
|
+
error_details = e.to_hash[:fault]
|
196
|
+
|
197
|
+
message = error_details[:faultstring]
|
198
|
+
code = error_details[:faultcode]
|
199
|
+
detail = error_details[:detail]
|
200
|
+
|
201
|
+
raise Moneta::Api::RuntimeException.new(code, message, detail)
|
196
202
|
rescue Savon::HTTPError => e
|
197
|
-
|
203
|
+
http = e.http
|
204
|
+
raise Moneta::Api::HTTPException.new(http.code, http.body)
|
205
|
+
rescue HTTPI::Error => e
|
206
|
+
raise Moneta::Api::ConnectionException.new(e.message)
|
198
207
|
end
|
199
208
|
|
200
209
|
def validate!(method, request)
|
@@ -31,14 +31,13 @@ module Moneta
|
|
31
31
|
# Операции выполняются в том порядке, в котором они переданы в запросе.
|
32
32
|
# / Set of transfers to be processed in one batch. Processed in order of appearance.
|
33
33
|
#
|
34
|
-
# @param [Moneta::Api::Types::
|
34
|
+
# @param [Moneta::Api::Types::ConfirmTransactionRequestType]
|
35
35
|
# @return void
|
36
36
|
def add_transaction(item)
|
37
|
-
|
38
|
-
if parents.include?(Moneta::Api::Types::Entity)
|
37
|
+
if item.is_a?(Moneta::Api::Types::ConfirmTransactionRequestType)
|
39
38
|
(@transaction ||=[]).push(item)
|
40
39
|
else
|
41
|
-
raise TypeError.new("TypeError: #{ item.class }
|
40
|
+
raise TypeError.new("TypeError: #{ item.class } should be a Moneta::Api::Types::ConfirmTransactionRequestType")
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
data/lib/moneta/api/version.rb
CHANGED
data/lib/moneta/api.rb
CHANGED
@@ -9,6 +9,7 @@ require 'moneta/api/key_value_serializer'
|
|
9
9
|
require 'moneta/api/exception'
|
10
10
|
require 'moneta/api/runtime_exception'
|
11
11
|
require 'moneta/api/http_exception'
|
12
|
+
require 'moneta/api/connection_exception'
|
12
13
|
|
13
14
|
require 'moneta/api/types/account_access_info'
|
14
15
|
require 'moneta/api/types/account_info'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe Moneta::Api::HTTPException do
|
2
|
+
let(:message) { 'Server Error' }
|
3
|
+
let(:code) { '500' }
|
4
|
+
|
5
|
+
let(:exception) { described_class.new(code, message) }
|
6
|
+
|
7
|
+
describe '.to_hash' do
|
8
|
+
subject { exception.to_hash }
|
9
|
+
|
10
|
+
its([:message]) { is_expected.to eq message }
|
11
|
+
its([:code]) { is_expected.to eq code }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.inspect' do
|
15
|
+
subject { exception }
|
16
|
+
|
17
|
+
its(:inspect) { is_expected.to eq '500: Server Error' }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
describe Moneta::Api::RuntimeException do
|
2
|
+
let(:message) { 'error' }
|
3
|
+
let(:code) { 'SOAP-ENV:Client' }
|
4
|
+
let(:detail) { { foo: ['bar'] } }
|
5
|
+
|
6
|
+
let(:exception) { described_class.new(code, message, detail) }
|
7
|
+
|
8
|
+
describe '.to_hash' do
|
9
|
+
subject { exception.to_hash }
|
10
|
+
|
11
|
+
its([:message]) { is_expected.to eq message }
|
12
|
+
its([:code]) { is_expected.to eq code }
|
13
|
+
its([:detail]) { is_expected.to eq detail }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.inspect' do
|
17
|
+
subject { exception }
|
18
|
+
|
19
|
+
its(:inspect) { is_expected.to eq "SOAP-ENV:Client: error#{ $/ }foo: bar" }
|
20
|
+
end
|
21
|
+
end
|
@@ -14,7 +14,7 @@ describe Moneta::Api::Service do
|
|
14
14
|
context 'when soap raise error' do
|
15
15
|
let(:account_id) { -1 }
|
16
16
|
|
17
|
-
it { expect { subject }.to raise_exception(Moneta::Api::RuntimeException, '
|
17
|
+
it { expect { subject }.to raise_exception(Moneta::Api::RuntimeException, 'Validation error') }
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'when soap http error' do
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe Moneta::Api::Types::ConfirmTransactionBatchRequestType do
|
2
|
+
describe '.add_transaction' do
|
3
|
+
let(:request) { described_class.new }
|
4
|
+
|
5
|
+
it 'should add transaction' do
|
6
|
+
transaction = Moneta::Api::Types::ConfirmTransactionRequestType.new
|
7
|
+
|
8
|
+
request.add_transaction(transaction)
|
9
|
+
|
10
|
+
expect(request.transaction).to include transaction
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should not add with wrong type' do
|
14
|
+
transaction = Moneta::Api::Types::Entity.new
|
15
|
+
|
16
|
+
expect { request.add_transaction(transaction) }.to raise_exception TypeError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneta-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ssnikolay
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-01-
|
12
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- README.md
|
169
169
|
- Rakefile
|
170
170
|
- lib/moneta/api.rb
|
171
|
+
- lib/moneta/api/connection_exception.rb
|
171
172
|
- lib/moneta/api/data_mapper.rb
|
172
173
|
- lib/moneta/api/exception.rb
|
173
174
|
- lib/moneta/api/http_exception.rb
|
@@ -273,6 +274,8 @@ files:
|
|
273
274
|
- lib/moneta/api/version.rb
|
274
275
|
- lib/moneta/core_ext/string.rb
|
275
276
|
- moneta-api.gemspec
|
277
|
+
- spec/lib/moneta/api/connection_exception_spec.rb
|
278
|
+
- spec/lib/moneta/api/http_exception_spec.rb
|
276
279
|
- spec/lib/moneta/api/requests/approve_phone_send_confirmation_request_spec.rb
|
277
280
|
- spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
|
278
281
|
- spec/lib/moneta/api/requests/authorise_transaction_request_spec.rb
|
@@ -291,7 +294,9 @@ files:
|
|
291
294
|
- spec/lib/moneta/api/requests/profile/edit_organization_profile_request_spec.rb
|
292
295
|
- spec/lib/moneta/api/requests/transfer_request_spec.rb
|
293
296
|
- spec/lib/moneta/api/response/find_account_by_id_spec.rb
|
297
|
+
- spec/lib/moneta/api/runtime_exception_spec.rb
|
294
298
|
- spec/lib/moneta/api/service_spec.rb
|
299
|
+
- spec/lib/moneta/api/types/confirm_transaction_batch_request_type_spec.rb
|
295
300
|
- spec/lib/moneta/api/types/operation_info_spec.rb
|
296
301
|
- spec/lib/moneta/api/types/profile/client_spec.rb
|
297
302
|
- spec/spec_helper.rb
|
@@ -360,6 +365,8 @@ signing_key:
|
|
360
365
|
specification_version: 4
|
361
366
|
summary: "МОНЕТА.РУ (MONETA.MerchantAPI.v2)"
|
362
367
|
test_files:
|
368
|
+
- spec/lib/moneta/api/connection_exception_spec.rb
|
369
|
+
- spec/lib/moneta/api/http_exception_spec.rb
|
363
370
|
- spec/lib/moneta/api/requests/approve_phone_send_confirmation_request_spec.rb
|
364
371
|
- spec/lib/moneta/api/requests/authorise_transaction_batch_request_spec.rb
|
365
372
|
- spec/lib/moneta/api/requests/authorise_transaction_request_spec.rb
|
@@ -378,7 +385,9 @@ test_files:
|
|
378
385
|
- spec/lib/moneta/api/requests/profile/edit_organization_profile_request_spec.rb
|
379
386
|
- spec/lib/moneta/api/requests/transfer_request_spec.rb
|
380
387
|
- spec/lib/moneta/api/response/find_account_by_id_spec.rb
|
388
|
+
- spec/lib/moneta/api/runtime_exception_spec.rb
|
381
389
|
- spec/lib/moneta/api/service_spec.rb
|
390
|
+
- spec/lib/moneta/api/types/confirm_transaction_batch_request_type_spec.rb
|
382
391
|
- spec/lib/moneta/api/types/operation_info_spec.rb
|
383
392
|
- spec/lib/moneta/api/types/profile/client_spec.rb
|
384
393
|
- spec/spec_helper.rb
|