getCurrentUser method

Future<GetCurrentUserResponse> getCurrentUser(
  1. GetCurrentUserRequest getCurrentUserRequest
)

Implementation

Future<GetCurrentUserResponse> getCurrentUser(GetCurrentUserRequest getCurrentUserRequest) async {
  final url = Uri.parse('$firebaseUrl/accounts:lookup?key=$_firebaseKey');
  final jsonRequestBody = jsonEncode(getCurrentUserRequest.toJson());
  final response = await http.post(
    url,
    headers: {'Content-Type': 'application/json'},
    body: jsonRequestBody,
  );

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