---
# System prepended metadata

title: Kampung Kita API Spec

---

# Kampung Kita API Spec

## 1. ✅ Auth Process

### 1.0 ✅ Registration
Perform checking on user registration info and request code. Request hash is sha256(EMEL+KATA_LALUAN+APP_SECRET).

App Secret = 18171e-40d6a4-5353ad

```
POST /api/auth/register
```
Request body:
```
{
    "nama_penuh": "Shafiq Rizwan bin Shaukat",
    "no_ic": "888888-88-8888",
    "no_tel": "0124205391",
    "emel": "shafiq.rizwan@gmail.com",
    "alamat1": "39 Jalan Eco Majestic",
    "alamat2": "Eco Majestic",
    "poskod": "43500",
    "negeri": "Selangor",
    "kata_laluan": "abcd123@!",
    "hash": "c22b6ad706c66f6d0dfe7af3d9dd2816"
}
```
Success Response:
```
{
    "status": "OK",
    "_token": "xxxxxxxxxxxxxxxxx"
}
```
Error Response:
```
{
    "code"  : 400,
    "status": "Error",
    "error": "Emel telah didaftarkan"
}
```


### 1.1 ✅ Verify Code

Perform code verification input by user

```
POST /api/auth/verify_code
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Request Body:
```
{
    "code": "120852"
}
```
Success Response:
```
{
    "status": "OK"
}
```
Error Response:
```
{
    "code"  : 400,
    "status": "Error",
    "error": "Kod tidak tepat"
}
```

### 1.2 ✅ Resent Verify Code

Perform code verification input by user

```
GET /api/auth/resent_verify_code
Authorization: Bearer xxxxxxxxxxxxxxxxx
```

Success Response:
```
{
    "status": "OK"
}
```
Error Response:
```
{
    "code"  : 400,
    "status": "Error",
    "error": "Kod pengesahan tidak berjaya untuk menghantar."
}
```

### 1.3 ✅ Login 

Perform user login

Note: 
 - Request hash is md5(EMEL+KATA_LALUAN+APP_SECRET).
 - App Secret = 18171e-40d6a4-5353ad

```
POST /api/auth/login
```
Request Body:
```
{
    "username": "0123456659", 
    "kata_laluan": "abcd123@!",
    "request_hash": "c22b6ad706c66f6d0dfe7af3d9dd2816"
}
```
Success Response:
```
{
    "status": "OK",
    "bearer_token": "xxxxxxxxxxxxxxxxxxxx"
}
```
Error Response:
```
{
    "code"  : 400,
    "status": "Error",
    "error": "Emel atau kata laluan tidak tepat"
}
```

### 1.4 ✅Update Push Notification Token

Send device push ID to server to store with user token.
```
POST /api/updatePushID
Authorization: Bearer xxxxxxxxxxxxxxxx
```
Request Body:
```
{
    "pushID": "XXXXXXXXXXXXXXXXXXX"
}
```
Success Response:
```
{
    "status": "OK"
}
```

### 1.5 ✅ Check User Session

Perform user session check to see if active.

```
GET /api/auth/validate
Authorization: Bearer xxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK"
    "user": {
        "nama_penuh": "Shafiq Rizwan bin Shaukat",
        "emel": "shafiq.rizwan@gmail.com",
        ...
    }
}
```
Error Response:
```
{
    "code" : 419,
    "status": "Error",
    "error": "Token invalid or your session has been expired.",
    "terminate_session": true
}
```

### 1.6 ✅ Request TAC for Password Reset
Perform email TAC request to complete password reset. Request hash is sha256(EMEL+APP_SECRET).

```
POST /api/auth/request_tac
```
Request Body:
```
{
    "emel": "shafiq.rizwan@gmail.com",
    "hash": "c22b6ad706c66f6d0dfe7af3d9dd2816"
}
```
Success Response:
```
{
    "status": "OK"
}
```
Error Response:
```
{
    "status": "Error",
    "code": "400",
    "error": "Tiada rekod emel"
}
```
### 1.7 ✅ Password Reset
Perform password . Request hash is sha256(EMEL+KATA_LALUAN+APP_SECRET).

```
POST /api/auth/reset_password
```
Request Body:
```
{
    "emel": "shafiq.rizwan@gmail.com",
    "kata_laluan": "m7Pas5w0r6!",
    "tac": "249201",
    "hash": "c22b6ad706c66f6d0dfe7af3d9dd2816"
}
```
Success Response:
```
{
    "status": "OK"
}
```
Error Response:
```
{
    "status": "Error",
    "code": "",
    "error": "TAC tidak tepat"
}
```

### 1.8 ✅ Log Out
Perform logout, destroying token and push ID.
```
POST /api/auth/logout
Authorization: Bearer xxxxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK"
}
```
Error Response: 
```
{
    "code" : 419,
    "status": "Error",
    "error": "Token invalid or your session has been expired.",
    "terminate_session": true
}
```

### 1.9 ✅ Update Profile
Perform profile update
```
POST /api/update_profile
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Request body:
```
{
    "nama_penuh": "Shafiq Rizwan bin Shaukat",
    "no_ic": "888888-88-8888",
    "no_tel": "0124205391",
    "emel": "shafiq.rizwan@gmail.com",
    "alamat1": "39 Jalan Eco Majestic",
    "alamat2": "Eco Majestic",
    "poskod": "43500",
    "negeri": "Selangor"
}
```
Success Response:
```
{
    "status": "OK"
}
```
Error Response: 
```
{
    "code" : 400,
    "status": "Error",
    "error": "Pastikan poskod telah diisi"
}
```

### 1.9 ✅ Change Password
Perform password change
```
POST /api/change_password
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Request body:
```
{
    "kata_laluan_lama": "123891238aa@@",
    "kata_laluan_baru": "myNewPass",
}
```
Success Response:
```
{
    "status": "OK"
}
```
Error Response: 
```
{
    "code" : 400,
    "status": "Error",
    "error": "Kata laluan lama tidak tepat"
}
```

### 1.10 Delete Account
Perform account deletion
```
POST /api/delete_account
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Request body:
```
{
    "kata_laluan": "123891238aa@@"
}
```
Success Response:
```
{
    "status": "OK"
}
```
Error Response: 
```
{
    "code" : 400,
    "status": "Error",
    "error": "Kata laluan lama tidak tepat"
}
```

## 2. ✅ Aduan Processes

### 2.0 ✅ Get Aduan categories
Perform request to retrieve all aduan categories
```
GET /api/aduan/categories
Authorization: Bearer xxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK",
    "categories": [
        {"id": 1, "category": "Jalan Rosak"},
        {"id": 2, "category": "Lampu Jalan Rosak"},
        {"id": 3, "category": "Longkang Tersumbat"},
    ]
}
```
Error Response:
```
{
    "code": 403,
    "status": "Error",
    "reason": "Unautorized request"
}
```

### 2.1 ✅ Post Aduan
Perform aduan submission. To force submission due to similar aduan records set `"force": 1`
```
PUT /api/aduan/store
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Request Body:
```
{
    "category": "Jalan Rosak",
    "tarikh": "2023-04-13 11:05:00",  // Format : YYYY-MM-DD HH:II:SS
    "keterangan": "Jalan rosak di beranang hingga menyebabkan kemalangan",
    "alamat": "Jalan Beranang 1, 43500 Semenyih",
    "geocoordinate": "5.128291,101.903202",
    "temp_resources": [
        "https://cdn.kampungkita.com/tmp/1b4ed0f9.png",
        "https://cdn.kampungkita.com/tmp/1b4ed0a5.png",
        "https://cdn.kampungkita.com/tmp/1b4ed0dc.png"],
    "force_submission": 0
}
```
Success Response:
```
{
    "status": "OK",
    "aduan_id": "1002",
}
```
Prompt Response:
```
{
    "status": "Prompt",
    "reason": "Aduan yang hampir sama telah direkod di kawasan yang dilaporkan. Anda pasti ingin membuat aduan ini?",
    "similar_aduan_id": "998"
}
```
Error Response:
```
{
    "code": 403,
    "status": "Error",
    "reason": "Unautorized request"
}
```

### 2.2 ✅ Get Aduan list
Perform request to retrieve all user-relevant Aduan listing
```
GET /api/aduan/list
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK",
    "aduan": [
        {"id": "887", "keterangan": "Lampu jalan rosak", ...},
        ...
    ]
}
```


### 2.2 ✅ Get Aduan by id
Perform request to retrieve all user-relevant Aduan listing
```
GET /api/aduan/list/{id}
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK",
    "aduan": {"id": "887", "keterangan": "Lampu jalan rosak", ...}
}
```


## 3. ✅ Hebahan Processes

### 3.1 ✅ Get Hebahan list

Perform request to retrieve all user-relevant hebahan listing
NOTE: if the news didn't have image, use this image as placeholder http://kampung_kita_web.test/images/40904151189.png
```
GET /api/hebahan/list
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK",
    "hebahan": [
        {"id": "887", "title": "Lampu jalan rosak", "datetime": "2023-04-30 23:11:21"},
        ...
    ]
}
```

### 3.2 ✅ Get Hebahan by id

Perform request to retrieve all user-relevant Hebahan listing
```
GET /api/hebahan/list/{id}
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK",
    "aduan": {"id": "887", "title": "Lampu jalan rosak", "datetime": "2023-04-30 23:11:21"}
}
```

### 3.3 ✅ Post Hebahan

Perform Hebahan Putih submission.
```
PUT /api/hebahan/store
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Request Body:
```
{
    "tarikh": "2023-04-13 11:05:00",  // Format : YYYY-MM-DD HH:II:SS
    "tajuk": "Mesyuarat Persatuan Penduduk"
    "keterangan": "Lorem Ipsum is simply dummy text of the printing and typesetting industry",
    "temp_resources": [
        "https://kampungkita.com/tmp/1b4ed0f9.png",
    ],
}
```
Success Response:
```
{
    "status": "OK",
}
```


## 4. ✅ Bendera Putih Processes

### 4.1 ✅ Post Bendera Putih

Perform Bendera Putih submission.
```
PUT /api/bputih/store
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Request Body:
```
{
    "tarikh": "2023-04-13 11:05:00",  // Format : YYYY-MM-DD HH:II:SS
    "category": "Makanan",
    "keterangan": "Lorem Ipsum is simply dummy text of the printing and typesetting industry",
    "catatan": "Lorem Ipsum is simply dummy text of the printing and typesetting industry",
    "geocoordinate": "5.128291,101.903202",
    "temp_resources": [
        "https://kampungkita.com/tmp/1b4ed0f9.png",
        "https://kampungkita.com/tmp/1b4ed0a5.png",
        "https://kampungkita.com/tmp/1b4ed0dc.png"
        ],
}
```
Success Response:
```
{
    "status": "OK",
}
```


### 4.2 ✅ Get Bendera Putih List
Perform request to retrieve all user-relevant Bendera Putih listing
```
GET /api/bputih/list
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK",
    "bputih": [
        {"id": "887", "keterangan": "Lorem Ipsum", ...},
        ...
    ]
}
```

### 4.3 ✅ Get Bendera Putih by id
Perform request to retrieve user-relevant Aduan listing
```
GET /api/bputih/list/{id}
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK",
    "categories": [
        {"id": 1, "category": "Makanan"},
        {"id": 2, "category": "Perubatan"},
        {"id": 3, "category": "Lain-lain"},
    ]
}
```

### 4.4 ✅ Get Bendera Putih Categories List
Perform request to retrieve all user-relevant Aduan listing
```
GET /api/bputih/categories
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Success Response:
```
{
    "status": "OK",
    "categories": [
        {"id": 1, "category": "Makanan"},
        {"id": 2, "category": "Perubatan"},
        {"id": 3, "category": "Lain-lain"},
    ]
}
```

## 5. Admin Processes

### 5.0 Dashboard Data
Perform request to retrieve all admin dashboard relevant data
```
GET /api/admin/dashboard?from=XXXX-XX-XX&to=XXXX-XX-XX
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Query String:
```
from=2023-04-01&to=2023-04-30
```
Success Response:
```
{
    "status": "OK",
    "jumlah_kutipan": 1000,
    "jumlah_sedekah": 500,
    "jumlah_semasa": 500,
    "permohonan": {
        aduan: {"q1":50,"q2":23,"q3":21,"q4":23},
        khairat_kematian: {"q1":50,"q2":23,"q3":21,"q4":23},
        kongsi_rezeki: {"q1":50,"q2":23,"q3":21,"q4":23},
        bendera_putih: {"q1":50,"q2":23,"q3":21,"q4":23},
    },
    "pendaftaran_baru": [
        {"nama": "Muhammad adam"}
        ...
    ]
}
```


## 6. ✅ Utilities

### 6.0 ✅ Upload Resource
Upload media resources such as photo / video using multipart form data encoding with "file" as input parameter. 
```
POST /api/resources/upload
Authorization: Bearer xxxxxxxxxxxxxxxx
Content-Type: multipart/form-data
Content-Disposition: form-data; name="file"; filename="myphoto.png"  
Content-Type: image/png
...
```
Success Response:
```
{
    "status": "OK",
    "temp_resource": "https://cdn.kampungkita.com/tmp/1b4ed0f9.png",
    "expiry": "2023-04-14 09:59:00"
}
```
Error Response:
```
{
    "status": "Error",
    "reason": "Invalid file format"
}
```

## 7. ✅ In-App-Browser

### 7.0 ✅ Call In-App-Browser
list of routes

| No | Name                 | Route          |
| -- | -------------------- | -------------- |
| 1  | Khairat Kematian     | khairat        |
| 2  | Kongsi Rezeki        | kongsi_rezeki  |
| 3  | Pendaftaran Ahli     | daftar_ahli    |
| 4  | FAQ                  | faq            |
| 5  | Terma & Syarat       | tns            |
| 6  | Dasar Privasi        | dp             |

param for **route** please follow above value

```
GET /in_app_browser/{ROUTE}/{TOKEN}/call
```

The response will render Web views else if return 404

## 8.0  ✅ Panic Button

### 8.1  ✅ Trigger panic button

Perform request to toggle panic mode states
```
POST /api/panic
Authorization: Bearer xxxxxxxxxxxxxxxxx
```
Request Body:
```
{
    "panic": 1,  // toggle state between panic mode 1 - on, 0 - off
    "geocoordinate": "5.128291,101.903202",
}
```
Success Response:
```
{
    "status": "OK",
    "panic": 1
}
```
### 8.2 ✅ Panic Details

Perform request to get information of panic user
```
GET /api/panic/{panic_id}
Authorization: Bearer xxxxxxxxxxxxxxxxx

```
Success Response:
```
{
    "status": "OK",
    "user": { ... },
    "geocoordinate": "5.128291,101.903202"
}
```

### 8.3 ✅ Panic List
Perform request to get list of past panic triggers
```
GET /api/panic/list
Authorization: Bearer xxxxxxxxxxxxxxxxx

```
Success Response:
```
{
    "status": "OK",
    "list": { ... },
}
```

### 8.4 ✅ Panic Details from list

Perform request to get information of panic user
```
GET /api/panic2/{panic_id}
Authorization: Bearer xxxxxxxxxxxxxxxxx

```
Success Response:
```
{
    "status": "OK",
    "user": { ... },
    "geocoordinate": "5.128291,101.903202"
}
```