getZAKToken method

Future<Response> getZAKToken({
  1. required String clientId,
  2. required String clientSecret,
  3. required String accessToken,
})

Implementation

Future<Response> getZAKToken(
    {required String clientId,
    required String clientSecret,
    required String accessToken}) async {
  const url = ZoomConstants.zakTokenUrl;

  final options = Options(
    headers: {
      "Authorization": "Bearer $accessToken",
      "Content-Type": "application/json",
    },
  );

  try {
    final response = await dio.get(url, options: options);

    if (response.statusCode == 200) {
      return response;
    } else {
      throw Exception('Failed to fetch data: ${response.statusCode}');
    }
  } on DioException catch (e) {
    if (e.response?.statusCode == 404) {
      throw Exception('Something went wrong... ${e.message}');
    } else {
      throw Exception('Failed to log in: ${e.message}');
    }
  } catch (e) {
    throw Exception('Failed to fetch data: $e');
  }
}