Skip to content

Commit

Permalink
Add Transfers.
Browse files Browse the repository at this point in the history
Add Transfers resources and tests.
  • Loading branch information
glorieux committed Jul 25, 2013
1 parent c6b9527 commit b51a023
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mangopay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
require 'mangopay/legal_user'
require 'mangopay/payin'
require 'mangopay/payout'
require 'mangopay/transfer'
require 'mangopay/transaction'
require 'mangopay/wallet'
require 'mangopay/bank_detail'
Expand Down
6 changes: 6 additions & 0 deletions lib/mangopay/transfer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module MangoPay
class Transfer < Resource
include MangoPay::HTTPCalls::Create
include MangoPay::HTTPCalls::Fetch
end
end
32 changes: 32 additions & 0 deletions spec/lib/mangopay/shared_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,35 @@
})
}
end

shared_context 'transfer' do
let(:credited_wallet) {
MangoPay::Wallet.create({
Owners: [new_natural_user['Id']],
Description: 'A test wallet',
Currency: 'EUR',
Tag: 'Test Time'
})
}

let(:debited_wallet) {
MangoPay::Wallet.create({
Owners: [new_legal_user['Id']],
Description: 'A test wallet',
Currency: 'EUR',
Tag: 'Test Time'
})
}

let(:new_transfer) {
MangoPay::Transfer.create({
AuthorId: debited_wallet['Owners'][0],
CreditedUserId: credited_wallet['Owners'][0],
DebitedFunds: { Currency: 'EUR', Amount: 500},
Fees: { Currency: 'EUR', Amout: 0},
DebitedWalletId: debited_wallet['Id'],
CreditedWalletId: credited_wallet['Id'],
Tag: 'Test Transfer'
})
}
end
20 changes: 20 additions & 0 deletions spec/lib/mangopay/transfer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require_relative '../../spec_helper'

describe MangoPay::Transfer do
include_context 'users'
include_context 'wallets'
include_context 'transfer'

describe 'CREATE' do
it 'creates a new Transfer' do
expect(new_transfer['Id']).not_to be_nil
end
end

describe 'FETCH' do
it 'fetches a Transfer' do
transfer = MangoPay::Transfer.fetch(new_transfer['Id'])
expect(transfer['Id']).to eq(new_transfer['Id'])
end
end
end

0 comments on commit b51a023

Please sign in to comment.