getKfAssetsProperties static method

Future<Result> getKfAssetsProperties()

Implementation

static Future<Result<dynamic>> getKfAssetsProperties() async {
  await checkKwikpassHealth();

  try {
    final gokwik = DioClient().getClient();

    final results = await Future.wait([
      cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkMerchantIdKey)!),
      cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.kpRequestIdKey)!),
    ]);

    final mid = results[0];
    final requestId = results[1];

    final headers = <String, String>{
      cdnConfigInstance.getHeader(APIHeaderKeys.gkMerchantId)!: mid ?? '',
      cdnConfigInstance.getHeader(APIHeaderKeys.kpRequestId)!: requestId ?? '',
    };

    final response = await gokwik.get(
      '${cdnConfigInstance.getEndpoint(APIEndpointKeys.getKfAssetsProperties)!}/$mid',
      options: Options(headers: headers),
    );

    return Success(response.data);
  } catch (err) {
    throw handleApiError(err);
  }
}