# Company-Side API Reference

API endpoints for the company/employer side of the job portal app.

---

## Authentication

### Login
**POST** `/api/login`
- Body: `{ "email", "password", "user_type": "company" }`
- Returns: `{ "success", "token", "user": { "id", "name", "email", "user_type": "company" } }`

### Register
**POST** `/api/company-register`
- Body: `{ "name", "email", "password", "password_confirmation", "terms_of_use" }`
- Returns: `{ "token", "name" }`

### Alternative Login (legacy)
**POST** `/api/company-login`
- Body: `{ "email", "password" }`
- Returns: `{ "token", "name" }`

### Forgot Password
- **POST** `/api/company-forgot-password` – Body: `{ "email" }` – Sends 6-digit code
- **POST** `/api/company-verify-reset-code` – Body: `{ "email", "reset_code" }`
- **POST** `/api/company-reset-password` – Body: `{ "email", "reset_code", "password", "password_confirmation" }`

**All company endpoints below require:** `Authorization: Bearer {token}`

---

## 1. Dashboard

**GET** `/api/company-home`

Returns: stats, suggested candidates, job package summary, CV package summary.

```json
{
  "stats": { "open_jobs", "followers", "messages" },
  "suggested_candidates": [...],
  "job_package": { "id", "title", "jobs_quota", "availed_jobs_quota", "remaining_jobs", "is_active", ... },
  "cv_package": { "id", "title", "cvs_quota", "availed_cvs_quota", "remaining_cvs", "is_active", ... },
  "is_active": true
}
```

---

## 2. Company Edit Profile

- **GET** `/api/company-profile` – Get profile + countries, industries, ownershipTypes
- **PUT** `/api/update-company-profile` – Update profile (multipart/form-data for logo)

---

## 3. CV Search Packages

**GET** `/api/company-packages`

Returns: `{ "packages": [...], "success_package": {...} }`

---

## 4. Job Packages

**GET** `/api/company-job-packages`

Returns: `{ "packages": [...], "current_package", "jobs_quota", "availed_jobs_quota", "package_end_date" }`

---

## 5. Payment History

- **GET** `/api/company/payment-history` – List with pagination
- **GET** `/api/company/payment-history/stats` – Summary stats
- **GET** `/api/company/payment-history/order/{orderId}` – Order details
- **GET** `/api/company/payment-history/recent` – Recent transactions
- **GET** `/api/company/payment-history/methods` – Payment methods used

---

## 6. Manage Jobs

**GET** `/api/posted-jobs`

Returns jobs posted by the company with metadata.

---

## 7. Post New Job

- **GET** `/api/post-job` – Get master data (countries, job types, skills, etc.)
- **POST** `/api/store-front-job` – Create job
- **GET** `/api/edit-front-job/{id}` – Get job edit form data
- **PUT** `/api/update-front-job/{id}` – Update job
- **DELETE** `/api/delete-front-job` – Body: `{ "id" }` – Delete job

---

## 8. Unlocked Users

- **GET** `/api/unloced-seekers` – List unlocked users
- **GET** `/api/unlock/{user_id}` – Unlock a user (CV view)

---

## 9. Messages

- **GET** `/api/company-messages` – List conversations (by seeker)
- **GET** `/api/company-messages/seeker/{seeker_id}` – Messages with a seeker
- **POST** `/api/company-submit-message` – Body: `{ "message", "seeker_id" }` – Send message
- **GET** `/api/company-message-detail/{id}` – Single message detail

---

## 10. Company Followers

**GET** `/api/company-followers`

Returns: `{ "company", "users" }`

---

## Additional (applicants, favourites, hiring)

- **GET** `/api/list-applied-users/{job_id}` – Applicants for job
- **GET** `/api/list-hired-users/{job_id}` – Hired applicants
- **GET** `/api/list-favourite-applied-users/{job_id}` – Favourite applicants
- **GET** `/api/add-to-favourite-applicant/{application_id}/{user_id}/{job_id}/{company_id}`
- **GET** `/api/remove-from-favourite-applicant/{application_id}/{user_id}/{job_id}/{company_id}`
- **GET** `/api/hire-from-favourite-applicant/{application_id}/{user_id}/{job_id}/{company_id}`
- **GET** `/api/removed-from-hired-applicant/{application_id}/{user_id}/{job_id}/{company_id}`
- **GET** `/api/applicant-profile/{application_id}` – Applicant details
- **GET** `/api/reject-applicant-profile/{application_id}` – Reject applicant
- **GET** `/api/user-profile/{id}` – User profile

---

## Migration

Run this before using company forgot password:

```bash
php artisan migrate
```

This adds `password_reset_code` and `password_reset_code_expires_at` to the `companies` table.
