addAddress static method
Implementation
static Future<Result<dynamic>> addAddress(Map<String, dynamic> body) async {
await checkKwikpassHealth();
try {
final gokwik = DioClient().getClient();
final results = await Future.wait([
cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkAccessTokenKey)!),
cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkMerchantIdKey)!),
cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkRequestIdKey)!),
cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.integrationType)!),
]);
final accessToken = results[0];
final mid = results[1];
final requestId = results[2];
final integrationType = results[3];
final headers = <String, String>{
'accept': 'application/json',
'content-type': 'application/json',
cdnConfigInstance.getHeader(APIHeaderKeys.gkMerchantId)!: mid ?? '',
cdnConfigInstance.getHeader(APIHeaderKeys.kpIntegrationType)!:
integrationType ?? 'PLUGIN',
};
if (accessToken != null && accessToken.isNotEmpty) {
headers[cdnConfigInstance.getHeader(APIHeaderKeys.gkAccessToken)!] = accessToken;
}
if (requestId != null && requestId.isNotEmpty) {
headers[cdnConfigInstance.getHeader(APIHeaderKeys.gkRequestId)!] = requestId;
}
final response = await gokwik.post(
cdnConfigInstance.getEndpoint(APIEndpointKeys.addAddress)!,
data: body,
options: Options(headers: headers),
);
return Success(response.data);
} catch (err) {
throw handleApiError(err);
}
}