# Research Category API — Curl / Postman

Base URL (XAMPP local):

```text
http://localhost/fintraBackend/fi_adm/public/api
```

If your vhost points at `public`, use:

```text
http://localhost/api
```

Replace `YOUR_JWT_TOKEN` with the `access_token` from login.  
All research-category routes require:

- Header: `Authorization: Bearer YOUR_JWT_TOKEN`
- Header: `Accept: application/json`
- Middleware: `jwt.auth`, `check.token`, `dynamic.permission`  
  (the logged-in back-office user must also have these APIs assigned in route-API permissions)

---

## 0. Login (get JWT)

```bash
curl --location --request POST "http://localhost/fintraBackend/fi_adm/public/api/auth/login" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data-raw "{
    \"email\": \"your.backoffice@email.com\",
    \"password\": \"your_password\"
  }"
```

Copy `access_token` from the response into the requests below.

---

## 1. List categories (index)

```bash
curl --location --request GET "http://localhost/fintraBackend/fi_adm/public/api/research-category/index" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_JWT_TOKEN"
```

Optional pagination:

```bash
curl --location --request GET "http://localhost/fintraBackend/fi_adm/public/api/research-category/index?per_page=20" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_JWT_TOKEN"
```

---

## 2. Show category by ID

```bash
curl --location --request GET "http://localhost/fintraBackend/fi_adm/public/api/research-category/show/1" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_JWT_TOKEN"
```

---

## 3. Create category (store)

```bash
curl --location --request POST "http://localhost/fintraBackend/fi_adm/public/api/research-category/research-category-store" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_JWT_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw "{
    \"name\": \"Equity Research\",
    \"logo\": \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 24 24\\\"><path d=\\\"M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z\\\"/></svg>\",
    \"description\": \"Company-level equity research reports\"
  }"
```

---

## 4. Update category (POST, not PUT)

```bash
curl --location --request POST "http://localhost/fintraBackend/fi_adm/public/api/research-category/update/1" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_JWT_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw "{
    \"name\": \"Equity Research Updated\",
    \"logo\": \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 24 24\\\"><path d=\\\"M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z\\\"/></svg>\",
    \"description\": \"Updated short description\"
  }"
```

---

## 5. Delete category

```bash
curl --location --request DELETE "http://localhost/fintraBackend/fi_adm/public/api/research-category/delete/1" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_JWT_TOKEN"
```

Delete returns **409** if the category still has related report types or reports.

---

## Postman quick setup

1. Create a collection variable `base_url` = `http://localhost/fintraBackend/fi_adm/public/api`
2. Create a collection variable `token` = *(paste access_token after login)*
3. In collection Authorization: Type **Bearer Token**, Token = `{{token}}`
4. Import each request:
   - `GET {{base_url}}/research-category/index`
   - `GET {{base_url}}/research-category/show/1`
   - `POST {{base_url}}/research-category/store` body raw JSON `{"name":"Equity Research"}`
   - `POST {{base_url}}/research-category/update/1` body raw JSON `{"name":"Equity Research Updated"}`
   - `DELETE {{base_url}}/research-category/delete/1`

---

## Expected success shapes

**Create (201)**

```json
{
  "status": true,
  "message": "Research category created successfully",
  "data": {
    "id": 1,
    "name": "Equity Research",
    "logo": "<svg ...></svg>",
    "description": "Company-level equity research reports",
    "created_at": "...",
    "updated_at": "..."
  }
}
```

**List (200)**

```json
{
  "status": true,
  "data": [ ... ],
  "pagination": {
    "current_page": 1,
    "last_page": 1,
    "per_page": 10,
    "total": 1
  }
}
```
