Skip to main content

Create User

Create User Example

For creating a new user you need to use the createUser and provide a data object, Here is the User class:

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.maritalStatus,
this.createdAt,
this.updatedAt
});
}

Check the example for create user:

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

ApiService apiService = ApiService();
var response = await apiService.createUser(User(name: user['name'] , nationalityNumber: user['nationality_number'] ));

Consider that not all User data are required

Responses

Status 201

Success

{
"id": '999999999',
"name": "Altibbi User",
"email": "[email protected]",
"date_of_birth": "2000-01-30",
"createdAt": "2024-01-30",
"updatedAt": "2024-01-30",
"gender": "male",
"insurance_id": "123123123",
"policy_number": "111111111",
"height": 180,
"weight": 90,
"blood_type": "A+",
"smoker": "yes",
"alcoholic": "no",
"marital_status": "single"
}

Status 401

UnauthorizedHttpException represents an Unauthorized HTTP exception with status code 401.

{
"name": "Unauthorized",
"message": "Your request was made with invalid credentials",
"code": "0",
"status": "401",
"type": "yii\\\\web\\\\UnauthorizedHttpException"
}

Status 422

Data Validation Failed.

[
{
"field": "string",
"message": "string"
}
]