currency_cloud 1.0.3

Currency Cloud Dart API #

Gitlab Status Pub Status

A dart library for the Currency Cloud service

Usage #

A simple usage example

Changelog #

1.0.3 #

  • Upgraded dependencies

1.0.2 #

  • Add missing underscore for certain Beneficiary keys

1.0.1 #

  • Fix wrong cast in the references data API call
  • Switch to json_serialize instead of codable for JSON (de)serialization

1.0.0 #

  • Use classes instead of maps for all API messages
  • Remove money dependency
  • Revert to use String of currency codes again

0.3.0 #

  • Fix all implicit type casts and cleanup for dart 2.0

0.2.0 #

  • Add missing pub dependency
  • PaymentsApi.create() now uses PaymentType instead of a String
  • API calls with currencies as arguments use Currency from money now instead of String

0.1.0 #

  • Add grinder for formatting and testing
  • Add ci for gitlab
  • Remove defunct authentication test
  • Remove integration tests
  • Remove debug output
  • Update gitignore

0.0.8 #

  • switch to new api url

0.0.7 #

  • add balance api (retrieve)

0.0.1 #

  • Initial version, created by Stagehand

example/example.dart

import 'package:currency_cloud/currency_cloud.dart';
import 'package:decimal/decimal.dart';

main() async {
  final cc = new CurrencyCloud('loginId', 'apiKey');

  // 1. Authenticate
  await cc.authApi.authenticate();

  // 2. Get a Quote
  final buyCurrency = 'EUR';
  final sellCurrency = 'GBP';
  final fixedSide = FixedSide.buy;
  final amount = new Decimal.parse('1000.00');

  final rate = await cc.ratesApi.detailed(DetailedRateRequest(
    buyCurrency: buyCurrency,
    sellCurrency: sellCurrency,
    fixedSide: fixedSide,
    amount: amount,
  ));
  print(rate);

  // 3. Convert
  final createConversion = new CreateConversion(
    buyCurrency: buyCurrency,
    sellCurrency: sellCurrency,
    fixedSide: fixedSide,
    amount: amount,
    termAgreement: true,
    reason: 'Invoice Payment',
  );

  final conversion = await cc.conversionApi.create(createConversion);
  print(conversion);

  // 4. Add a Beneficiary
  final createBeneficiary = new CreateBeneficiary(
    name: 'My Test Beneficiary',
    bankAccountHolderName: 'My Test Account Holder',
    bankCountry: 'DE',
    currency: buyCurrency,
    iban: 'DE89370400440532013000',
    bicSwift: 'COBADEFF',
  );

  final beneficiary = await cc.beneficiariesApi.create(createBeneficiary);
  print(beneficiary);

  // 5. Pay
  final createPayment = new CreatePayment(
    currency: buyCurrency,
    beneficiaryId: '9b40b6e7-5d18-42ac-87bc-5c5f774e91ab',
    amount: amount,
    reason: 'This is a test payment.',
    reference: 'This is a test reference.',
  );

  final payment = await cc.paymentsApi.create(createPayment);
  print(payment);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  currency_cloud: ^1.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:currency_cloud/currency_cloud.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:currency_cloud/currency_cloud.dart.

Health suggestions

Fix lib/currency_cloud.dart. (-1 points)

Analysis of lib/currency_cloud.dart reported 2 hints:

line 45 col 23: Use = to separate a named parameter from its default value.

line 52 col 48: Use = to separate a named parameter from its default value.

Fix lib/src/api/reference_data.dart. (-1 points)

Analysis of lib/src/api/reference_data.dart reported 2 hints:

line 18 col 7: DO use curly braces for all flow control structures.

line 20 col 7: DO use curly braces for all flow control structures.

Fix lib/src/api/messages/payment.dart. (-0.50 points)

Analysis of lib/src/api/messages/payment.dart reported 1 hint:

line 38 col 21: Use = to separate a named parameter from its default value.

Fix lib/src/base/currency_cloud_base.dart. (-0.50 points)

Analysis of lib/src/base/currency_cloud_base.dart reported 1 hint:

line 25 col 66: Use = to separate a named parameter from its default value.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.22.0 <3.0.0
decimal ^0.3.2 0.3.3
http >=0.11.0 <0.13.0 0.12.0+2
json_annotation >=1.1.0 <3.0.0 2.4.0
logging ^0.11.0 0.11.3+2
meta ^1.1.6 1.1.7
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
pedantic 1.8.0+1
rational 0.3.4
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^1.0.1
glob ^1.1.0
grinder ^0.8.3
json_serializable >=1.1.0 <3.0.0
mockito ^4.0.0
path ^1.6.0 1.6.2
test ^1.0.0
yaml ^2.1.0

Admin