initializeMerchant static method
Implementation
static Future<Result<MerchantConfig?>> initializeMerchant(
String mid, String environment) async {
try {
final gokwik = DioClient().getClient();
final response = (await gokwik.get('${cdnConfigInstance.getEndpoint(APIEndpointKeys.merchantConfiguration)!}$mid')).toBaseResponse(
fromJson: (json) => MerchantConfig.fromJson(json),
);
final merchantRes = response.data;
await cacheInstance.setValue(
cdnConfigInstance.getKeys(StorageKeyKeys.gkMerchantConfig)!,
jsonEncode(merchantRes),
);
final requestId = merchantRes?.kpRequestId;
if (requestId != null) {
await cacheInstance.setValue(
cdnConfigInstance.getKeys(StorageKeyKeys.gkRequestIdKey)!,
requestId.toString(),
);
}
return Success(merchantRes);
} catch (error) {
throw handleApiError(error);
}
}