currency_cloud 0.2.0 currency_cloud: ^0.2.0 copied to clipboard
A dart library for the Currency Cloud service. It operates as a wrapper for the Currency Cloud REST API.
import 'package:currency_cloud/currency_cloud.dart';
main() async {
final cc = new CurrencyCloud('loginId', 'apiKey');
// 1. Authenticate
await cc.authApi.authenticate();
// 2. Get a Quote
final buyCurrency = new Currency('EUR');
final sellCurrency = new Currency('GBP');
final fixedSide = FixedSide.buy;
final amount = '1000.00';
final rates = await cc.ratesApi.detailed(buyCurrency, sellCurrency, fixedSide, amount);
print(rates);
// 3. Convert
final reason = 'Invoice Payment';
final termAgreement = true;
final conversion = await cc.conversionApi.create(buyCurrency, sellCurrency, fixedSide, amount, reason, termAgreement);
// 4. Add a Beneficiary
final bankAccountHolderName = 'Acme GmbH';
final bankCountry = 'DE';
final currency = new Currency('EUR');
final name = '';
final iban = 'DE89370400440532013000';
final bicSwift = 'COBADEFF';
final beneficiary = await cc.beneficiariesApi
.create(bankAccountHolderName, bankCountry, currency, name, iban: iban, bicSwift: bicSwift);
// 5. Pay
final money = new Money.fromString(amount, buyCurrency);
final reference = 'Invoice 1234';
final payment =
await cc.paymentsApi.create(money, beneficiary['id'], reason, reference, conversionId: conversion['id']);
print(payment);
}