getCheckoutMultiPassToken static method
Implementation
static Future<Map<String, dynamic>> getCheckoutMultiPassToken({
required String phone,
required String email,
required String gkAccessToken,
String? id,
bool? notifications,
}) async {
try {
final gokwik = DioClient().getClient();
gokwik.options.headers[cdnConfigInstance.getHeader(APIHeaderKeys.gkAccessToken)!] = gkAccessToken;
final response = await gokwik.post(
cdnConfigInstance.getEndpoint(APIEndpointKeys.shopifyMultipass)!,
data: {
'id': id ?? '',
'email': email,
'redirectUrl': '/',
'isMarketingEventSubscribed': notifications,
'skipEmailOtp': true,
},
);
final userData = {
...response.data?['data'],
'phone': phone,
};
// await trackAnalyticsEvent(AnalyticsEvents.appLoginShopifySuccess, {
// 'email': userData['email']?.toString() ?? "",
// 'phone': phone,
// 'customer_id': userData['shopifyCustomerId']?.toString() ?? "",
// });
await cacheInstance.setValue(
cdnConfigInstance.getKeys(StorageKeyKeys.gkVerifiedUserKey)!,
jsonEncode(userData),
);
await SnowplowTrackerService.sendCustomEventToSnowPlow({
'category': 'sso_login',
'label': 'checkout_sso_logged_in',
'action': 'logged_in',
'property': 'phone_number',
'value': int.tryParse(phone) ?? 0,
});
return response.data;
} catch (error) {
throw await ApiService.handleApiError(error);
}
}