rd-android-app/lib/controller/shiptoandbillto_service.dart
saritabirare 077aa1e5d5 1)shipto and bill to Api integration done
2)Opening Inventory api integration done
2024-10-30 13:15:56 +05:30

41 lines
1.3 KiB
Dart

import '../models/shippingandBilling_address_model.dart';
import '../utils/api_urls.dart';
import '../utils/common_api_service.dart';
class ShiptoandbilltoService {
Future<List<UserShippingAddress>?> fetchshiptobillAddress(String token) async {
try {
String url = ApiUrls
.ShiptoandBilltoAddressUrl; // Base URL to fetch product manuals
final response = await commonApiService<List<UserShippingAddress>>(
method: "GET",
url: url,
additionalHeaders: { // Pass the token here
'Authorization': 'Bearer $token',
},
fromJson: (json) {
if (json['UserShippingAddress'] != null) {
// If the productManuals key is present, map the response to a list of ProductManualModel objects
final List<
UserShippingAddress> productManuals = (json['UserShippingAddress'] as List)
.map((manualJson) => UserShippingAddress.fromJson(manualJson))
.toList();
return productManuals; // Return the list of product manuals
} else {
return [];
}
},
);
return response;
} catch (e) {
print("fkfgghgh ,${e.toString()}");
//print(e.toString());
return null;
}
}
}