Skip to content

Commit

Permalink
Merge pull request #354 from Mangopay/feature/quoted_conversion
Browse files Browse the repository at this point in the history
quoted conversion
  • Loading branch information
mihaimoiseanu authored Mar 7, 2024
2 parents a627cbc + 65c4a89 commit 090f892
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
12 changes: 12 additions & 0 deletions mangopay/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2157,3 +2157,15 @@ class Meta:
SelectQuery.identifier: '/deposit-preauthorizations/',
UpdateQuery.identifier: '/deposit-preauthorizations/'
}


class QuotedConversion(Transaction):
quote_id = CharField(api_name='QuoteId')
conversion_rate = ConversionRateField(api_name='ConversionRateResponse')

class Meta:
verbose_name = 'quoted_conversion'
verbose_name_plural = 'quoted_conversions'
url = {
InsertQuery.identifier: '/conversions/quoted-conversion'
}
29 changes: 28 additions & 1 deletion tests/test_conversion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mangopay.resources import ConversionQuote
from mangopay.resources import ConversionQuote, QuotedConversion
from mangopay.utils import Money
from tests.resources import ConversionRate, Conversion, Wallet
from tests.test_base import BaseTestLive
Expand Down Expand Up @@ -114,3 +114,30 @@ def test_get_conversion_quote(self):
self.assertIsNotNone(response.conversion_rate)
self.assertEqual('ACTIVE', response.status)

def test_create_quoted_conversion(self):
user = BaseTestLive.get_john()

credited_wallet = Wallet()
credited_wallet.owners = (user,)
credited_wallet.currency = 'GBP'
credited_wallet.description = 'WALLET IN GBP'
credited_wallet = Wallet(**credited_wallet.save())
debited_wallet = BaseTestLive.create_new_wallet_with_money()

conversion_quote = ConversionQuote()
conversion_quote.credited_funds = Money(currency='GBP')
conversion_quote.debited_funds = Money(currency='EUR', amount=50)
conversion_quote.duration = 90
conversion_quote.tag = "Created using the Mangopay Python SDK"
created_conversion_quote = conversion_quote.create_conversion_quote()

quotedConversion = QuotedConversion()
quotedConversion.quote_id = created_conversion_quote['id']
quotedConversion.author_id = debited_wallet.owners_ids[0]
quotedConversion.credited_wallet = credited_wallet
quotedConversion.debited_wallet = debited_wallet

response = quotedConversion.save()
self.assertIsNotNone(response)


0 comments on commit 090f892

Please sign in to comment.