listAllDiscounts method
Implementation
Future<Map<String, dynamic>> listAllDiscounts({int? storeId}) async {
if (apiKey.isEmpty) {
return {'error': 'API key is empty'};
}
Options dioOptions = Options(
headers: {
"Authorization": "Bearer $apiKey",
"Accept": "application/vnd.api+json",
"Content-Type": "application/vnd.api+json",
},
);
String url = "https://api.lemonsqueezy.com/v1/discounts";
if (storeId != null) {
url += "?filter[store_id]=$storeId";
}
try {
Response response = await dio.get(
url,
options: dioOptions,
);
return response.data;
} catch (e) {
return {'error': e.toString()};
}
}