create method

Future<TokenNewResponse> create(
  1. TokenNew tokenNew,
  2. Authentication authentication
)

Implementation

Future<TokenNewResponse> create(
    TokenNew tokenNew, Authentication authentication) async {
  http.Response response = await _httpService.post(
    '/api/v1/push.token',
    jsonEncode(tokenNew.toMap()),
    authentication,
  );

  if (response.statusCode == 200) {
    if (response.body.isNotEmpty == true) {
      return TokenNewResponse.fromMap(jsonDecode(response.body));
    } else {
      return TokenNewResponse();
    }
  }
  throw RocketChatException(response.body);
}