setAutoRecharge method

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

Implementation

Future<void> setAutoRecharge({
  required String projectId,
  required bool enabled,
  required double amount,
  required double threshold,
  double? monthlyBudget,
}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/recharge');
  final resp = await httpClient.post(
    uri,
    body: jsonEncode({"enabled": enabled, "amount": amount, "threshold": threshold, "monthly_budget": monthlyBudget}),
  );

  if (resp.statusCode != 200) {
    throw Exception("Unable to update autorecharge");
  }
}