bannerAction method
Implementation
Future<void> bannerAction(BannerResponse banner, {String? action}) async {
final storage = HiveStorageService.instance;
Map<String, dynamic> context = {
'deviceId': await storage.getDeviceId(),
'sessionId': await storage.getSessionId(),
'profile': {'id': await storage.getProfileId()},
'bid': banner.token
};
if (action != null) {
context['action'] = action;
}
final response = await http.post(
Uri.parse('${_getEndpoint()}/api/v0/push'),
headers: {
'content-type': 'application/json',
'authorization': 'Bearer $_accessToken',
},
body: jsonEncode({
'context': context
}),
);
if (response.statusCode != 200) {
throw Exception(
'Banner Push ${action} API error: - ${response.statusCode} - ${response.body}',
);
}
}