# Daftar Lengkap Endpoint API

Base URL: `http://127.0.0.1:8000/api`

---

## 🔓 Public Endpoints (Tidak Perlu Token)

### Authentication

| Method | Endpoint | Deskripsi |
|--------|----------|-----------|
| POST | `/login` | Login dan dapatkan token |
| POST | `/v1/auth/login` | Login API v1 (Courier Tracking) |
| POST | `/v1/auth/generate-test-token` | Generate test token (development only) |

---

## 🔐 Protected Endpoints (Perlu Bearer Token)

### Authentication & User

| Method | Endpoint | Deskripsi |
|--------|----------|-----------|
| POST | `/logout` | Logout dan hapus token |
| GET | `/user` | Get user yang sedang login |
| POST | `/v1/auth/logout` | Logout API v1 |
| GET | `/v1/auth/me` | Get profile user API v1 |

---

## 📝 Blog Management (Permission Required)

| Method | Endpoint | Permission | Deskripsi |
|--------|----------|------------|-----------|
| GET | `/blogs` | view blogs | List semua blog |
| GET | `/blogs/{id}` | view blogs | Detail blog |
| POST | `/blogs` | create blogs | Buat blog baru |
| PUT | `/blogs/{id}` | edit blogs | Update blog |
| DELETE | `/blogs/{id}` | delete blogs | Hapus blog |

---

## 📁 Project Management (Permission Required)

| Method | Endpoint | Permission | Deskripsi |
|--------|----------|------------|-----------|
| GET | `/projects` | view projects | List semua project |
| GET | `/projects/{id}` | view projects | Detail project |
| POST | `/projects` | create projects | Buat project baru |
| PUT | `/projects/{id}` | edit projects | Update project |
| DELETE | `/projects/{id}` | delete projects | Hapus project |

---

## 👥 User Management

| Method | Endpoint | Deskripsi |
|--------|----------|-----------|
| GET | `/v1/operators` | List operators/drivers |
| GET | `/v1/users` | List semua users |

---

## 🔑 Role & Permission Management (SuperAdmin Only)

### Roles

| Method | Endpoint | Deskripsi |
|--------|----------|-----------|
| GET | `/v1/roles` | List semua roles |
| GET | `/v1/roles/{id}` | Detail role |
| POST | `/v1/roles` | Buat role baru |
| PUT | `/v1/roles/{id}` | Update role |
| DELETE | `/v1/roles/{id}` | Hapus role |
| POST | `/v1/roles/{id}/assign-permissions` | Assign permissions ke role |
| POST | `/v1/roles/{id}/remove-permissions` | Remove permissions dari role |

### Permissions

| Method | Endpoint | Deskripsi |
|--------|----------|-----------|
| GET | `/v1/permissions` | List semua permissions |
| GET | `/v1/permissions/{id}` | Detail permission |
| POST | `/v1/permissions` | Buat permission baru |
| PUT | `/v1/permissions/{id}` | Update permission |
| DELETE | `/v1/permissions/{id}` | Hapus permission |
| GET | `/v1/permissions-grouped` | List permissions grouped by category |

---

## 💰 Laporan Keuangan Masjid

Base: `/v1/masjid/{masjid_id}/laporan`

| Method | Endpoint | Deskripsi |
|--------|----------|-----------|
| GET | `/ringkasan` | Ringkasan keuangan per periode |
| GET | `/transaksi` | List transaksi (dengan pagination & filter) |
| GET | `/transaksi/{id}` | Detail transaksi |
| GET | `/rekap-bulanan` | Rekap bulanan per tahun |
| GET | `/saldo` | Saldo terkini (kas + bank) |
| GET | `/kategori` | List kategori dengan statistik |
| GET | `/export` | Export laporan (PDF/Excel) |

**Query Parameters:**

**Ringkasan:**
- `periode` (optional): YYYY-MM (default: bulan ini)

**Transaksi:**
- `page` (optional): default 1
- `per_page` (optional): 1-100 (default: 20)
- `tanggal_mulai` (optional): YYYY-MM-DD
- `tanggal_selesai` (optional): YYYY-MM-DD
- `jenis` (optional): pemasukan|pengeluaran
- `kategori_id` (optional): filter by kategori
- `sort_by` (optional): tanggal|nominal (default: tanggal)
- `sort_order` (optional): asc|desc (default: desc)

**Rekap Bulanan:**
- `tahun` (optional): YYYY (default: tahun ini)

**Kategori:**
- `jenis` (optional): pemasukan|pengeluaran
- `sort_by` (optional): nama|total_nominal (default: nama)
- `sort_order` (optional): asc|desc (default: asc)

**Export:**
- `format` (required): pdf|excel
- `tanggal_mulai` (required): YYYY-MM-DD
- `tanggal_selesai` (required): YYYY-MM-DD
- `jenis` (optional): pemasukan|pengeluaran

---

## 🕌 Jadwal Sholat Masjid

Base: `/v1/masjid/{masjid_id}/jadwal-sholat`

| Method | Endpoint | Deskripsi |
|--------|----------|-----------|
| GET | `/` | Jadwal sholat hari ini |
| GET | `/bulanan` | Jadwal sholat bulanan |
| GET | `/berikutnya` | Waktu sholat berikutnya + countdown |
| PUT | `/lokasi` | Update koordinat lokasi masjid |
| GET | `/koreksi` | Get pengaturan koreksi waktu |
| PUT | `/koreksi` | Update koreksi waktu |

**Query Parameters:**

**Jadwal Hari Ini:**
- `tanggal` (optional): YYYY-MM-DD (default: hari ini)

**Jadwal Bulanan:**
- `bulan` (optional): 1-12 (default: bulan ini)
- `tahun` (optional): YYYY (default: tahun ini)

**Request Body - Update Lokasi:**
```json
{
  "kota": "Jakarta",
  "latitude": -6.2088,
  "longitude": 106.8456,
  "timezone": "Asia/Jakarta"
}
```

**Request Body - Update Koreksi:**
```json
{
  "imsak": 0,
  "subuh": 0,
  "syuruq": 0,
  "dzuhur": 2,
  "ashar": 0,
  "maghrib": 2,
  "isya": 0
}
```

---

## 📊 Summary Endpoint

### Total Endpoints: **47 endpoints**

**Breakdown:**
- 🔓 Public: 3 endpoints
- 🔐 Auth & User: 4 endpoints
- 📝 Blog: 5 endpoints
- 📁 Project: 5 endpoints
- 👥 User Management: 2 endpoints
- 🔑 Role & Permission: 13 endpoints
- 💰 Laporan Keuangan: 7 endpoints
- 🕌 Jadwal Sholat: 6 endpoints
- ⚡ Legacy/Other: 2 endpoints

---

## 🔑 Authentication

Semua protected endpoint memerlukan Bearer Token di header:

```
Authorization: Bearer {your_token_here}
```

**Generate Token:**
```bash
php artisan api:generate-token admin@masjid.com
```

---

## 📖 Dokumentasi Detail

- **Laporan Keuangan**: Lihat `API_LAPORAN_KEUANGAN.md`
- **Jadwal Sholat**: Lihat `API_JADWAL_SHOLAT.md`
- **Testing Laporan**: Lihat `TESTING_LAPORAN_KEUANGAN.md`
- **Testing Jadwal**: Lihat `TESTING_JADWAL_SHOLAT.md`

---

## 🎯 Quick Start

### 1. Login
```bash
POST /api/v1/auth/login
{
  "email": "admin@masjid.com",
  "password": "password"
}
```

### 2. Get Jadwal Sholat
```bash
GET /api/v1/masjid/1/jadwal-sholat
Authorization: Bearer {token}
```

### 3. Get Laporan Keuangan
```bash
GET /api/v1/masjid/1/laporan/ringkasan
Authorization: Bearer {token}
```

---

## 🚀 Status

✅ **Production Ready:**
- Authentication & Authorization
- Laporan Keuangan (7 endpoints)
- Jadwal Sholat (6 endpoints)

⚠️ **Legacy (Perlu Review):**
- Blog Management
- Project Management

---

## 📝 Notes

1. Semua endpoint menggunakan JSON format
2. Timezone default: Asia/Jakarta (WIB)
3. Date format: YYYY-MM-DD
4. Time format: HH:mm (24 jam)
5. Pagination default: 20 items per page
6. Error response format konsisten di semua endpoint
