def test_login(self): AuthenticationClient(self.mock_config).getTokenFromClientCredentials() self.assertNotEqual(self.mock_config.context.token, None) with VeemClient(configs=self.config_yaml, useClientCredentials=True) as veem: self.assertNotEqual(veem.config.context.token, None)
def test_country_currency_map(self): ccMap = MetadataClient(self.mock_config).getCountryCurrencyMap() self.assertEqual(ccMap.content[0].country, 'AE') with VeemClient(yaml_file=self.config_file) as veem: rate = veem.metadataClient.getCountryCurrencyMap() self.assertEqual(ccMap.content[0].country, 'AE')
def test_customers(self): AuthenticationClient(self.mock_config).getTokenFromClientCredentials() customers = CustomerClient(self.mock_config).list('*****@*****.**') self.assertEqual(customers.content[0].email, '*****@*****.**') with VeemClient(yaml_file=self.config_file, useClientCredentials=True) as veem: customers = veem.customerClient.list('*****@*****.**') self.assertEqual(customers.content[0].email, '*****@*****.**')
def test_generate_rate(self): request = ExchangeRateRequest(fromAmount=500.0, fromCurrency='CAD', fromCountry='CA', toCurrency='USD', toCountry='US') rate = ExchangeRateClient(self.mock_config).generate(request) self.assertNotEqual(rate.hashId, None) with VeemClient(configs=self.config_yaml, useClientCredentials=True) as veem: rate = veem.exchangeRateClient.generate(request) self.assertNotEqual(rate.hashId, None)
def test_attachments(self): AuthenticationClient(self.mock_config).getTokenFromClientCredentials() attachment = AttachmentClient(self.mock_config).upload( dict(path=self.attachment_path), 'invoice for shipping') self.assertTrue(bool(attachment.referenceId)) attachment = AttachmentClient(self.mock_config).download(attachment) self.assertTrue(bool(attachment)) with VeemClient(yaml_file=self.config_file, useClientCredentials=True) as veem: attachment = veem.attachmentClient.upload( dict(path=self.attachment_path), 'invoice for shipping') self.assertTrue(bool(attachment.referenceId)) attachment = veem.attachmentClient.download(attachment) self.assertTrue(bool(attachment))
def test_invoices(self): AuthenticationClient(self.mock_config).getTokenFromClientCredentials() request = InvoiceRequest(payer=dict(type='Business', email='*****@*****.**', firstName='Wei', lastName='Chen', businessName='GBP Veem Wei', countryCode='GB', phoneCountryCode='44', phone='03700100222'), status='Drafted', amount=dict(number=50, currency='GBP')) invoice = InvoiceClient(self.mock_config).create(request) self.assertEqual(invoice.payer.email, '*****@*****.**') self.assertEqual(invoice.amount.currency, 'GBP') # self.assertEqual(invoice.status, 'Drafted') invoice = InvoiceClient(self.mock_config).get(invoice.id) # self.assertEqual(invoice.payer.email, '*****@*****.**') self.assertEqual(invoice.amount.currency, 'GBP') # self.assertEqual(invoice.status, 'Drafted') # invoice = InvoiceClient(self.mock_config).send(invoice.id) # self.assertEqual(invoice.payer.email, '*****@*****.**') # self.assertEqual(invoice.amount.currency, 'GBP') # self.assertEqual(invoice.status, 'Sent') invoice = InvoiceClient(self.mock_config).cancel(invoice.id) self.assertEqual(invoice.payer.email, '*****@*****.**') self.assertEqual(invoice.amount.currency, 'GBP') self.assertEqual(invoice.status, 'Cancelled') with VeemClient(yaml_file=self.config_file, useClientCredentials=True) as veem: invoice = veem.invoiceClient.create(request) self.assertEqual(invoice.payer.email, '*****@*****.**') self.assertEqual(invoice.amount.currency, 'GBP') # self.assertEqual(invoice.status, 'Drafted') invoice = veem.invoiceClient.get(invoice.id) # self.assertEqual(invoice.payer.email, '*****@*****.**') self.assertEqual(invoice.amount.currency, 'GBP') # self.assertEqual(invoice.status, 'Drafted') # invoice = veem.invoiceClient.send(invoice.id) # self.assertEqual(invoice.payer.email, '*****@*****.**') # self.assertEqual(invoice.amount.currency, 'GBP') # self.assertEqual(invoice.status, 'Sent') invoice = veem.invoiceClient.cancel(invoice.id) self.assertEqual(invoice.payer.email, '*****@*****.**') self.assertEqual(invoice.amount.currency, 'GBP') self.assertEqual(invoice.status, 'Cancelled')
def test_payments(self): AuthenticationClient(self.mock_config).getTokenFromClientCredentials() request = PaymentRequest(payee=dict(type='Business', email='*****@*****.**', firstName='Wei', lastName='Chen', businessName='GBP Veem Wei', countryCode='GB', phoneCountryCode='44', phone='03700100222'), amount=dict(number=50, currency='GBP')) payment = PaymentClient(self.mock_config).create(request) self.assertEqual(payment.payee.email, '*****@*****.**') self.assertEqual(payment.amount.currency, 'GBP') self.assertEqual(payment.status, 'Drafted') payment = PaymentClient(self.mock_config).get(payment.id) self.assertEqual(payment.status, 'Drafted') payment = PaymentClient(self.mock_config).send(payment.id) self.assertEqual(payment.status, 'Sent') payment = PaymentClient(self.mock_config).cancel(payment.id) self.assertEqual(payment.status, 'Cancelled') payments = PaymentClient(self.mock_config).list() payment = payments.content[0] self.assertEqual(payment.amount.currency, 'GBP') self.assertEqual(payment.status, 'Cancelled') with VeemClient(yaml_file=self.config_file, useClientCredentials=True) as veem: payment = veem.paymentClient.create(request) self.assertEqual(payment.payee.email, '*****@*****.**') self.assertEqual(payment.amount.currency, 'GBP') self.assertEqual(payment.status, 'Drafted') payment = veem.paymentClient.get(payment.id) self.assertEqual(payment.status, 'Drafted') payment = veem.paymentClient.send(payment.id) self.assertEqual(payment.status, 'Sent') payment = veem.paymentClient.cancel(payment.id) self.assertEqual(payment.status, 'Cancelled') payments = veem.paymentClient.list() payment = payments.content[0] self.assertEqual(payment.status, 'Cancelled')
from veem.client.veem import VeemClient from veem.client.requests.payment import PaymentRequest if __name__ == '__main__': # define a VeemClient Context Manager with yaml+file and auto login. with VeemClient(yaml_file='/path/to/your/configuration.yaml', useClientCredentials=True) as veem: # define an PaymentRequest request = PaymentRequest(payee=dict(type='Business', email='*****@*****.**', firstName='Joe', lastName='Doe', businessName='Your Business Inc.', countryCode='US', phoneCountryCode='1', phone='02222222222'), amount=dict(number=50, currency='USD')) # create a Draft payment payment = veem.paymentClient.create(request) # send the Drafted payment payment = veem.paymentClient.send(payment.id)