diff options
Diffstat (limited to 'lib/cepis.dart')
| -rw-r--r-- | lib/cepis.dart | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/cepis.dart b/lib/cepis.dart new file mode 100644 index 0000000..2bc42b8 --- /dev/null +++ b/lib/cepis.dart @@ -0,0 +1,51 @@ +/// Dart client for the [public CEP API at cep.is](https://cep.is). +/// +/// Official Correios data (DNE), refreshed every two weeks. Pure Dart, so the +/// same code runs on the VM, in AOT binaries and everywhere Flutter runs, +/// Web included. +/// +/// ```dart +/// import 'package:cepis/cepis.dart' as cepis; +/// +/// final address = await cepis.lookup('01001-000'); +/// print('${address.logradouro} ${address.localidade} ${address.uf}'); +/// // Praça da Sé São Paulo SP +/// ``` +/// +/// Data fields keep the API's own Portuguese names; everything else — methods, +/// types, errors — is English. +library; + +import 'src/client.dart'; +import 'src/models.dart'; + +export 'src/client.dart' + show Client, defaultBaseUrl, maxBatch, normalizeCep, retriableStatus; +export 'src/errors.dart' + show + CepNotFoundException, + CepisException, + InvalidCepException, + InvalidResponseException, + NetworkException, + RateLimitedException, + ServerException; +export 'src/models.dart' show Address, Geo, Health; + +final Client _default = Client(); + +/// The [Client] behind the top-level [lookup], [lookupMany] and [health]. +/// +/// It applies process-wide, third-party packages included. Need a different +/// configuration? Build your own [Client] rather than reaching in here. +Client get defaultClient => _default; + +/// Looks up a single CEP with [defaultClient]. See [Client.lookup]. +Future<Address> lookup(String cep) => _default.lookup(cep); + +/// Looks up many CEPs with [defaultClient]. See [Client.lookupMany]. +Future<List<Address?>> lookupMany(List<String> ceps) => + _default.lookupMany(ceps); + +/// Queries the API's health with [defaultClient]. See [Client.health]. +Future<Health> health() => _default.health(); |