mangopay 3.0.21 → 3.0.23

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63b80399ecc8d9221db114f107e954ab277b6c72
4
- data.tar.gz: 2d995aaed246ba27847e7671efcf24b439025059
3
+ metadata.gz: 66c9892c195aece2222cf16271e0f667feb321fe
4
+ data.tar.gz: d1b4c622c63bbc55a6689bbf458d9aaabb9f157d
5
5
  SHA512:
6
- metadata.gz: 495dbecbf3a741693d4da00b4cab946b5267f3a71cded1dff692586df537c49832b5fbfb7e12b3500b71d3f9e42a7e000c544df0e55bd273e1931c4819bd2ff0
7
- data.tar.gz: eafb9be0c814ca133d04fc8b5af5d4e7a33618e3805a8fa8b7907ef69bc9e00da659439c2104d50cb19cd66892ae4e5e7d9654b2f1745ca4d04bb3826779ccec
6
+ metadata.gz: 9d95ae1f194bf4b1efa39c4ecc353fd93b77b59ce838f17efea87fa13ef20d8f200f9c5d0deb6aa931948f559d03df7846db703be45f7b79103c3fd140c3e850
7
+ data.tar.gz: 8c3f0400d5f58c06f9f0af78e83329b4dd1c1170d210da2b1a677fc03f7854f965572eeb1ace71cd0257b5051cd9392312ef8ac4dca97c0705ffeaab9d5815b3
data/README.md CHANGED
@@ -94,7 +94,7 @@ on the [Gem's Github](https://github.com/Mangopay/mangopay2-ruby-sdk/issues)
94
94
  1. Fork the repo.
95
95
 
96
96
  2. Run the tests. We only take pull requests with passing tests, and it's great
97
- to know that you have a clean slate: `bundle && bundle exec rake`
97
+ to know that you have a clean slate: `bundle && bundle exec rspec`
98
98
 
99
99
  3. Add a test for your change. Only refactoring and documentation changes
100
100
  require no new tests. If you are adding functionality or fixing a bug, we need
data/lib/mangopay.rb CHANGED
@@ -31,6 +31,7 @@ module MangoPay
31
31
  autoload :Refund, 'mangopay/refund'
32
32
  autoload :Dispute, 'mangopay/dispute'
33
33
  autoload :Mandate, 'mangopay/mandate'
34
+ autoload :Report, 'mangopay/report'
34
35
  autoload :JSON, 'mangopay/json'
35
36
  autoload :AuthorizationToken, 'mangopay/authorization_token'
36
37
 
@@ -21,6 +21,11 @@ module MangoPay
21
21
  MangoPay.request(:get, url(user_id, bank_account_id), {}, filters)
22
22
  end
23
23
 
24
+ # see https://docs.mangopay.com/endpoints/v2.01/bank-accounts#e306_disactivate-a-bank-account
25
+ def update(user_id, bank_account_id, params = {})
26
+ MangoPay.request(:put, url(user_id, bank_account_id), params)
27
+ end
28
+
24
29
  def url(user_id, bank_account_id = nil)
25
30
  if bank_account_id
26
31
  "#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/bankaccounts/#{CGI.escape(bank_account_id.to_s)}"
@@ -5,13 +5,6 @@ module MangoPay
5
5
 
6
6
  class << self
7
7
 
8
- def create(params)
9
- MangoPay.request(:post, '/clients/', params, {}, {
10
- 'user_agent' => "MangoPay V2 RubyBindings/#{VERSION}",
11
- 'Content-Type' => 'application/json'
12
- })
13
- end
14
-
15
8
  # see https://docs.mangopay.com/api-references/client-details/
16
9
  def fetch()
17
10
  MangoPay.request(:get, url())
@@ -36,6 +29,46 @@ module MangoPay
36
29
  end
37
30
  end
38
31
 
32
+ # Fetch all your client wallets;
33
+ # +funds_type+ may be:
34
+ # - nil: all wallets
35
+ # - 'fees': fees wallets
36
+ # - 'credit': credit wallets
37
+ # see https://docs.mangopay.com/api-references/client-wallets/
38
+ def fetch_wallets(funds_type = nil)
39
+ MangoPay.request(:get, url() + "/wallets/#{funds_type}")
40
+ end
41
+
42
+ # Fetch one of your client wallets (fees or credit) with a particular currency;
43
+ # +funds_type+ may be:
44
+ # - nil: all wallets
45
+ # - 'fees': fees wallets
46
+ # - 'credit': credit wallets
47
+ # +currency_iso_code+ is currncy ISO code
48
+ # see https://docs.mangopay.com/api-references/client-wallets/
49
+ def fetch_wallet(funds_type, currency_iso_code)
50
+ MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}")
51
+ end
52
+
53
+ # Fetch transactions for all your client wallets.
54
+ # Optional +filters+ hash: see MangoPay::Transaction.fetch
55
+ # See https://docs.mangopay.com/api-references/client-wallets/
56
+ def fetch_wallets_transactions(filters = {})
57
+ MangoPay.request(:get, url() + "/transactions", {}, filters)
58
+ end
59
+
60
+ # Fetch transactions for one of your client wallets (fees or credit) with a particular currency;
61
+ # +funds_type+ may be:
62
+ # - nil: all wallets
63
+ # - 'fees': fees wallets
64
+ # - 'credit': credit wallets
65
+ # +currency_iso_code+ is currncy ISO code
66
+ # Optional +filters+ hash: see MangoPay::Transaction.fetch
67
+ # See https://docs.mangopay.com/api-references/client-wallets/
68
+ def fetch_wallet_transactions(funds_type, currency_iso_code, filters = {})
69
+ MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}/transactions", {}, filters)
70
+ end
71
+
39
72
  end
40
73
  end
41
74
  end
@@ -0,0 +1,17 @@
1
+ module MangoPay
2
+
3
+ # See https://docs.mangopay.com/endpoints/v2.01/reporting
4
+ class Report < Resource
5
+ include HTTPCalls::Fetch
6
+
7
+ class << self
8
+
9
+ # +params+: hash; see https://docs.mangopay.com/endpoints/v2.01/reporting#e825_create-a-transaction-report
10
+ def create(params, idempotency_key = nil)
11
+ url = url() + '/transactions/'
12
+ MangoPay.request(:post, url, params, {}, idempotency_key)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -11,6 +11,7 @@ module MangoPay
11
11
  # - +Nature+: TransactionNature {NORMAL, REFUND, REPUDIATION}
12
12
  # - +BeforeDate+ (timestamp): filters transactions with CreationDate _before_ this date
13
13
  # - +AfterDate+ (timestamp): filters transactions with CreationDate _after_ this date
14
+ # See https://docs.mangopay.com/api-references/sort-lists/
14
15
  def fetch(wallet_id, filters={})
15
16
  MangoPay.request(:get, url(wallet_id), {}, filters)
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.0.21' # Direct debit
2
+ VERSION = '3.0.23'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  describe MangoPay::BankAccount do
2
2
  include_context 'bank_accounts'
3
-
3
+
4
4
  def create(params)
5
5
  user = new_natural_user
6
6
  params_fixed = { OwnerName: 'John', OwnerAddress: user['Address'] }.merge(params)
@@ -82,4 +82,16 @@ describe MangoPay::BankAccount do
82
82
  expect(single['Id']).to eq(new_bank_account['Id'])
83
83
  end
84
84
  end
85
+
86
+ describe 'UPDATE' do
87
+ it 'disactivates a bank account' do
88
+ usr_id = new_bank_account['UserId']
89
+ acc_id = new_bank_account['Id']
90
+
91
+ changed = MangoPay::BankAccount.update(usr_id, acc_id, {Active: false})
92
+ fetched = MangoPay::BankAccount.fetch(usr_id, acc_id)
93
+ expect(changed['Active']).to eq(false)
94
+ expect(fetched['Active']).to eq(false)
95
+ end
96
+ end
85
97
  end
@@ -1,30 +1,4 @@
1
1
  describe MangoPay::Client do
2
- include_context 'clients'
3
-
4
- describe 'CREATE' do
5
- it 'creates a new client' do
6
- expect(new_client['ClientId']).to eq(client_id)
7
- expect(new_client['Email']).not_to be_nil
8
- expect(new_client['Passphrase']).not_to be_nil
9
- end
10
-
11
- it 'refuses the client id' do
12
- expect { wrong_client['errors'] }.to raise_error { |err|
13
- expect(err).to be_a MangoPay::ResponseError
14
- expect(err.type).to eq 'param_error'
15
- }
16
- end
17
-
18
- it "ClientId_already_exist" do
19
- expect {
20
- MangoPay::Client.create({
21
- 'ClientId' => new_client['ClientId'],
22
- 'Name' => 'What a nice name',
23
- 'Email' => 'clientemail@email.com'
24
- })
25
- }.to raise_error MangoPay::ResponseError
26
- end
27
- end
28
2
 
29
3
  describe 'FETCH' do
30
4
  it 'fetches the current client details' do
@@ -71,4 +45,66 @@ describe MangoPay::Client do
71
45
  end
72
46
  end
73
47
 
48
+ describe 'fetch_wallets' do
49
+ it 'fetches all client wallets' do
50
+ wlts = MangoPay::Client.fetch_wallets
51
+ expect(wlts).to be_kind_of(Array)
52
+ expect(wlts).not_to be_empty
53
+ end
54
+
55
+ it 'fetches all client fees wallets' do
56
+ wlts = MangoPay::Client.fetch_wallets('fees')
57
+ expect(wlts).to be_kind_of(Array)
58
+ expect(wlts).not_to be_empty
59
+ expect((wlts.map {|m| m['FundsType']}).uniq).to eq(['FEES'])
60
+ end
61
+
62
+ it 'fetches all client credit wallets' do
63
+ wlts = MangoPay::Client.fetch_wallets('credit')
64
+ expect(wlts).to be_kind_of(Array)
65
+ expect(wlts).not_to be_empty
66
+ expect((wlts.map {|m| m['FundsType']}).uniq).to eq(['CREDIT'])
67
+ end
68
+ end
69
+
70
+ describe 'fetch_wallet' do
71
+ it 'fetches one of client wallets by funds type (fees) and currency' do
72
+ wlt = MangoPay::Client.fetch_wallet('fees', 'EUR')
73
+ expect(wlt).to be_kind_of(Hash)
74
+ expect(wlt['FundsType']).to eq('FEES')
75
+ expect(wlt['Currency']).to eq('EUR')
76
+ end
77
+
78
+ it 'fetches one of client wallets by funds type (credit) and currency' do
79
+ wlt = MangoPay::Client.fetch_wallet('credit', 'EUR')
80
+ expect(wlt).to be_kind_of(Hash)
81
+ expect(wlt['FundsType']).to eq('CREDIT')
82
+ expect(wlt['Currency']).to eq('EUR')
83
+ end
84
+ end
85
+
86
+ describe 'fetch_wallets_transactions' do
87
+ it 'fetches transactions for all client wallets' do
88
+ trns = MangoPay::Client.fetch_wallets_transactions
89
+ expect(trns).to be_kind_of(Array)
90
+ expect(trns).not_to be_empty
91
+ end
92
+ end
93
+
94
+ describe 'fetch_wallets_transactions' do
95
+ it 'fetches transactions of one of client wallets by funds type (fees) and currency' do
96
+ trns = MangoPay::Client.fetch_wallet_transactions('fees', 'EUR')
97
+ expect(trns).to be_kind_of(Array)
98
+ expect(trns).not_to be_empty
99
+ expect((trns.map {|m| m['DebitedWalletId']}).uniq).to eq(['FEES_EUR'])
100
+ end
101
+
102
+ it 'fetches transactions of one of client wallets by funds type (credit) and currency' do
103
+ trns = MangoPay::Client.fetch_wallet_transactions('credit', 'EUR')
104
+ expect(trns).to be_kind_of(Array)
105
+ expect(trns).not_to be_empty
106
+ expect((trns.map {|m| m['DebitedWalletId']}).uniq).to eq(['CREDIT_EUR'])
107
+ end
108
+ end
109
+
74
110
  end
@@ -1,5 +1,10 @@
1
1
  describe MangoPay::Dispute do
2
2
 
3
+ =begin
4
+ comment out all Dispute related unit tests please
5
+ these require manual actions on our side
6
+ and it's infact not suitable like that
7
+
3
8
  # IMPORTANT NOTE!
4
9
  #
5
10
  # Due to the fact the disputes CANNOT be created on user's side,
@@ -251,4 +256,7 @@ describe MangoPay::Dispute do
251
256
  expect(changed_dispute['Status']).to eq('CLOSED')
252
257
  end
253
258
  end
259
+
260
+ =end
261
+
254
262
  end
@@ -0,0 +1,39 @@
1
+ describe MangoPay::Report do
2
+
3
+ def create
4
+ params = {
5
+ Tag: 'custom meta',
6
+ CallbackURL: 'http://www.my-site.com/callbackURL/',
7
+ DownloadFormat: 'CSV',
8
+ Sort: 'CreationDate:DESC',
9
+ Preview: false,
10
+ Filters: {},
11
+ Columns: [ 'Id', 'CreationDate' ]
12
+ }
13
+ MangoPay::Report.create(params)
14
+ end
15
+
16
+ describe 'CREATE' do
17
+ it 'creates a report' do
18
+ created = create
19
+ expect(created['Id']).to_not be_nil
20
+ end
21
+ end
22
+
23
+ describe 'FETCH' do
24
+
25
+ it 'fetches a report' do
26
+ created = create
27
+ fetched = MangoPay::Report.fetch(created['Id'])
28
+ expect(fetched['Id']).to eq(created['Id'])
29
+ end
30
+
31
+ it 'fetches all the reports' do
32
+ reports = MangoPay::Report.fetch()
33
+ expect(reports).to be_kind_of(Array)
34
+ expect(reports).not_to be_empty
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -1,34 +1,3 @@
1
- ###############################################
2
- shared_context 'clients' do
3
- ###############################################
4
-
5
- require 'securerandom'
6
-
7
- let(:client_id) {
8
- SecureRandom.hex(10)
9
- }
10
-
11
- let(:wrong_client_id) {
12
- SecureRandom.hex(20)
13
- }
14
-
15
- let(:wrong_client) {
16
- MangoPay::Client.create({
17
- 'ClientID' => wrong_client_id,
18
- 'Name' => 'What a nice name',
19
- 'Email' => 'clientemail@email.com'
20
- })
21
- }
22
-
23
- let(:new_client) {
24
- MangoPay::Client.create({
25
- 'ClientID' => client_id,
26
- 'Name' => 'What a nice name',
27
- 'Email' => 'clientemail@email.com'
28
- })
29
- }
30
- end
31
-
32
1
  ###############################################
33
2
  shared_context 'users' do
34
3
  ###############################################
data/spec/spec_helper.rb CHANGED
@@ -23,6 +23,7 @@ reset_mangopay_configuration
23
23
 
24
24
  ################################################################################
25
25
  # uncomment it for logging all http calls in tests
26
+ # require 'pp'
26
27
  # require 'http_logger'
27
28
  # require 'logger'
28
29
  # HttpLogger.logger = Logger.new(STDOUT)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangopay
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.21
4
+ version: 3.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Lorieux
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-20 00:00:00.000000000 Z
12
+ date: 2016-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -91,6 +91,7 @@ files:
91
91
  - lib/mangopay/pay_out.rb
92
92
  - lib/mangopay/pre_authorization.rb
93
93
  - lib/mangopay/refund.rb
94
+ - lib/mangopay/report.rb
94
95
  - lib/mangopay/resource.rb
95
96
  - lib/mangopay/temp.rb
96
97
  - lib/mangopay/transaction.rb
@@ -123,6 +124,7 @@ files:
123
124
  - spec/mangopay/payout_bankwire_spec.rb
124
125
  - spec/mangopay/preauthorization_spec.rb
125
126
  - spec/mangopay/refund_spec.rb
127
+ - spec/mangopay/report_spec.rb
126
128
  - spec/mangopay/shared_resources.rb
127
129
  - spec/mangopay/temp_paymentcard_spec.rb
128
130
  - spec/mangopay/transaction_spec.rb
@@ -151,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
153
  version: '0'
152
154
  requirements: []
153
155
  rubyforge_project:
154
- rubygems_version: 2.4.5.1
156
+ rubygems_version: 2.2.3
155
157
  signing_key:
156
158
  specification_version: 4
157
159
  summary: Ruby bindings for the version 2 of the MANGOPAY API
@@ -180,6 +182,7 @@ test_files:
180
182
  - spec/mangopay/payout_bankwire_spec.rb
181
183
  - spec/mangopay/preauthorization_spec.rb
182
184
  - spec/mangopay/refund_spec.rb
185
+ - spec/mangopay/report_spec.rb
183
186
  - spec/mangopay/shared_resources.rb
184
187
  - spec/mangopay/temp_paymentcard_spec.rb
185
188
  - spec/mangopay/transaction_spec.rb