createTenant method

Future<Map<String, dynamic>?> createTenant({
  1. required String product,
  2. required String username,
  3. required String email,
  4. required String password,
  5. required String first_name,
  6. required String last_name,
  7. required String name,
})

Implementation

Future<Map<String, dynamic>?> createTenant({
  required String product,
  required String username,
  required String email,
  required String password,
  required String first_name,
  required String last_name,
  required String name,
}) async {
  var body = {
    "product": product,
    "username": username,
    "email": email,
    "password": password,
    "first_name": first_name,
    "last_name": last_name,
    "name": name,
  };

  String formData = body.keys
      .map((key) =>
          "${Uri.encodeComponent(key)}=${Uri.encodeComponent(body[key].toString())}")
      .join("&");
  final response = await http.post(
    Uri.parse('$webbaseUrl/api/ibl/v1/tenant/post/'),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: formData,
  );

  var data = json.decode(response.body);

  return data; // Returns the API response
}