getRefreshIdToken method

Future<GetRefreshIdTokenSuccess> getRefreshIdToken(
  1. GetRefreshIdTokenRequest getRefreshIdTokenRequest
)

Implementation

Future<GetRefreshIdTokenSuccess> getRefreshIdToken(GetRefreshIdTokenRequest getRefreshIdTokenRequest) async {
  final url = Uri.parse('$firebaseUrl/token?key=$_firebaseKey');
  final jsonRequestBody = jsonEncode(getRefreshIdTokenRequest.toJson());
  final response = await http.post(
    url,
    headers: {'Content-Type': 'application/json'},
    body: jsonRequestBody,
  );

  if (response.statusCode >= 200 && response.statusCode < 300) {
    return GetRefreshIdTokenSuccess.fromJson(jsonDecode(response.body));
  } else {
    throw WepinError(WepinErrorCode.apiRequestError, 'code: ${response.statusCode} , body: ${response.body}');
  }
}