activateUserAccount static method
Implementation
static Future<Result<dynamic>> activateUserAccount(
String id, String url, String password, String token) async {
final result = await checkKwikpassHealth();
if(result.isSuccess) {
final healthData = result.getDataOrThrow();
if(healthData?.isKwikpassHealthy == false){
throw Exception('Kwikpass is unhealthy');
}
}
final data = {
'form_type': 'activate_customer_password',
'utf8': '✓',
'customer[password]': password,
'customer[password_confirmation]': password,
'token': token,
'id': id,
};
try {
final phone = await cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkUserPhone)!);
await SnowplowTrackerService.sendCustomEventToSnowPlow({
'category': 'login_modal',
'label': 'account_activated',
'action': 'automated',
'property': 'phone_number',
'value': int.tryParse(phone ?? '0') ?? 0,
});
final response = await Dio().post(
'https://$url/account/activate',
data: data,
options: Options(
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
followRedirects: false,
),
);
return Success(response);
} catch (err) {
final apiError = handleApiError(err);
return apiError;
}
}