Roadsdata Dart HTTP Client
A Dart package for interacting with the Roadsdata API, featuring robust error handling and retry mechanisms using the dio
and dio_smart_retry
packages.
Table of Contents
Introduction
This package provides an easy-to-use HTTP client for the Roadsdata API, supporting operations like checking advertisements for containers, performing test ad checks, and tracking user actions. It's designed to seamlessly handle network issues by implementing automatic retries.
Installation
To add the package to your Dart or Flutter project, include the following in your pubspec.yaml
file:
dependencies:
dio: ^4.0.0
dio_smart_retry: ^2.0.0
Then run:
flutter pub get
Features
- Configurable HTTP client with custom timeouts and headers.
- Automatic retries on failure with custom delay strategy.
- Support for both anonymous and authenticated requests.
- Easy tracking of user actions like click, impression, and close.
Dependencies
dio
: A powerful Dart HTTP client for making requests.dio_smart_retry
: Adds retry functionality to Dio requests.
Configuration
See the RoadsdataHttpClient.init
method for initial configuration. Adjust the base URL, headers, and retry policies as needed.
Usage
Initialize the dart http client with RoadsdataHttpClient.init
.
Use the httpClient's function to use integrate Roadsdata in your custom implementation.
var httpClient = RoadsdataHttpClient.init(
host: 'YOUR_HOST',
clientId: 'YOUR_CLIENT_ID',
accessToken: 'YOUR_ACCES_TOKEN',
uuid: 'YOUR_UUID'
);
httpClient.checkAdForContainer('CONTAINER_ID')
Additional information
If you want to know more about Roadsdata, visit https://roadsdata.it/