getZainboxProfile method

Future<ZainboxProfileResponse?> getZainboxProfile()

Executes network call to initiate transactions

Implementation

Future<ZainboxProfileResponse?> getZainboxProfile() async {

  ZainboxProfileResponse? zainboxProfileResponse = ZainboxProfileResponse();

  final url = "${Utils.getBaseUrl(isTest)}/${Utils.zainboxProfileUrl}/$zainboxCode";

  final response = await http.get(Uri.parse(url),
      headers: {
        "Authorization" : "Bearer $publicKey",
        "Content-Type" : "application/json"
      }
  );

  final responseBody = jsonDecode(response.body);
  zainboxProfileResponse = ZainboxProfileResponse.fromJson(responseBody);

  return zainboxProfileResponse;
}