-
Notifications
You must be signed in to change notification settings - Fork 33
Networking
In this project we use HTTP client generator for Dart - chopper
Chopper library is already set, it is used for getting tasks and authentication of users.
Implemented services:
TasksApiServiceUserApiServiceUserAuthApiService
HttpApiServiceProvider will configure ChopperClient and all services used.
Feel free to change this configuration as you need.
For more information on getting started with chopper and how to use the ChopperService class head to the chopper's getting started guide.
RefreshTokenAuthenticator is already implemented, this feature will detect 401 HTTP response code and will try to refresh the user token if possible. If the token is refreshed successfully it will repeat the already failed API call with the new token and return as if nothing happened, or if it fails to refresh the token exception will be thrown.
With RefreshTokenAuthenticator you can interceptRequest and interceptResponse.
JsonTypeConverter is custom converter that is used in this project.
To use the custom JsonTypeConverter you must register converters for all json serializable models.
If you miss to register a type converter you'll get a warning log at runtime:
Log.w('JsonTypeConverter - No converter found for type: $type');
ResponseToTypeConverter is another custom converter that converts chopper's result Response to BodyType.
For more info on this check the open discussion at chopper's GitHub page.
-
AuthInteceptor- adds authorization header -
ErrorInterceptor- will parse errors -
HttpLoggerInterceptor- usesLoginstead of chopper logger -
LanguageInteceptor- adds preferred language header -
VersionInterceptor- adds the supported app version header