# Registration API Documentation

This document describes the registration API endpoints for the application.

## Base URL
```
http://localhost:4200/
```

## Endpoints

### 1. Register New User/Organization
**POST** `/usermanagement/register`

Register a new user and organization in the system.

#### Request Body
```json
{
  "organization": {
    "country_id": 1,
    "registration_type": "Company",
    "commercial_reg_no": "CR123456789",
    "establishment_date": "2020-01-15",
    "name": "Sample Company Ltd",
    "incorporation_style": "LLC",
    "industry_sector": "Technology",
    "reuse_supplier_code": 0
  },
  "contact": {
    "first_name": "John",
    "middle_name": "Michael",
    "last_name": "Doe",
    "email": "john.doe@example.com",
    "mobile_number": "1234567890",
    "country_code": "+1",
    "same_whatsapp": true,
    "whatsapp_cc": "+1",
    "whatsapp_number": "1234567890"
  }
}
```

#### Response
```json
{
  "status": true,
  "message": "Registration successful",
  "data": {
    "registration_number": "0001",
    "supplier_code": "US000001",
    "user_id": 123,
    "company_id": 456,
    "login_id": "john.doe",
    "email": "john.doe@example.com"
  }
}
```

### 2. Get Countries List
**GET** `/usermanagement/get-countries`

Retrieve list of active countries for the registration form.

#### Response
```json
{
  "status": true,
  "message": "Countries retrieved successfully",
  "data": [
    {
      "countrymst_pk": 1,
      "cym_countryname_en": "United States",
      "cym_countrydialcode": "+1"
    },
    {
      "countrymst_pk": 2,
      "cym_countryname_en": "United Kingdom",
      "cym_countrydialcode": "+44"
    }
  ]
}
```

### 3. Get Sectors List
**GET** `/usermanagement/get-sectors`

Retrieve list of industry sectors.

#### Response
```json
{
  "status": true,
  "message": "Sectors retrieved successfully",
  "data": [
    {
      "sectormst_pk": 1,
      "secm_sectorname": "Technology"
    },
    {
      "sectormst_pk": 2,
      "secm_sectorname": "Healthcare"
    }
  ]
}
```

### 4. Get Designations List
**GET** `/usermanagement/get-designations`

Retrieve list of job designations.

#### Response
```json
{
  "status": true,
  "message": "Designations retrieved successfully",
  "data": [
    {
      "designationmst_pk": 1,
      "dsg_designationname": "CEO"
    },
    {
      "designationmst_pk": 2,
      "dsg_designationname": "Manager"
    }
  ]
}
```

### 5. Send Email OTP
**POST** `/usermanagement/send-email-otp`

Send OTP to email for verification.

#### Request Body
```json
{
  "email": "john.doe@example.com"
}
```

#### Response
```json
{
  "status": true,
  "message": "OTP sent successfully to john.doe@example.com",
  "otp": "123456"
}
```

### 6. Verify Email
**POST** `/usermanagement/verify-email`

Verify email address using OTP.

#### Request Body
```json
{
  "email": "john.doe@example.com",
  "verification_code": "123456"
}
```

#### Response
```json
{
  "status": true,
  "message": "Email verified successfully"
}
```

## Error Responses

All endpoints return error responses in the following format:

```json
{
  "status": false,
  "message": "Error description",
  "errors": ["List of validation errors"]
}
```

## Required Fields

### Organization Information
- `country_id`: Country selection
- `registration_type`: Type of registration
- `commercial_reg_no`: Commercial registration number
- `establishment_date`: Date of establishment
- `name`: Organization name
- `incorporation_style`: Style of incorporation
- `industry_sector`: Industry/sector

### Contact Person Information
- `first_name`: First name
- `last_name`: Last name
- `email`: Email address
- `mobile_number`: Mobile number
- `country_code`: Country code for mobile

## Notes

1. The API uses JSON format for both requests and responses
2. CSRF validation is disabled for API endpoints
3. All datetime fields should be in 'Y-m-d H:i:s' format
4. Email verification is required after registration
5. Supplier codes are auto-generated based on country and sequence
6. Registration numbers are auto-generated sequentially

## Testing

You can test the API using tools like Postman or curl:

```bash
# Register new user
curl -X POST http://localhost:4200/usermanagement/register \
  -H "Content-Type: application/json" \
  -d '{
    "organization": {
      "country_id": 1,
      "registration_type": "Company",
      "commercial_reg_no": "CR123456789",
      "establishment_date": "2020-01-15",
      "name": "Sample Company Ltd",
      "incorporation_style": "LLC",
      "industry_sector": "Technology"
    },
    "contact": {
      "first_name": "John",
      "last_name": "Doe",
      "email": "john.doe@example.com",
      "mobile_number": "1234567890",
      "country_code": "+1"
    }
  }'

# Get countries
curl -X GET http://localhost:4200/usermanagement/get-countries
```