getVehicles static method
Returns a set of Vehicles
Implementation
static Future<Vehicles> getVehicles({int page, String url}) {
http.Client httpClient = http.Client();
String urlRequest = (url == null
? _baseUrl +
_resourceVehicles +
(page == null ? "" : page.toString() + "/")
: url);
return httpClient.get(urlRequest).then((response) {
String responseBody = utf8.decode(response.bodyBytes);
if (response.statusCode == 200) {
var map = json.decode(responseBody);
return Vehicles(map);
}
throw ("code: ${response.statusCode}, message: $responseBody");
});
}