fetchBanner static method

Future<BannerResponse> fetchBanner(
  1. int domainId,
  2. String subjectIdentity
)

Implementation

static Future<BannerResponse> fetchBanner(
    int domainId, String subjectIdentity) async {
  try {
    final uri = Uri.parse(
      '$_baseUrl/ucm/banner/display?domain_id=$domainId&subject_identity=$subjectIdentity',
    );
    final response = await http.get(uri);
    dev.log("Cookie response status code => ${response.statusCode}");
    if (response.statusCode == 200) {
      dev.log("Cookie response body => ${response.body}");
      final decoded = utf8.decode(response.bodyBytes);
      return BannerResponse.fromJson(
        jsonDecode(decoded) as Map<String, dynamic>,
      );
    } else {
      return BannerResponse(exceptionType: ExceptionType.apiException);
    }
  } catch (e) {
    dev.log("Error in cookie consent -> ${e.toString()}");
    return BannerResponse(exceptionType: ExceptionType.apiException);
  }
}