Skip to main content

Create User

createUser

For creating a new user you need to use createUser and provide a data object of UserType.

Parameters

  • user: (UserType) - The user data object.

Returns

  • Promise<ResponseType<UserType>>: A promise that resolves with the created UserType object.

Example

import { createUser } from 'react-native-altibbi';

const data: UserType = {
name: 'Altibbi User',
email: '[email protected]',
phone_number: '0791234567',
date_of_birth: '2000-01-30',
gender: 'male', // Accepted Values: 'male' | 'female'
insurance_id: '123123123',
policy_number: '111111111',
nationality_number: '9999999999',
height: '180',
weight: '90',
blood_type: 'A+', // Accepted Values: 'A+' | 'B+' | 'AB+' | 'O+' | 'A-' | 'B-' | 'AB-' | 'O-'
smoker: 'yes', // Accepted Values: 'yes' | 'no'
alcoholic: 'no', // Accepted Values: 'yes' | 'no'
marital_status: 'single', // Accepted Values: 'single' | 'married' | 'divorced' | 'widow'
relation_type: 'brother', // Accepted Values: 'personal' | 'father' | 'mother' | 'sister' | 'brother' | 'child' | 'husband' | 'wife' | 'other'
};

const response = await createUser(data);

Consider that not all UserType fields are required.

Responses

Status 201

Success

{
"id": 999999999,
"name": "Altibbi User",
"email": "[email protected]",
"phone_number": "0791234567",
"date_of_birth": "2000-01-30",
"gender": "male",
"insurance_id": "123123123",
"policy_number": "111111111",
"nationality_number": "9999999999",
"height": "180",
"weight": "90",
"blood_type": "A+",
"smoker": "yes",
"alcoholic": "no",
"marital_status": "single",
"relation_type": "brother",
"created_at": "2024-01-01 00:00:00",
"updated_at": "2024-01-01 00:00:00"
}

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"
}
]