bid method
Implementation
Future<ApiResponse<Bid>> bid(int id, int amount) async {
final Map<String, dynamic> body = {
"total_amount": amount.toString(),
"auction_id": id
};
try {
final response = await call(endpoint: 'bids', method: Method.POST, body: body);
final bodyJson = jsonDecode(response.body);
if (response.statusCode == 201) {
return ApiResponse.fromJson(
bodyJson,
(data) => Bid.fromJson(data),
);
} else {
return ApiResponse(
success: false,
data: null,
message: bodyJson['message'] ?? 'Bid request failed',
);
}
} catch (e) {
return ApiResponse(
success: false,
data: null,
message: 'Error placing bid: $e',
);
}
}