setAutoRecharge method

Future<void> setAutoRecharge({
  1. required String projectId,
  2. required bool enabled,
  3. required double amount,
  4. required double threshold,
})

Implementation

Future<void> setAutoRecharge({
  required String projectId,
  required bool enabled,
  required double amount,
  required double threshold,
}) async {
  final uri = Uri.parse('$baseUrl/accounts/projects/$projectId/recharge');
  final resp = await http.post(
    uri,
    headers: _getHeaders(),
    body: jsonEncode({"enabled": enabled, "amount": amount, "threshold": threshold}),
  );
  if (resp.statusCode != 200) {
    throw Exception("Unable to update autorecharge");
  }
}