Skip to content

Commit

Permalink
Implemented Spot FX endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Silviana Ghita committed Sep 19, 2023
1 parent 904c289 commit c5f9fa9
Show file tree
Hide file tree
Showing 4 changed files with 466 additions and 353 deletions.
1 change: 1 addition & 0 deletions lib/mangopay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module MangoPay
autoload :Ubo, 'mangopay/ubo'
autoload :Regulatory, 'mangopay/regulatory'
autoload :Deposit, 'mangopay/deposit'
autoload :InstantConversion, 'mangopay/instant_conversion'

# temporary
autoload :Temp, 'mangopay/temp'
Expand Down
24 changes: 24 additions & 0 deletions lib/mangopay/instant_conversion.rb
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
33 changes: 33 additions & 0 deletions spec/mangopay/instant_conversion_spec.rb
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
Loading

0 comments on commit c5f9fa9

Please sign in to comment.