# Testing API Jadwal Sholat

## Setup

Database sudah ter-migrate dan ter-seed dengan data masjid yang memiliki lokasi Jakarta.

## Token untuk Testing

```
Bearer 1|VJ7FDx7z8DpkLhdSpx2wrdkslSjJDORKTt4vYZVp0802f485
```

## Test Endpoints

### 1. Get Jadwal Sholat Hari Ini

**PowerShell:**
```powershell
Invoke-WebRequest -Uri "http://127.0.0.1:8000/api/v1/masjid/1/jadwal-sholat" -Headers @{"Authorization"="Bearer 1|VJ7FDx7z8DpkLhdSpx2wrdkslSjJDORKTt4vYZVp0802f485"} | Select-Object -ExpandProperty Content
```

**Response:**
```json
{
  "type": "jadwal_sholat",
  "data": {
    "tanggal": "2026-02-07",
    "hijriah": "1447-11-07",
    "lokasi": {
      "kota": "Jakarta",
      "latitude": -6.2088,
      "longitude": 106.8456
    },
    "jadwal": {
      "imsak": "04:12",
      "subuh": "04:23",
      "syuruq": "05:38",
      "dzuhur": "11:53",
      "ashar": "15:23",
      "maghrib": "17:49",
      "isya": "19:19"
    }
  }
}
```

### 2. Get Jadwal Sholat Bulanan

**PowerShell:**
```powershell
Invoke-WebRequest -Uri "http://127.0.0.1:8000/api/v1/masjid/1/jadwal-sholat/bulanan?bulan=2&tahun=2026" -Headers @{"Authorization"="Bearer 1|VJ7FDx7z8DpkLhdSpx2wrdkslSjJDORKTt4vYZVp0802f485"} | Select-Object -ExpandProperty Content
```

**Response:**
```json
{
  "type": "jadwal_sholat_bulanan",
  "data": {
    "bulan": 2,
    "tahun": 2026,
    "nama_bulan": "Februari",
    "lokasi": {
      "kota": "Jakarta",
      "latitude": -6.2088,
      "longitude": 106.8456
    },
    "jadwal": [
      {
        "tanggal": "2026-02-01",
        "hijriah": "1447-11-01",
        "hari": "Minggu",
        "imsak": "04:12",
        "subuh": "04:23",
        "syuruq": "05:38",
        "dzuhur": "11:53",
        "ashar": "15:23",
        "maghrib": "17:49",
        "isya": "19:19"
      }
      // ... 27 hari lainnya
    ]
  }
}
```

### 3. Get Waktu Sholat Berikutnya

**PowerShell:**
```powershell
Invoke-WebRequest -Uri "http://127.0.0.1:8000/api/v1/masjid/1/jadwal-sholat/berikutnya" -Headers @{"Authorization"="Bearer 1|VJ7FDx7z8DpkLhdSpx2wrdkslSjJDORKTt4vYZVp0802f485"} | Select-Object -ExpandProperty Content
```

**Response:**
```json
{
  "type": "sholat_berikutnya",
  "data": {
    "waktu_sekarang": "2026-02-07T17:05:45+07:00",
    "sholat_berikutnya": {
      "nama": "Maghrib",
      "waktu": "17:49",
      "countdown": {
        "jam": 0,
        "menit": 43,
        "detik": 14
      }
    },
    "jadwal_hari_ini": {
      "imsak": "04:12",
      "subuh": "04:23",
      "syuruq": "05:38",
      "dzuhur": "11:53",
      "ashar": "15:23",
      "maghrib": "17:49",
      "isya": "19:19"
    }
  }
}
```

### 4. Update Lokasi Masjid

**PowerShell:**
```powershell
$body = @{
    kota = "Bandung"
    latitude = -6.9175
    longitude = 107.6191
    timezone = "Asia/Jakarta"
} | ConvertTo-Json

Invoke-WebRequest -Uri "http://127.0.0.1:8000/api/v1/masjid/1/jadwal-sholat/lokasi" -Method PUT -Headers @{"Authorization"="Bearer 1|VJ7FDx7z8DpkLhdSpx2wrdkslSjJDORKTt4vYZVp0802f485"; "Content-Type"="application/json"} -Body $body | Select-Object -ExpandProperty Content
```

**Response:**
```json
{
  "type": "update_lokasi",
  "data": {
    "message": "Lokasi masjid berhasil diperbarui",
    "lokasi": {
      "kota": "Bandung",
      "latitude": -6.9175,
      "longitude": 107.6191,
      "timezone": "Asia/Jakarta"
    }
  }
}
```

### 5. Get Pengaturan Koreksi Waktu

**PowerShell:**
```powershell
Invoke-WebRequest -Uri "http://127.0.0.1:8000/api/v1/masjid/1/jadwal-sholat/koreksi" -Headers @{"Authorization"="Bearer 1|VJ7FDx7z8DpkLhdSpx2wrdkslSjJDORKTt4vYZVp0802f485"} | Select-Object -ExpandProperty Content
```

**Response:**
```json
{
  "type": "koreksi_waktu",
  "data": {
    "imsak": 0,
    "subuh": 0,
    "syuruq": 0,
    "dzuhur": 0,
    "ashar": 0,
    "maghrib": 0,
    "isya": 0
  },
  "meta": {
    "satuan": "menit",
    "keterangan": "Nilai positif = mundur, nilai negatif = maju"
  }
}
```

### 6. Update Koreksi Waktu

**PowerShell:**
```powershell
$body = @{
    dzuhur = 2
    maghrib = 2
} | ConvertTo-Json

Invoke-WebRequest -Uri "http://127.0.0.1:8000/api/v1/masjid/1/jadwal-sholat/koreksi" -Method PUT -Headers @{"Authorization"="Bearer 1|VJ7FDx7z8DpkLhdSpx2wrdkslSjJDORKTt4vYZVp0802f485"; "Content-Type"="application/json"} -Body $body | Select-Object -ExpandProperty Content
```

**Response:**
```json
{
  "type": "update_koreksi",
  "data": {
    "message": "Koreksi waktu berhasil diperbarui",
    "koreksi": {
      "imsak": 0,
      "subuh": 0,
      "syuruq": 0,
      "dzuhur": 2,
      "ashar": 0,
      "maghrib": 2,
      "isya": 0
    }
  }
}
```

## Status Testing

✅ Get Jadwal Hari Ini - WORKING
✅ Get Jadwal Bulanan - WORKING
✅ Get Sholat Berikutnya - WORKING
✅ Update Lokasi - READY
✅ Get Koreksi - WORKING
✅ Update Koreksi - READY

## Database Tables

### masjids
- Ditambahkan kolom: kota, latitude, longitude, timezone
- Sample data: Jakarta (-6.2088, 106.8456)

### jadwal_sholat_koreksis
- Menyimpan koreksi waktu per masjid
- Range: -30 sampai +30 menit
- Default: semua 0

## Notes

1. **Perhitungan**: Menggunakan formula sederhana (untuk production gunakan library seperti `adhan`)
2. **Timezone**: Hardcoded ke WIB (UTC+7)
3. **Hijriah**: Konversi approximate (untuk production gunakan library proper)
4. **Koreksi**: Diterapkan setelah perhitungan base time
5. **Format Waktu**: HH:mm (24 jam)

## Improvement untuk Production

1. Install library `islamic/prayer-times` atau `adhan` untuk perhitungan akurat
2. Implementasi proper Hijri calendar conversion
3. Support multiple timezone
4. Caching untuk performa
5. Validasi koordinat dengan Google Maps API
6. Notifikasi push untuk waktu sholat
