treasury_direct 0.1.1

treasury_direct #

Build Status codecov

A Dart library package to access the debt of the United States from the US Treasury Direct site. Can be used in a command line app or in a Flutter app.

Example #

import 'package:treasury_direct/treasury_direct.dart';
import 'package:treasury_direct/src/debt_entry.dart';

void main() async {
  final td = TreasuryDirect();
  final list = await td.downloadDebtFeedAsync(pagesize: 15);

  print('Total possible rows: ${list.totalRows}');

  print('Total row received: ${list.mostRecentList.length}');
  for (DebtEntry entry in list.mostRecentList) {
    print('${DebtEntry.dateFormatted(entry.effectiveDate)}: ${DebtEntry.currencyShortened(entry.totalDebt, false)}');
  }
}

Expected output:

Total possible rows: 6486
Total row received: 15
Nov 8, 2018: $21.73T
Nov 7, 2018: $21.69T
Nov 6, 2018: $21.69T
Nov 5, 2018: $21.68T
Nov 2, 2018: $21.68T
Nov 1, 2018: $21.68T
Oct 31, 2018: $21.70T
Oct 30, 2018: $21.70T
Oct 29, 2018: $21.70T
Oct 26, 2018: $21.69T
Oct 25, 2018: $21.70T
Oct 24, 2018: $21.67T
Oct 23, 2018: $21.68T
Oct 22, 2018: $21.67T
Oct 19, 2018: $21.67T

Treasury Direct API Docs: #

https://www.treasurydirect.gov/webapis/webapisdebt.htm

0.1.0 #

  • Initial Open Source release.

example/example.dart

import 'package:treasury_direct/treasury_direct.dart';
import 'package:treasury_direct/src/debt_entry.dart';

void main() async {
  final td = TreasuryDirect();
  final list = await td.downloadDebtFeedAsync(pagesize: 15);

  print('Total possible rows: ${list.totalRows}');

  print('Total row received: ${list.mostRecentList.length}');
  for (DebtEntry entry in list.mostRecentList) {
    print(
        '${DebtEntry.dateFormatted(entry.effectiveDate)}: ${DebtEntry.currencyShortened(entry.totalDebt, false)}');
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  treasury_direct: ^0.1.1

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:treasury_direct/treasury_direct.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Aug 16, 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:treasury_direct/treasury_direct.dart.

Health suggestions

Fix lib/src/debt_entry.dart. (-1.49 points)

Analysis of lib/src/debt_entry.dart reported 3 hints:

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

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

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
async ^2.0.8 2.3.0
convert ^2.0.2 2.1.1
http ^0.12.0 0.12.0+2
intl ^0.15.7 0.15.8
Transitive dependencies
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
coverage ^0.12.3
test ^1.5.1