mangopay 3.0.25 → 3.0.26

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +30 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +13 -4
  5. data/Gemfile +2 -2
  6. data/LICENSE +20 -20
  7. data/README.md +126 -126
  8. data/bin/mangopay +9 -9
  9. data/lib/generators/mangopay/install_generator.rb +60 -60
  10. data/lib/generators/templates/mangopay.rb.erb +5 -5
  11. data/lib/mangopay.rb +228 -225
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/bankingaliases.rb +29 -0
  15. data/lib/mangopay/bankingaliases_iban.rb +16 -0
  16. data/lib/mangopay/card.rb +8 -8
  17. data/lib/mangopay/card_registration.rb +9 -9
  18. data/lib/mangopay/client.rb +74 -74
  19. data/lib/mangopay/dispute.rb +130 -130
  20. data/lib/mangopay/errors.rb +61 -61
  21. data/lib/mangopay/event.rb +18 -18
  22. data/lib/mangopay/filter_parameters.rb +46 -46
  23. data/lib/mangopay/hook.rb +9 -9
  24. data/lib/mangopay/http_calls.rb +85 -85
  25. data/lib/mangopay/json.rb +14 -14
  26. data/lib/mangopay/kyc_document.rb +70 -70
  27. data/lib/mangopay/legal_user.rb +15 -15
  28. data/lib/mangopay/mandate.rb +32 -32
  29. data/lib/mangopay/natural_user.rb +14 -14
  30. data/lib/mangopay/pay_in.rb +96 -85
  31. data/lib/mangopay/pay_out.rb +14 -14
  32. data/lib/mangopay/pre_authorization.rb +13 -13
  33. data/lib/mangopay/refund.rb +7 -7
  34. data/lib/mangopay/report.rb +17 -17
  35. data/lib/mangopay/resource.rb +21 -21
  36. data/lib/mangopay/transaction.rb +24 -24
  37. data/lib/mangopay/transfer.rb +9 -9
  38. data/lib/mangopay/user.rb +43 -43
  39. data/lib/mangopay/version.rb +3 -3
  40. data/lib/mangopay/wallet.rb +17 -17
  41. data/mangopay.gemspec +30 -30
  42. data/spec/mangopay/authorization_token_spec.rb +70 -70
  43. data/spec/mangopay/bank_account_spec.rb +97 -97
  44. data/spec/mangopay/bankingaliases_spec.rb +29 -0
  45. data/spec/mangopay/card_registration_spec.rb +73 -73
  46. data/spec/mangopay/client_spec.rb +110 -110
  47. data/spec/mangopay/configuration_spec.rb +95 -95
  48. data/spec/mangopay/dispute_spec.rb +262 -262
  49. data/spec/mangopay/event_spec.rb +31 -31
  50. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  51. data/spec/mangopay/hook_spec.rb +37 -37
  52. data/spec/mangopay/idempotency_spec.rb +41 -41
  53. data/spec/mangopay/kyc_document_spec.rb +103 -103
  54. data/spec/mangopay/log_requests_filter_spec.rb +25 -25
  55. data/spec/mangopay/mandate_spec.rb +92 -92
  56. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  57. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  58. data/spec/mangopay/payin_card_web_spec.rb +47 -38
  59. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  60. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  61. data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
  62. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  63. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  64. data/spec/mangopay/preauthorization_spec.rb +42 -42
  65. data/spec/mangopay/refund_spec.rb +21 -21
  66. data/spec/mangopay/report_spec.rb +39 -39
  67. data/spec/mangopay/shared_resources.rb +397 -381
  68. data/spec/mangopay/transaction_spec.rb +54 -54
  69. data/spec/mangopay/transfer_spec.rb +69 -69
  70. data/spec/mangopay/user_spec.rb +137 -137
  71. data/spec/mangopay/wallet_spec.rb +80 -80
  72. data/spec/spec_helper.rb +31 -31
  73. metadata +7 -6
  74. data/lib/mangopay/temp.rb +0 -74
  75. data/spec/mangopay/temp_paymentcard_spec.rb +0 -31
@@ -1,130 +1,130 @@
1
- require 'base64'
2
-
3
- module MangoPay
4
-
5
- # See https://docs.mangopay.com/api-references/disputes/disputes/
6
- class Dispute < Resource
7
- include HTTPCalls::Fetch
8
- include HTTPCalls::Update
9
- class << self
10
-
11
- def close(dispute_id)
12
- url = url(dispute_id) + "/close/"
13
- MangoPay.request(:put, url)
14
- end
15
-
16
- # +contested_funds+: Money hash
17
- # see 'Contest' section @ https://docs.mangopay.com/api-references/disputes/disputes/
18
- def contest(dispute_id, contested_funds)
19
- url = url(dispute_id) + "/submit/"
20
- MangoPay.request(:put, url, {ContestedFunds: contested_funds})
21
- end
22
-
23
- def resubmit(dispute_id)
24
- url = url(dispute_id) + "/submit/"
25
- MangoPay.request(:put, url)
26
- end
27
-
28
- def transactions(dispute_id, filters = {})
29
- url = url(dispute_id) + "/transactions/"
30
- MangoPay.request(:get, url, {}, filters)
31
- end
32
-
33
- def fetch_for_user(user_id, filters = {})
34
- url = "#{MangoPay.api_path}/users/#{user_id}/disputes"
35
- MangoPay.request(:get, url, {}, filters)
36
- end
37
-
38
- def fetch_for_wallet(wallet_id, filters = {})
39
- url = "#{MangoPay.api_path}/wallets/#{wallet_id}/disputes"
40
- MangoPay.request(:get, url, {}, filters)
41
- end
42
-
43
- #####################################################
44
- # repudiations / settlement transfers
45
- #####################################################
46
-
47
- # see https://docs.mangopay.com/api-references/disputes/repudiations/
48
- def fetch_repudiation(repudiation_id)
49
- url = "#{MangoPay.api_path}/repudiations/#{repudiation_id}"
50
- MangoPay.request(:get, url)
51
- end
52
-
53
- # +params+: hash; see https://docs.mangopay.com/api-references/disputes/settlement-transfers/
54
- def create_settlement_transfer(repudiation_id, params, idempotency_key = nil)
55
- url = "#{MangoPay.api_path}/repudiations/#{repudiation_id}/settlementtransfer/"
56
- MangoPay.request(:post, url, params, {}, idempotency_key)
57
- end
58
-
59
- # see https://docs.mangopay.com/api-references/disputes/settlement-transfers/
60
- def fetch_settlement_transfer(transfer_id)
61
- url = "#{MangoPay.api_path}/settlements/#{transfer_id}"
62
- MangoPay.request(:get, url)
63
- end
64
-
65
- #####################################################
66
- # documents
67
- #####################################################
68
-
69
- # +params+: hash; see https://docs.mangopay.com/api-references/disputes/dispute-documents/
70
- def create_document(dispute_id, params, idempotency_key = nil)
71
- url = url(dispute_id) + "/documents/"
72
- MangoPay.request(:post, url, params, {}, idempotency_key)
73
- end
74
-
75
- def fetch_document(document_id)
76
- url = "#{MangoPay.api_path}/dispute-documents/#{document_id}"
77
- MangoPay.request(:get, url)
78
- end
79
-
80
- # +params+: hash; see 'Edit' section @ https://docs.mangopay.com/api-references/disputes/dispute-documents/
81
- def update_document(dispute_id, document_id, params)
82
- url = url(dispute_id) + "/documents/#{document_id}"
83
- MangoPay.request(:put, url, params)
84
- end
85
-
86
- # Fetches list of dispute documents:
87
- # - for the particular dispute if +dispute_id+ is provided (not nil)
88
- # - or for all disputes otherwise.
89
- #
90
- # Optional +filters+ is a hash accepting following keys:
91
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
92
- # - filters such as +Type+ (e.g. 'REFUND_PROOF') and +Status+ (e.g. 'VALIDATED')
93
- # - +BeforeDate+ (timestamp): filters documents with CreationDate _before_ this date
94
- # - +AfterDate+ (timestamp): filters documents with CreationDate _after_ this date
95
- #
96
- # See https://docs.mangopay.com/api-references/disputes/dispute-documents/
97
- #
98
- def fetch_documents(dispute_id = nil, filters = {})
99
- url = (dispute_id) ? url(dispute_id) + "/documents/" : "#{MangoPay.api_path}/dispute-documents/"
100
- MangoPay.request(:get, url, {}, filters)
101
- end
102
-
103
- # Adds the file page (attachment) to the given document.
104
- #
105
- # See https://docs.mangopay.com/api-references/disputes/dispute-document-pages/ :
106
- # - Document have to be in 'CREATED' Status
107
- # - You can create as many pages as needed
108
- # - Change Status to 'VALIDATION_ASKED' to submit dispute documents
109
- #
110
- # The file_content_base64 param may be:
111
- # - Base64 encoded file content
112
- # - or nil: in this case pass the file path in the next param
113
- #
114
- def create_document_page(dispute_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil)
115
- if file_content_base64.nil? && !file_path.nil?
116
- bts = File.open(file_path, 'rb') { |f| f.read }
117
- file_content_base64 = Base64.encode64(bts)
118
- end
119
- # normally it returns 204 HTTP code on success
120
- begin
121
- url = url(dispute_id) + "/documents/#{document_id}/pages"
122
- MangoPay.request(:post, url, {'File' => file_content_base64}, {}, idempotency_key)
123
- rescue ResponseError => ex
124
- raise ex unless ex.code == '204'
125
- end
126
- end
127
-
128
- end
129
- end
130
- end
1
+ require 'base64'
2
+
3
+ module MangoPay
4
+
5
+ # See https://docs.mangopay.com/api-references/disputes/disputes/
6
+ class Dispute < Resource
7
+ include HTTPCalls::Fetch
8
+ include HTTPCalls::Update
9
+ class << self
10
+
11
+ def close(dispute_id)
12
+ url = url(dispute_id) + "/close/"
13
+ MangoPay.request(:put, url)
14
+ end
15
+
16
+ # +contested_funds+: Money hash
17
+ # see 'Contest' section @ https://docs.mangopay.com/api-references/disputes/disputes/
18
+ def contest(dispute_id, contested_funds)
19
+ url = url(dispute_id) + "/submit/"
20
+ MangoPay.request(:put, url, {ContestedFunds: contested_funds})
21
+ end
22
+
23
+ def resubmit(dispute_id)
24
+ url = url(dispute_id) + "/submit/"
25
+ MangoPay.request(:put, url)
26
+ end
27
+
28
+ def transactions(dispute_id, filters = {})
29
+ url = url(dispute_id) + "/transactions/"
30
+ MangoPay.request(:get, url, {}, filters)
31
+ end
32
+
33
+ def fetch_for_user(user_id, filters = {})
34
+ url = "#{MangoPay.api_path}/users/#{user_id}/disputes"
35
+ MangoPay.request(:get, url, {}, filters)
36
+ end
37
+
38
+ def fetch_for_wallet(wallet_id, filters = {})
39
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/disputes"
40
+ MangoPay.request(:get, url, {}, filters)
41
+ end
42
+
43
+ #####################################################
44
+ # repudiations / settlement transfers
45
+ #####################################################
46
+
47
+ # see https://docs.mangopay.com/api-references/disputes/repudiations/
48
+ def fetch_repudiation(repudiation_id)
49
+ url = "#{MangoPay.api_path}/repudiations/#{repudiation_id}"
50
+ MangoPay.request(:get, url)
51
+ end
52
+
53
+ # +params+: hash; see https://docs.mangopay.com/api-references/disputes/settlement-transfers/
54
+ def create_settlement_transfer(repudiation_id, params, idempotency_key = nil)
55
+ url = "#{MangoPay.api_path}/repudiations/#{repudiation_id}/settlementtransfer/"
56
+ MangoPay.request(:post, url, params, {}, idempotency_key)
57
+ end
58
+
59
+ # see https://docs.mangopay.com/api-references/disputes/settlement-transfers/
60
+ def fetch_settlement_transfer(transfer_id)
61
+ url = "#{MangoPay.api_path}/settlements/#{transfer_id}"
62
+ MangoPay.request(:get, url)
63
+ end
64
+
65
+ #####################################################
66
+ # documents
67
+ #####################################################
68
+
69
+ # +params+: hash; see https://docs.mangopay.com/api-references/disputes/dispute-documents/
70
+ def create_document(dispute_id, params, idempotency_key = nil)
71
+ url = url(dispute_id) + "/documents/"
72
+ MangoPay.request(:post, url, params, {}, idempotency_key)
73
+ end
74
+
75
+ def fetch_document(document_id)
76
+ url = "#{MangoPay.api_path}/dispute-documents/#{document_id}"
77
+ MangoPay.request(:get, url)
78
+ end
79
+
80
+ # +params+: hash; see 'Edit' section @ https://docs.mangopay.com/api-references/disputes/dispute-documents/
81
+ def update_document(dispute_id, document_id, params)
82
+ url = url(dispute_id) + "/documents/#{document_id}"
83
+ MangoPay.request(:put, url, params)
84
+ end
85
+
86
+ # Fetches list of dispute documents:
87
+ # - for the particular dispute if +dispute_id+ is provided (not nil)
88
+ # - or for all disputes otherwise.
89
+ #
90
+ # Optional +filters+ is a hash accepting following keys:
91
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
92
+ # - filters such as +Type+ (e.g. 'REFUND_PROOF') and +Status+ (e.g. 'VALIDATED')
93
+ # - +BeforeDate+ (timestamp): filters documents with CreationDate _before_ this date
94
+ # - +AfterDate+ (timestamp): filters documents with CreationDate _after_ this date
95
+ #
96
+ # See https://docs.mangopay.com/api-references/disputes/dispute-documents/
97
+ #
98
+ def fetch_documents(dispute_id = nil, filters = {})
99
+ url = (dispute_id) ? url(dispute_id) + "/documents/" : "#{MangoPay.api_path}/dispute-documents/"
100
+ MangoPay.request(:get, url, {}, filters)
101
+ end
102
+
103
+ # Adds the file page (attachment) to the given document.
104
+ #
105
+ # See https://docs.mangopay.com/api-references/disputes/dispute-document-pages/ :
106
+ # - Document have to be in 'CREATED' Status
107
+ # - You can create as many pages as needed
108
+ # - Change Status to 'VALIDATION_ASKED' to submit dispute documents
109
+ #
110
+ # The file_content_base64 param may be:
111
+ # - Base64 encoded file content
112
+ # - or nil: in this case pass the file path in the next param
113
+ #
114
+ def create_document_page(dispute_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil)
115
+ if file_content_base64.nil? && !file_path.nil?
116
+ bts = File.open(file_path, 'rb') { |f| f.read }
117
+ file_content_base64 = Base64.encode64(bts)
118
+ end
119
+ # normally it returns 204 HTTP code on success
120
+ begin
121
+ url = url(dispute_id) + "/documents/#{document_id}/pages"
122
+ MangoPay.request(:post, url, {'File' => file_content_base64}, {}, idempotency_key)
123
+ rescue ResponseError => ex
124
+ raise ex unless ex.code == '204'
125
+ end
126
+ end
127
+
128
+ end
129
+ end
130
+ end
@@ -1,61 +1,61 @@
1
- module MangoPay
2
-
3
- # Generic error superclass for MangoPay specific errors.
4
- # Currently never instantiated directly.
5
- # Currently only single subclass used.
6
- class Error < StandardError
7
- end
8
-
9
- # See http://docs.mangopay.com/api-references/response-codes-rules/
10
- # and http://docs.mangopay.com/api-references/error-codes/
11
- #
12
- # Thrown from any MangoPay API call whenever
13
- # it returns response with HTTP code != 200.
14
- # Check @details hash for further info.
15
- #
16
- # Two example exceptions with details:
17
- #
18
- # #<MangoPay::ResponseError:
19
- # One or several required parameters are missing or incorrect. [...]
20
- # Email: The Email field is required.>
21
- # {"Message"=>"One or several required parameters are missing or incorrect.
22
- # An incorrect resource ID also raises this kind of error.",
23
- # "Type"=>"param_error",
24
- # "Id"=>"66936e92-3f21-4a35-b6cf-f1d17c2fb6e5",
25
- # "Date"=>1409047252.0,
26
- # "errors"=>{"Email"=>"The Email field is required."},
27
- # "Code"=>"400",
28
- # "Url"=>"/v2/sdk-unit-tests/users/natural"}
29
- #
30
- # #<MangoPay::ResponseError: Internal Server Error>
31
- # {"Message"=>"Internal Server Error",
32
- # "Type"=>"other",
33
- # "Id"=>"7bdc5c6f-2000-4cd3-96f3-2a3fcb746f07",
34
- # "Date"=>1409047251.0,
35
- # "errors"=>nil,
36
- # "Code"=>"500",
37
- # "Url"=>"/v2/sdk-unit-tests/payins/3380640/refunds"}
38
- class ResponseError < Error
39
-
40
- attr_reader :request_url, :code, :details
41
-
42
- def initialize(request_url, code, details)
43
- @request_url, @code, @details = request_url, code, details
44
-
45
- @details['Code'] = code
46
- @details['Url'] = request_url.request_uri
47
-
48
- super(message) if message
49
- end
50
-
51
- def type; @details['Type']; end
52
- def errors; @details['errors']; end
53
-
54
- def message;
55
- msg = @details['Message']
56
- msg += errors.sort.map {|k,v| " #{k}: #{v}"}.join if (errors && errors.is_a?(Hash))
57
- msg
58
- end
59
-
60
- end
61
- end
1
+ module MangoPay
2
+
3
+ # Generic error superclass for MangoPay specific errors.
4
+ # Currently never instantiated directly.
5
+ # Currently only single subclass used.
6
+ class Error < StandardError
7
+ end
8
+
9
+ # See http://docs.mangopay.com/api-references/response-codes-rules/
10
+ # and http://docs.mangopay.com/api-references/error-codes/
11
+ #
12
+ # Thrown from any MangoPay API call whenever
13
+ # it returns response with HTTP code != 200.
14
+ # Check @details hash for further info.
15
+ #
16
+ # Two example exceptions with details:
17
+ #
18
+ # #<MangoPay::ResponseError:
19
+ # One or several required parameters are missing or incorrect. [...]
20
+ # Email: The Email field is required.>
21
+ # {"Message"=>"One or several required parameters are missing or incorrect.
22
+ # An incorrect resource ID also raises this kind of error.",
23
+ # "Type"=>"param_error",
24
+ # "Id"=>"66936e92-3f21-4a35-b6cf-f1d17c2fb6e5",
25
+ # "Date"=>1409047252.0,
26
+ # "errors"=>{"Email"=>"The Email field is required."},
27
+ # "Code"=>"400",
28
+ # "Url"=>"/v2/sdk-unit-tests/users/natural"}
29
+ #
30
+ # #<MangoPay::ResponseError: Internal Server Error>
31
+ # {"Message"=>"Internal Server Error",
32
+ # "Type"=>"other",
33
+ # "Id"=>"7bdc5c6f-2000-4cd3-96f3-2a3fcb746f07",
34
+ # "Date"=>1409047251.0,
35
+ # "errors"=>nil,
36
+ # "Code"=>"500",
37
+ # "Url"=>"/v2/sdk-unit-tests/payins/3380640/refunds"}
38
+ class ResponseError < Error
39
+
40
+ attr_reader :request_url, :code, :details
41
+
42
+ def initialize(request_url, code, details)
43
+ @request_url, @code, @details = request_url, code, details
44
+
45
+ @details['Code'] = code
46
+ @details['Url'] = request_url.request_uri
47
+
48
+ super(message) if message
49
+ end
50
+
51
+ def type; @details['Type']; end
52
+ def errors; @details['errors']; end
53
+
54
+ def message;
55
+ msg = @details['Message']
56
+ msg += errors.sort.map {|k,v| " #{k}: #{v}"}.join if (errors && errors.is_a?(Hash))
57
+ msg
58
+ end
59
+
60
+ end
61
+ end
@@ -1,18 +1,18 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/events/
4
- class Event < Resource
5
-
6
- # Fetches list of events (PayIns, PayOuts, Transfers).
7
- #
8
- # Optional +filters+ is a hash accepting following keys:
9
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
10
- # - +EventType+: {PAYIN_NORMAL_CREATED, PAYIN_NORMAL_SUCCEEDED, PAYIN_NORMAL_FAILED etc...} (see http://docs.mangopay.com/api-references/events/)
11
- # - +BeforeDate+ (timestamp): filters events with Date _before_ this date
12
- # - +AfterDate+ (timestamp): filters events with Date _after_ this date
13
- #
14
- def self.fetch(filters={})
15
- MangoPay.request(:get, url(), {}, filters)
16
- end
17
- end
18
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/events/
4
+ class Event < Resource
5
+
6
+ # Fetches list of events (PayIns, PayOuts, Transfers).
7
+ #
8
+ # Optional +filters+ is a hash accepting following keys:
9
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
10
+ # - +EventType+: {PAYIN_NORMAL_CREATED, PAYIN_NORMAL_SUCCEEDED, PAYIN_NORMAL_FAILED etc...} (see http://docs.mangopay.com/api-references/events/)
11
+ # - +BeforeDate+ (timestamp): filters events with Date _before_ this date
12
+ # - +AfterDate+ (timestamp): filters events with Date _after_ this date
13
+ #
14
+ def self.fetch(filters={})
15
+ MangoPay.request(:get, url(), {}, filters)
16
+ end
17
+ end
18
+ end
@@ -1,46 +1,46 @@
1
- module MangoPay
2
- module FilterParameters
3
-
4
- def self.request(body)
5
- begin
6
- body = JSON.load(body)
7
- rescue MultiJson::LoadError => e
8
- return body
9
- end
10
- filter_hash(body, req_confidential_params)
11
- JSON.dump(body)
12
- end
13
-
14
- def self.response(body)
15
- return '' if body.to_s.empty?
16
- body = JSON.load(body)
17
- filter_hash(body, res_confidential_params)
18
- JSON.dump(body)
19
- end
20
-
21
- private
22
-
23
- def self.filter_hash(hash, to_filter)
24
- hash.each do |k,v|
25
- if v.is_a?(Hash)
26
- filter_hash(v, to_filter)
27
- else
28
- hash[k] = '[FILTERED]' if to_filter.include?(k)
29
- end
30
- end
31
- end
32
-
33
- def self.res_confidential_params
34
- @@res_confidential_params ||= [
35
- 'access_token', 'AccessKey', 'IBAN', 'CardRegistrationURL',
36
- 'PreregistrationData', 'RedirectURL', 'RegistrationData',
37
- 'SecureModeRedirectUrl'
38
- ].freeze
39
- end
40
-
41
- def self.req_confidential_params
42
- @@req_confidential_params ||= ['File', 'IBAN'].freeze
43
- end
44
-
45
- end
46
- end
1
+ module MangoPay
2
+ module FilterParameters
3
+
4
+ def self.request(body)
5
+ begin
6
+ body = JSON.load(body)
7
+ rescue MultiJson::LoadError => e
8
+ return body
9
+ end
10
+ filter_hash(body, req_confidential_params)
11
+ JSON.dump(body)
12
+ end
13
+
14
+ def self.response(body)
15
+ return '' if body.to_s.empty?
16
+ body = JSON.load(body)
17
+ filter_hash(body, res_confidential_params)
18
+ JSON.dump(body)
19
+ end
20
+
21
+ private
22
+
23
+ def self.filter_hash(hash, to_filter)
24
+ hash.each do |k,v|
25
+ if v.is_a?(Hash)
26
+ filter_hash(v, to_filter)
27
+ else
28
+ hash[k] = '[FILTERED]' if to_filter.include?(k)
29
+ end
30
+ end
31
+ end
32
+
33
+ def self.res_confidential_params
34
+ @@res_confidential_params ||= [
35
+ 'access_token', 'AccessKey', 'IBAN', 'CardRegistrationURL',
36
+ 'PreregistrationData', 'RedirectURL', 'RegistrationData',
37
+ 'SecureModeRedirectUrl'
38
+ ].freeze
39
+ end
40
+
41
+ def self.req_confidential_params
42
+ @@req_confidential_params ||= ['File', 'IBAN'].freeze
43
+ end
44
+
45
+ end
46
+ end