mangopay 3.0.25.pre.alpha.pre.20 → 3.0.25

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +4 -13
  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 +225 -225
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/card.rb +8 -8
  15. data/lib/mangopay/card_registration.rb +9 -9
  16. data/lib/mangopay/client.rb +74 -74
  17. data/lib/mangopay/dispute.rb +130 -130
  18. data/lib/mangopay/errors.rb +61 -61
  19. data/lib/mangopay/event.rb +18 -18
  20. data/lib/mangopay/filter_parameters.rb +46 -46
  21. data/lib/mangopay/hook.rb +9 -9
  22. data/lib/mangopay/http_calls.rb +85 -85
  23. data/lib/mangopay/json.rb +14 -14
  24. data/lib/mangopay/kyc_document.rb +70 -70
  25. data/lib/mangopay/legal_user.rb +15 -15
  26. data/lib/mangopay/mandate.rb +32 -32
  27. data/lib/mangopay/natural_user.rb +14 -14
  28. data/lib/mangopay/pay_in.rb +85 -85
  29. data/lib/mangopay/pay_out.rb +14 -14
  30. data/lib/mangopay/pre_authorization.rb +13 -13
  31. data/lib/mangopay/refund.rb +7 -7
  32. data/lib/mangopay/report.rb +17 -17
  33. data/lib/mangopay/resource.rb +21 -21
  34. data/lib/mangopay/temp.rb +74 -74
  35. data/lib/mangopay/transaction.rb +24 -24
  36. data/lib/mangopay/transfer.rb +9 -9
  37. data/lib/mangopay/user.rb +43 -43
  38. data/lib/mangopay/version.rb +3 -3
  39. data/lib/mangopay/wallet.rb +17 -17
  40. data/mangopay.gemspec +30 -31
  41. data/spec/mangopay/authorization_token_spec.rb +70 -70
  42. data/spec/mangopay/bank_account_spec.rb +97 -97
  43. data/spec/mangopay/card_registration_spec.rb +73 -73
  44. data/spec/mangopay/client_spec.rb +110 -110
  45. data/spec/mangopay/configuration_spec.rb +95 -95
  46. data/spec/mangopay/dispute_spec.rb +262 -262
  47. data/spec/mangopay/event_spec.rb +31 -31
  48. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  49. data/spec/mangopay/hook_spec.rb +37 -37
  50. data/spec/mangopay/idempotency_spec.rb +41 -41
  51. data/spec/mangopay/kyc_document_spec.rb +103 -103
  52. data/spec/mangopay/log_requests_filter_spec.rb +25 -25
  53. data/spec/mangopay/mandate_spec.rb +92 -92
  54. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  55. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  56. data/spec/mangopay/payin_card_web_spec.rb +38 -38
  57. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  58. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  59. data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
  60. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  61. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  62. data/spec/mangopay/preauthorization_spec.rb +42 -42
  63. data/spec/mangopay/refund_spec.rb +21 -21
  64. data/spec/mangopay/report_spec.rb +39 -39
  65. data/spec/mangopay/shared_resources.rb +381 -381
  66. data/spec/mangopay/temp_paymentcard_spec.rb +31 -31
  67. data/spec/mangopay/transaction_spec.rb +54 -54
  68. data/spec/mangopay/transfer_spec.rb +69 -69
  69. data/spec/mangopay/user_spec.rb +137 -137
  70. data/spec/mangopay/wallet_spec.rb +80 -80
  71. data/spec/spec_helper.rb +31 -31
  72. metadata +5 -5
@@ -1,70 +1,70 @@
1
- require 'base64'
2
-
3
- module MangoPay
4
-
5
- # See http://docs.mangopay.com/api-references/kyc/documents/
6
- class KycDocument < Resource
7
- class << self
8
- def create(user_id, params, idempotency_key = nil)
9
- MangoPay.request(:post, url(user_id), params, {}, idempotency_key)
10
- end
11
-
12
- def update(user_id, document_id, params = {})
13
- MangoPay.request(:put, url(user_id, document_id), params)
14
- end
15
-
16
- # Fetches the KYC document belonging to the given +user_id+, with the given +document_id+.
17
- def fetch(user_id, document_id)
18
- url = (user_id) ? url(user_id, document_id) : "#{MangoPay.api_path}/KYC/documents/#{CGI.escape(document_id.to_s)}"
19
- MangoPay.request(:get, url)
20
- end
21
-
22
- # Fetches list of KYC documents:
23
- # - for the particular user if +user_id+ is provided (not nil)
24
- # - or for all users otherwise.
25
- #
26
- # Optional +filters+ is a hash accepting following keys:
27
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
28
- # - filters such as +Type+ (e.g. 'IDENTITY_PROOF') and +Status+ (e.g. 'VALIDATED')
29
- # - +BeforeDate+ (timestamp): filters documents with CreationDate _before_ this date
30
- # - +AfterDate+ (timestamp): filters documents with CreationDate _after_ this date
31
- #
32
- def fetch_all(user_id = nil, filters = {})
33
- url = (user_id) ? url(user_id) : "#{MangoPay.api_path}/KYC/documents"
34
- MangoPay.request(:get, url, {}, filters)
35
- end
36
-
37
- # Adds the file page (attachment) to the given document.
38
- #
39
- # See http://docs.mangopay.com/api-references/kyc/pages/ :
40
- # - Document have to be in 'CREATED' Status
41
- # - You can create as many pages as needed
42
- # - Change Status to 'VALIDATION_ASKED' to submit KYC documents
43
- #
44
- # The file_content_base64 param may be:
45
- # - Base64 encoded file content
46
- # - or nil: in this case pass the file path in the next param
47
- #
48
- def create_page(user_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil)
49
- if file_content_base64.nil? && !file_path.nil?
50
- bts = File.open(file_path, 'rb') { |f| f.read }
51
- file_content_base64 = Base64.encode64(bts)
52
- end
53
- # normally it returns 204 HTTP code on success
54
- begin
55
- MangoPay.request(:post, url(user_id, document_id) + '/pages', {'File' => file_content_base64}, {}, idempotency_key)
56
- rescue ResponseError => ex
57
- raise ex unless ex.code == '204'
58
- end
59
- end
60
-
61
- def url(user_id, document_id = nil)
62
- if document_id
63
- "#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/KYC/documents/#{CGI.escape(document_id.to_s)}"
64
- else
65
- "#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/KYC/documents"
66
- end
67
- end
68
- end
69
- end
70
- end
1
+ require 'base64'
2
+
3
+ module MangoPay
4
+
5
+ # See http://docs.mangopay.com/api-references/kyc/documents/
6
+ class KycDocument < Resource
7
+ class << self
8
+ def create(user_id, params, idempotency_key = nil)
9
+ MangoPay.request(:post, url(user_id), params, {}, idempotency_key)
10
+ end
11
+
12
+ def update(user_id, document_id, params = {})
13
+ MangoPay.request(:put, url(user_id, document_id), params)
14
+ end
15
+
16
+ # Fetches the KYC document belonging to the given +user_id+, with the given +document_id+.
17
+ def fetch(user_id, document_id)
18
+ url = (user_id) ? url(user_id, document_id) : "#{MangoPay.api_path}/KYC/documents/#{CGI.escape(document_id.to_s)}"
19
+ MangoPay.request(:get, url)
20
+ end
21
+
22
+ # Fetches list of KYC documents:
23
+ # - for the particular user if +user_id+ is provided (not nil)
24
+ # - or for all users otherwise.
25
+ #
26
+ # Optional +filters+ is a hash accepting following keys:
27
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
28
+ # - filters such as +Type+ (e.g. 'IDENTITY_PROOF') and +Status+ (e.g. 'VALIDATED')
29
+ # - +BeforeDate+ (timestamp): filters documents with CreationDate _before_ this date
30
+ # - +AfterDate+ (timestamp): filters documents with CreationDate _after_ this date
31
+ #
32
+ def fetch_all(user_id = nil, filters = {})
33
+ url = (user_id) ? url(user_id) : "#{MangoPay.api_path}/KYC/documents"
34
+ MangoPay.request(:get, url, {}, filters)
35
+ end
36
+
37
+ # Adds the file page (attachment) to the given document.
38
+ #
39
+ # See http://docs.mangopay.com/api-references/kyc/pages/ :
40
+ # - Document have to be in 'CREATED' Status
41
+ # - You can create as many pages as needed
42
+ # - Change Status to 'VALIDATION_ASKED' to submit KYC documents
43
+ #
44
+ # The file_content_base64 param may be:
45
+ # - Base64 encoded file content
46
+ # - or nil: in this case pass the file path in the next param
47
+ #
48
+ def create_page(user_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil)
49
+ if file_content_base64.nil? && !file_path.nil?
50
+ bts = File.open(file_path, 'rb') { |f| f.read }
51
+ file_content_base64 = Base64.encode64(bts)
52
+ end
53
+ # normally it returns 204 HTTP code on success
54
+ begin
55
+ MangoPay.request(:post, url(user_id, document_id) + '/pages', {'File' => file_content_base64}, {}, idempotency_key)
56
+ rescue ResponseError => ex
57
+ raise ex unless ex.code == '204'
58
+ end
59
+ end
60
+
61
+ def url(user_id, document_id = nil)
62
+ if document_id
63
+ "#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/KYC/documents/#{CGI.escape(document_id.to_s)}"
64
+ else
65
+ "#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/KYC/documents"
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,15 +1,15 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/users/legal-users/
4
- # See also parent class MangoPay::User
5
- class LegalUser < User
6
-
7
- def self.url(id = nil)
8
- if id
9
- "#{MangoPay.api_path}/users/legal/#{CGI.escape(id.to_s)}"
10
- else
11
- "#{MangoPay.api_path}/users/legal"
12
- end
13
- end
14
- end
15
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/users/legal-users/
4
+ # See also parent class MangoPay::User
5
+ class LegalUser < User
6
+
7
+ def self.url(id = nil)
8
+ if id
9
+ "#{MangoPay.api_path}/users/legal/#{CGI.escape(id.to_s)}"
10
+ else
11
+ "#{MangoPay.api_path}/users/legal"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,32 +1,32 @@
1
- module MangoPay
2
-
3
- # See https://docs.mangopay.com/api-references/mandates/
4
- class Mandate < Resource
5
- include HTTPCalls::Fetch
6
-
7
- class << self
8
-
9
- # +params+: hash; see https://docs.mangopay.com/api-references/mandates/
10
- def create(params, idempotency_key = nil)
11
- url = "#{MangoPay.api_path}/mandates/directdebit/web"
12
- MangoPay.request(:post, url, params, {}, idempotency_key)
13
- end
14
-
15
- def cancel(id)
16
- url = "#{MangoPay.api_path}/mandates/#{id}/cancel"
17
- MangoPay.request(:put, url)
18
- end
19
-
20
- def fetch_for_user(user_id, filters = {})
21
- url = "#{MangoPay.api_path}/users/#{user_id}/mandates"
22
- MangoPay.request(:get, url, {}, filters)
23
- end
24
-
25
- def fetch_for_user_bank_account(user_id, bank_account_id, filters = {})
26
- url = "#{MangoPay.api_path}/users/#{user_id}/bankaccounts/#{bank_account_id}/mandates"
27
- MangoPay.request(:get, url, {}, filters)
28
- end
29
-
30
- end
31
- end
32
- end
1
+ module MangoPay
2
+
3
+ # See https://docs.mangopay.com/api-references/mandates/
4
+ class Mandate < Resource
5
+ include HTTPCalls::Fetch
6
+
7
+ class << self
8
+
9
+ # +params+: hash; see https://docs.mangopay.com/api-references/mandates/
10
+ def create(params, idempotency_key = nil)
11
+ url = "#{MangoPay.api_path}/mandates/directdebit/web"
12
+ MangoPay.request(:post, url, params, {}, idempotency_key)
13
+ end
14
+
15
+ def cancel(id)
16
+ url = "#{MangoPay.api_path}/mandates/#{id}/cancel"
17
+ MangoPay.request(:put, url)
18
+ end
19
+
20
+ def fetch_for_user(user_id, filters = {})
21
+ url = "#{MangoPay.api_path}/users/#{user_id}/mandates"
22
+ MangoPay.request(:get, url, {}, filters)
23
+ end
24
+
25
+ def fetch_for_user_bank_account(user_id, bank_account_id, filters = {})
26
+ url = "#{MangoPay.api_path}/users/#{user_id}/bankaccounts/#{bank_account_id}/mandates"
27
+ MangoPay.request(:get, url, {}, filters)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -1,14 +1,14 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/users/natural-users/
4
- class NaturalUser < User
5
-
6
- def self.url(id = nil)
7
- if id
8
- "#{MangoPay.api_path}/users/natural/#{CGI.escape(id.to_s)}"
9
- else
10
- "#{MangoPay.api_path}/users/natural"
11
- end
12
- end
13
- end
14
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/users/natural-users/
4
+ class NaturalUser < User
5
+
6
+ def self.url(id = nil)
7
+ if id
8
+ "#{MangoPay.api_path}/users/natural/#{CGI.escape(id.to_s)}"
9
+ else
10
+ "#{MangoPay.api_path}/users/natural"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,85 +1,85 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/payins/
4
- class PayIn < Resource
5
- include HTTPCalls::Fetch
6
- include HTTPCalls::Refund
7
-
8
- module Card
9
-
10
- # See http://docs.mangopay.com/api-references/payins/payins-card-web/
11
- class Web < Resource
12
- include HTTPCalls::Create
13
- def self.url(*)
14
- "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
15
- end
16
- end
17
-
18
- # See http://docs.mangopay.com/api-references/payins/payindirectcard/
19
- class Direct < Resource
20
- include HTTPCalls::Create
21
- def self.url(*)
22
- "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
23
- end
24
- end
25
-
26
- end
27
-
28
- module PreAuthorized
29
-
30
- # See http://docs.mangopay.com/api-references/payins/preauthorized-payin/
31
- class Direct < Resource
32
- include HTTPCalls::Create
33
- def self.url(*)
34
- "#{MangoPay.api_path}/payins/preauthorized/direct"
35
- end
36
- end
37
-
38
- end
39
-
40
- module BankWire
41
-
42
- # See http://docs.mangopay.com/api-references/payins/payinbankwire/
43
- class Direct < Resource
44
- include HTTPCalls::Create
45
- def self.url(*)
46
- "#{MangoPay.api_path}/payins/bankwire/direct"
47
- end
48
- end
49
-
50
- end
51
-
52
- module DirectDebit
53
-
54
- # See http://docs.mangopay.com/api-references/payins/direct-debit-pay-in-web/
55
- class Web < Resource
56
- include HTTPCalls::Create
57
- def self.url(*)
58
- "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
59
- end
60
- end
61
-
62
- # See https://docs.mangopay.com/api-references/payins/direct-debit-pay-in-direct/
63
- class Direct < Resource
64
- include HTTPCalls::Create
65
- def self.url(*)
66
- "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
67
- end
68
- end
69
-
70
- end
71
-
72
- module PayPal
73
-
74
- # See https://docs.mangopay.com/api-references/payins/paypal-payin/
75
- class Web < Resource
76
- include HTTPCalls::Create
77
- def self.url(*)
78
- "#{MangoPay.api_path}/payins/paypal/#{CGI.escape(class_name.downcase)}"
79
- end
80
- end
81
-
82
- end
83
-
84
- end
85
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/payins/
4
+ class PayIn < Resource
5
+ include HTTPCalls::Fetch
6
+ include HTTPCalls::Refund
7
+
8
+ module Card
9
+
10
+ # See http://docs.mangopay.com/api-references/payins/payins-card-web/
11
+ class Web < Resource
12
+ include HTTPCalls::Create
13
+ def self.url(*)
14
+ "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
15
+ end
16
+ end
17
+
18
+ # See http://docs.mangopay.com/api-references/payins/payindirectcard/
19
+ class Direct < Resource
20
+ include HTTPCalls::Create
21
+ def self.url(*)
22
+ "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ module PreAuthorized
29
+
30
+ # See http://docs.mangopay.com/api-references/payins/preauthorized-payin/
31
+ class Direct < Resource
32
+ include HTTPCalls::Create
33
+ def self.url(*)
34
+ "#{MangoPay.api_path}/payins/preauthorized/direct"
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ module BankWire
41
+
42
+ # See http://docs.mangopay.com/api-references/payins/payinbankwire/
43
+ class Direct < Resource
44
+ include HTTPCalls::Create
45
+ def self.url(*)
46
+ "#{MangoPay.api_path}/payins/bankwire/direct"
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ module DirectDebit
53
+
54
+ # See http://docs.mangopay.com/api-references/payins/direct-debit-pay-in-web/
55
+ class Web < Resource
56
+ include HTTPCalls::Create
57
+ def self.url(*)
58
+ "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
59
+ end
60
+ end
61
+
62
+ # See https://docs.mangopay.com/api-references/payins/direct-debit-pay-in-direct/
63
+ class Direct < Resource
64
+ include HTTPCalls::Create
65
+ def self.url(*)
66
+ "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ module PayPal
73
+
74
+ # See https://docs.mangopay.com/api-references/payins/paypal-payin/
75
+ class Web < Resource
76
+ include HTTPCalls::Create
77
+ def self.url(*)
78
+ "#{MangoPay.api_path}/payins/paypal/#{CGI.escape(class_name.downcase)}"
79
+ end
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+ end
@@ -1,14 +1,14 @@
1
- module MangoPay
2
- class PayOut < Resource
3
- include HTTPCalls::Fetch
4
-
5
- # See http://docs.mangopay.com/api-references/pay-out-bank-wire/
6
- class BankWire < Resource
7
- include HTTPCalls::Create
8
-
9
- def self.url(*)
10
- "#{MangoPay.api_path}/payouts/bankwire"
11
- end
12
- end
13
- end
14
- end
1
+ module MangoPay
2
+ class PayOut < Resource
3
+ include HTTPCalls::Fetch
4
+
5
+ # See http://docs.mangopay.com/api-references/pay-out-bank-wire/
6
+ class BankWire < Resource
7
+ include HTTPCalls::Create
8
+
9
+ def self.url(*)
10
+ "#{MangoPay.api_path}/payouts/bankwire"
11
+ end
12
+ end
13
+ end
14
+ end