kfAddAddress static method
Saves a new address for a phone number. Sets muToken + x-idempotency-key on global client headers (mirrors RN), then removes x-idempotency-key after the call to avoid polluting other requests.
Implementation
static Future<dynamic> kfAddAddress({
required String phone,
required String userAuthToken,
required Map<String, dynamic> address,
String? email,
bool consent = true,
}) =>
_withRetry(() async {
final gokwik = DioClient().getClient();
final idempotencyKey = _generateUuid();
gokwik.options.headers[APIHeader.muToken] = userAuthToken;
gokwik.options.headers[APIHeader.xIdempotencyKey] = idempotencyKey;
try {
final response = await gokwik.post(
cdnConfigInstance.getEndpoint(APIEndpointKeys.kfAddresses)!,
data: {
'phone': phone,
'consent': consent,
'address': address,
if (email != null && email.isNotEmpty) 'email': email,
},
);
return response.data;
} finally {
// remove x-idempotency-key to avoid affecting other requests
gokwik.options.headers.remove(APIHeader.xIdempotencyKey);
}
});