getAuction method
Implementation
Future<ApiResponse<Auction>> getAuction(int id) async {
final Map<String, dynamic> queryParams = {
"expand": "order,order.vehicle,order.featuredImage"
};
try {
final response = await call(endpoint: 'auctions/$id', method: Method.GET, body: queryParams);
final bodyJson = jsonDecode(response.body);
if (response.statusCode == 200) {
return ApiResponse.fromJson(
bodyJson,
(data) => Auction.fromJson(data),
);
} else {
return ApiResponse(
success: false,
data: null,
message: bodyJson['message'] ?? 'Failed to fetch auction details',
);
}
} catch (e) {
return ApiResponse(
success: false,
data: null,
message: 'Error fetching auction: $e',
);
}
}