You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
import 'package:diplomaticquarterapp/config/config.dart';
|
|
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
|
import 'package:diplomaticquarterapp/models/pharmacy/brandModel.dart';
|
|
import 'package:diplomaticquarterapp/models/pharmacy/topBrandsModel.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
class BrandsService extends BaseService {
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
bool isLogin = false;
|
|
|
|
List<Brand> _brandsList = List();
|
|
List<Brand> get brandsList => _brandsList;
|
|
|
|
List<TopBrand> _topBrandsList = List();
|
|
List<TopBrand> get topBrandsList => _topBrandsList;
|
|
|
|
Future getBrands() async {
|
|
hasError = false;
|
|
await baseAppClient.getPharmacy(GET_BRANDS,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_brandsList.clear();
|
|
response['manufacturer'].forEach((item) {
|
|
_brandsList.add(Brand.fromJson(item));
|
|
});
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
});
|
|
}
|
|
|
|
Future getTopBrands() async {
|
|
hasError = false;
|
|
await baseAppClient.getPharmacy(GET_TOP_BRANDS,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_topBrandsList.clear();
|
|
response['manufacturer'].forEach((item) {
|
|
_topBrandsList.add(TopBrand.fromJson(item));
|
|
});
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
});
|
|
}
|
|
}
|