getSpace method
Returns the space with the given id.
Implementation
Future<ClearResponse<Space?, ClearErrorResponse?>> getSpace(
final String spaceId) async {
final uri = Uri.parse('${Constants.baseUrl}spaces/$spaceId');
final res = await _client.get(
uri,
headers: <String, String>{
...Constants.getAuthHeader(token),
},
);
try {
final state = Constants.getResultState(res.statusCode);
if (state == ReturnState.success) {
final doc = jsonDecode(res.body);
final space = Space.fromJson(doc);
return ClearResponse(data: space, error: null);
} else if (state == ReturnState.success) {
return ClearResponse(
data: null,
error: ClearErrorResponse(
code: res.statusCode,
message: res.body,
),
);
} else {
return ClearResponse(
data: null,
error: ClearErrorResponse(
code: res.statusCode,
message: res.body,
),
);
}
} catch (e) {
Logger.printError('Error in getSpace() method, error: $e');
return ClearResponse(
data: null,
error: ClearErrorResponse(
code: res.statusCode,
message: e.toString(),
),
);
}
}