-
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 #247 from Mangopay/feature/conversion-updates
Feature/conversion updates
- Loading branch information
Showing
6 changed files
with
144 additions
and
62 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,39 @@ | ||
module MangoPay | ||
|
||
class Conversion < Resource | ||
include HTTPCalls::Fetch | ||
include HTTPCalls::Update | ||
|
||
class << self | ||
def get_rate(debited_currency, credited_currency, params) | ||
url = "#{MangoPay.api_path}/conversions/rate/#{debited_currency}/#{credited_currency}" | ||
MangoPay.request(:get, url, params) | ||
end | ||
|
||
def create_instant_conversion(params) | ||
url = "#{MangoPay.api_path}/conversions/instant-conversion" | ||
MangoPay.request(:post, url, params) | ||
end | ||
|
||
def create_quoted_conversion(params) | ||
url = "#{MangoPay.api_path}/conversions/quoted-conversion" | ||
MangoPay.request(:post, url, params) | ||
end | ||
|
||
def get(id, params) | ||
url = "#{MangoPay.api_path}/conversions/#{id}" | ||
MangoPay.request(:get, url, params) | ||
end | ||
|
||
def create_quote(params) | ||
url = "#{MangoPay.api_path}/conversions/quote" | ||
MangoPay.request(:post, url, params) | ||
end | ||
|
||
def get_quote(id, params) | ||
url = "#{MangoPay.api_path}/conversions/quote/#{id}" | ||
MangoPay.request(:get, url, params) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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,64 @@ | ||
describe MangoPay::Conversion, 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 INSTANT CONVERSION' do | ||
it 'creates a new instant conversion' do | ||
conversion = create_instant_conversion | ||
|
||
expect(conversion['DebitedFunds']['Amount']).not_to be_nil | ||
expect(conversion['CreditedFunds']['Amount']).not_to be_nil | ||
expect(conversion['Fees']['Amount']).not_to be_nil | ||
expect(conversion['Status']).equal? 'SUCCEEDED' | ||
end | ||
end | ||
|
||
describe 'CREATE QUOTED CONVERSION' do | ||
it 'creates a new quoted conversion' do | ||
conversion = create_quoted_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_conversion(conversion['Id']) | ||
|
||
expect(returned_conversion['DebitedFunds']['Amount']).not_to be_nil | ||
expect(returned_conversion['CreditedFunds']['Amount']).not_to be_nil | ||
expect(conversion['Fees']['Amount']).not_to be_nil | ||
expect(returned_conversion['Status']).equal? 'SUCCEEDED' | ||
end | ||
end | ||
|
||
describe 'CREATE CONVERSION QUOTE' do | ||
it 'create a conversion quote' do | ||
conversion_quote = create_conversion_quote | ||
expect(conversion_quote['DebitedFunds']).not_to be_nil | ||
expect(conversion_quote['CreditedFunds']).not_to be_nil | ||
expect(conversion_quote['Duration']).equal? 90 | ||
end | ||
end | ||
|
||
describe 'GET CONVERSION QUOTE' do | ||
it 'get a conversion quote' do | ||
conversion_quote = create_conversion_quote | ||
returned_conversion_quote = get_conversion_quote(conversion_quote['Id']) | ||
expect(returned_conversion_quote['DebitedFunds']).not_to be_nil | ||
expect(returned_conversion_quote['CreditedFunds']).not_to be_nil | ||
expect(returned_conversion_quote['Duration']).equal? 90 | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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