get_attributes method
dynamic
get_attributes(
{ - String? context,
- int? id,
})
Implementation
get_attributes({String? context, int? id}) async {
String request_api = 'products/attributes';
if (id != null) {
request_api = 'products/attributes/$id';
}
Response res = await ApiServices()
.getRequest(request_api, baseUrl, consumerKey, consumerSecret);
// print(res);
var decode_data = json.decode(res.body);
// print(decode_data);
if (id != null) {
return ProductAttributeModel.fromJson(decode_data);
} else {
List<ProductAttributeModel> attribut_list = [];
for (var i = 0; i < decode_data.length; i++) {
ProductAttributeModel attribut_data =
ProductAttributeModel.fromJson(decode_data[i]);
attribut_list.add(attribut_data);
}
return attribut_list;
}
}