fintecture 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 380ee5e078235f8c550e02cd80251b1d75a75a5cf9d3214fe3002fc64a8b45bb
4
- data.tar.gz: fe2cb7a9cf8ae4bdc4ad9277bec47464ca2c5bd78fed48e76e586a2898b468bc
3
+ metadata.gz: b35fbfdb87c9ffc11f3faa4bf87130b1d926f1e5ee2d3db0e43e7a5138b12d8d
4
+ data.tar.gz: 1d6b107a7cf07ca35d69a726b48b0c732323fc4d8271d7c1fd872509d68a0eac
5
5
  SHA512:
6
- metadata.gz: 53e538a15c2e0d543584cd6b82f63a10162f36565cdff4acea3cbc432826692e0ff7cbb89ddbf125a0c026ac6602d8126262f914977bc6de0381fe53738d4a73
7
- data.tar.gz: f4ff6bae4d2b8fb0b38b05f28da8c991bf55eb9da97bf5b694499588b3433dc80fa3b6ecb0107a78948c6eccaf2fec78fe704cc40cf542869243336a9af856c3
6
+ metadata.gz: ea46a0531764adecf7005404f80989a96da42a8f9a4c26b4b5e62e691741151c997893b2f2cc6d57270f440b67d6924116ae207cf7247ef0d1dd98da83c88209
7
+ data.tar.gz: 46571be0cd4697af398b668cf7595a59d24590c66db364b0a1edda23cb9f4b2767be3ebb75c5b61b40bad988d23c252b9f46cb3d67373c241495f6b9ad24f146
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fintecture (0.5.0)
4
+ fintecture (0.5.1)
5
5
  faraday
6
6
 
7
7
  GEM
@@ -12,61 +12,34 @@ module Fintecture
12
12
  def error(res)
13
13
  body = JSON.parse res.body
14
14
 
15
- # Errors array
16
- if body['code'] && body['log_id'] && body['errors']
17
- raise _construct_message_errors(res, body)
18
- # Single error
19
- else
20
- raise _construct_message_error(res, body)
21
- end
15
+ raise construct_message_errors(res.status, body)
22
16
  end
23
17
 
24
18
  private
25
19
 
26
- def _construct_message_errors(res, body)
27
- status = res.status
28
- code = body['code']
29
- log_id = body['log_id']
30
- errors_array = body['errors']
20
+ def construct_message_errors(status, body)
21
+ code = body['code'].presence
22
+ log_id = body['log_id'].presence
23
+ errors_array = body['errors'].presence || body['meta'].presence || []
31
24
 
32
25
  error_string = "\nFintecture server errors : "
33
- error_string += "\n status: #{status} "
34
- error_string += "\n code: #{code}"
35
- error_string += "\n id : #{log_id}"
26
+ error_string += "\n status: #{status} " if status
27
+ error_string += "\n code: #{code}" if code
28
+ error_string += "\n id : #{log_id}" if log_id
36
29
 
37
- errors_array.compact.each do |error|
30
+ errors_array.compact!
31
+ errors_array.each do |error|
38
32
  formated_error = error
39
33
  formated_error = error.map { |key, value| " #{key}: #{value}" }.join("\n") if error.is_a?(Hash)
40
34
  error_string += "\n\n#{formated_error}"
41
35
  end
42
- error_string += "\n\n"
43
-
44
- {
45
- type: 'Fintecture api',
46
- status: status,
47
- errors: errors_array,
48
- error_string: error_string
49
- }.to_json
50
- end
51
-
52
- def _construct_message_error(res, body)
53
- status = res.status
54
- error = body['meta']
55
-
56
- error_string = "\nFintecture server errors : "
57
- error_string += "\n status: #{status} "
58
-
59
- formated_error = error
60
- formated_error = error.map { |key, value| " #{key}: #{value}" }.join("\n") if error.is_a?(Hash)
61
-
62
- error_string += "\n\n#{formated_error}"
63
36
 
64
37
  error_string += "\n\n"
65
38
 
66
39
  {
67
40
  type: 'Fintecture api',
68
41
  status: status,
69
- errors: [error],
42
+ errors: errors_array,
70
43
  error_string: error_string
71
44
  }.to_json
72
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fintecture
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fintecture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fintecture
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2022-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler