Skip to main content

Create User

Create User Example​

To create a new user, use the createUser method. The SDK uses the following User model:

class User {
int? id;
String? name;
String? phoneNumber;
String? email;
String? dateOfBirth;
String? gender;
String? insuranceId;
String? policyNumber;
String? nationalityNumber;
int? height;
int? weight;
String? bloodType;
String? smoker;
String? alcoholic;
String? relationType;
String? maritalStatus;
String? createdAt;
String? updatedAt;

User({
this.id,
this.name,
this.phoneNumber,
this.email,
this.dateOfBirth,
this.gender,
this.insuranceId,
this.policyNumber,
this.nationalityNumber,
this.height,
this.weight,
this.bloodType,
this.smoker,
this.alcoholic,
this.relationType,
this.maritalStatus,
this.createdAt,
this.updatedAt
});
}

Usage Example:​

import 'package:altibbi/service/api_service.dart';

ApiService apiService = ApiService();

void createNewUser() async {
try {
User newUser = User(
name: \"John Doe\",
email: \"[email protected]\",
gender: \"male\",
dateOfBirth: \"1990-01-01\",
relationType: \"personal\", // Optional relation type
);

User createdUser = await apiService.createUser(newUser);
print(\"User created with ID: ${createdUser.id}\");
} catch (e) {
print(\"Error creating user: $e\");
}
}

Responses​

Status 201 (Created)​

Returns the newly created User object including its unique ID.

Status 401 (Unauthorized)​

Returned if the partner token is invalid.

Status 422 (Validation Failed)​

Returned if required fields are missing or data is invalid.