-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from Mangopay/feature/spot-fx-endpoints
feature/ Implemented Spot FX endpoints
- Loading branch information
Showing
4 changed files
with
466 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module MangoPay | ||
|
||
class InstantConversion < Resource | ||
include HTTPCalls::Fetch | ||
include HTTPCalls::Update | ||
|
||
class << self | ||
def get_rate(debited_currency, credited_currency, params) | ||
url = "#{MangoPay.api_path}/conversion/rate/#{debited_currency}/#{credited_currency}" | ||
MangoPay.request(:get, url, params) | ||
end | ||
|
||
def create(params) | ||
url = "#{MangoPay.api_path}/instant-conversion" | ||
MangoPay.request(:post, url, params) | ||
end | ||
|
||
def get(id, params) | ||
url = "#{MangoPay.api_path}/instant-conversion/#{id}" | ||
MangoPay.request(:get, url, params) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
describe MangoPay::InstantConversion, type: :feature do | ||
include_context 'instant_conversion' | ||
|
||
describe 'GET CONVERSION RATE' do | ||
it 'get a conversion rate' do | ||
conversion_rate = get_conversion_rate('EUR','GBP') | ||
|
||
expect(conversion_rate['ClientRate']).not_to be_nil | ||
expect(conversion_rate['MarketRate']).not_to be_nil | ||
end | ||
end | ||
|
||
describe 'CREATE CONVERSION' do | ||
it 'creates a new conversion' do | ||
conversion = create_instant_conversion | ||
|
||
expect(conversion['DebitedFunds']['Amount']).not_to be_nil | ||
expect(conversion['CreditedFunds']['Amount']).not_to be_nil | ||
expect(conversion['Status']).equal? 'SUCCEEDED' | ||
end | ||
end | ||
|
||
describe 'GET EXISTING CONVERSION' do | ||
it 'get an existing conversion' do | ||
conversion = create_instant_conversion | ||
returned_conversion = get_instant_conversion(conversion['Id']) | ||
|
||
expect(returned_conversion['DebitedFunds']['Amount']).not_to be_nil | ||
expect(returned_conversion['CreditedFunds']['Amount']).not_to be_nil | ||
expect(returned_conversion['Status']).equal? 'SUCCEEDED' | ||
end | ||
end | ||
end |
Oops, something went wrong.