gojek / courier-flutter

Dart port of our popular courier library
43 stars 8 forks source link

Create AuthProviderInterface for getting CourierConnectOptions #12

Closed alfianlosari closed 1 year ago

alfianlosari commented 1 year ago

Currently, we need to pass Dio for making HTTP call to fetch CourierConnectOptions. For clients that don't need to fetch the auth from network, they have to create an endpoint and return the response.

This MR solves the problem by creating AuthProvider interface with one method to fetchConnectOptions that returns a Future so it will work for async dio http call as well as just returning the value by creating an immediate future value.

I have provided a concrete implementations for the interface: DioAuthProvider -> Use dio to make async http call given an URL to fetch CourierConnectOptions AuthResponse

I also included example LocalAuthProvider in sample demo app for retrieving connect options locally without making http api call.