auction 0.1.1
auction: ^0.1.1 copied to clipboard
auction sdk
API Service Library for Dart #
Initialization #
Before making API calls, initialize MorniService with your backend URL and authentication token:
MorniService.init(baseUrl, token, language);
Usage #
Making API Calls #
Use the ApiService class to interact with the backend:
Get User Information
final apiService = ApiService();
final response = await apiService.getUser();
if (response.success) {
print("User: \${response.data}");
} else {
print("Error: \${response.message}");
}
Placing a Bid
final response = await apiService.bid(auctionId, bidAmount);
if (response.success) {
print("Bid placed successfully");
} else {
print("Error: \${response.message}");
}
Fetching Auctions
final response = await apiService.getAuctions(AuctionType.activeAuctions, page, perPage);
if (response.success) {
print("Auctions: \${response.data}");
} else {
print("Error: \${response.message}");
}
Fetching Auction Details
final response = await apiService.getAuction(auctionId);
if (response.success) {
print("Auction Details: \${response.data}");
} else {
print("Error: \${response.message}");
}
Processing Payment
File receipt = File("/path/to/receipt.jpg");
final response = await apiService.pay(auctionId, amount, receipt);
if (response.success) {
print("Payment successful");
} else {
print("Error: \${response.message}");
}
Requesting Towing
final towingParam = TowingParam(/* set parameters */);
final response = await apiService.requestTowing(towingParam);
if (response.success) {
print("Towing request successful");
} else {
print("Error: \${response.message}");
}
Updating User Information
File? licenseImage = File("/path/to/license.jpg");
File? nationalIdImage = File("/path/to/national_id.jpg");
final response = await apiService.updateUser(userId, licenseImage, nationalIdImage);
if (response.success) {
print("User updated successfully");
} else {
print("Error: \${response.message}");
}
Error Handling #
Each API call returns an ApiResponse<T> object containing:
success(bool): Indicates if the request was successfuldata(T?): The response data if successfulmessage(String): Error message if the request fails