ParodiaHTTP constructor

ParodiaHTTP({
  1. required String baseUrl,
  2. required String storeKey,
  3. String? authToken,
  4. String? currency,
})

Creates a new instance of ParodiaHTTP.

The parameters can be used to specify the initial values for the base URL, store key, authentication token, and currency.

Implementation

ParodiaHTTP({
  required String baseUrl,
  required String storeKey,
  String? authToken,
  String? currency,
}) {
  _dio = Dio();
  _baseUrl = baseUrl;
  _storeKey = storeKey;
  _authToken = authToken;
  _currency = currency;

  _headers["Store"] = _storeKey;

  if (authToken != null) {
    _headers["Authorization"] = "Bearer $_authToken";
  }

  if (currency != null) {
    _headers["Currency"] = currency;
  }

  _options.baseUrl = _baseUrl;
  _options.headers = _headers;
  _dio!.options = _options;
}