# Market Updates Store API — Curl / Postman

**Method:** `POST`  
**URL:** `/api/research-company/research-market-updates-store`  
**Route name:** `research-market-updates-store`  
**Controller:** `DiverseResearchController@storeMarketUpdates`  
**Content-Type:** `multipart/form-data` (required because of file uploads)

Base URL (XAMPP local):

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

Replace `YOUR_JWT_TOKEN` with the `access_token` from login.  
Requires middleware: `jwt.auth`, `check.token`, `dynamic.permission`  
(assign this route to the user’s role in route-API permissions first).

---

## 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.

---

## 1. Store Market Updates report

Replace placeholders:

- `CATEGORY_ID` → a valid `research_categories.id` (Market Updates category)
- `REPORT_TYPE_ID` → a valid `report_types.id` (e.g. Daily / Weekly / Monthly Market Wrap-up)
- file paths → real local files

```bash
curl --location --request POST "http://localhost/fintraBackend/fi_adm/public/api/research-company/research-market-updates-store" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_JWT_TOKEN" \
  --form "report_type_id=REPORT_TYPE_ID" \
  --form "report_date=2026-03-31" \
  --form "category_id=CATEGORY_ID" \
  --form "en_json={\"pages\":[]}" \
  --form "bn_json={\"pages\":[]}" \
  --form "english_pdf=@C:/path/to/english.pdf" \
  --form "bangla_pdf=@C:/path/to/bangla.pdf"
```

### Minimal required-only request

```bash
curl --location --request POST "http://localhost/fintraBackend/fi_adm/public/api/research-company/research-market-updates-store" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer YOUR_JWT_TOKEN" \
  --form "report_type_id=REPORT_TYPE_ID" \
  --form "report_date=2026-03-31" \
  --form "category_id=CATEGORY_ID"
```

---

## Field reference

| Field | Required | Type | Notes |
|---|---|---|---|
| `report_type_id` | Yes | int | must exist in `report_types.id` |
| `report_date` | Yes | date | e.g. `2026-03-31` |
| `category_id` | Yes | int | must exist in `research_categories.id` |
| `english_pdf` | No | file | pdf, max 10MB |
| `bangla_pdf` | No | file | pdf, max 10MB |
| `en_json` | No | string | JSON text |
| `bn_json` | No | string | JSON text |

**Not used for Market Updates** (left null / false): `sub_heading`, `quarter`, `featured_image_url`, `is_featured` (`false`), securities, sectors, tags.

`report_title` is generated server-side as `{report_type_name}_{report_date}` (e.g. `Daily Market Wrap-up_2026-03-31`). Do not send it from the frontend.

---

## Postman setup

1. Method: **POST**
2. URL: `{{base_url}}/research-company/research-market-updates-store`
3. Authorization: **Bearer Token** → paste JWT
4. Headers: `Accept: application/json`
5. Body → **form-data** (not raw JSON):

| Key | Type | Example value |
|---|---|---|
| `report_type_id` | Text | `1` |
| `report_date` | Text | `2026-03-31` |
| `category_id` | Text | `1` |
| `en_json` | Text | `{"pages":[]}` |
| `bn_json` | Text | `{"pages":[]}` |
| `english_pdf` | File | choose PDF |
| `bangla_pdf` | File | choose PDF |

Do **not** set `Content-Type` manually in Postman; it must auto-set the multipart boundary.

---

## Example `en_json` / `bn_json` (paste as Text)

**en_json**
```json
{"title":"Daily Market Wrap-up","report_date":"2026-03-31","summary":"DSEX closed higher on broad-based buying.","pages":[{"page":1,"heading":"Market Summary","content":"Turnover improved with banking and pharma leading gains."}]}
```

**bn_json**
```json
{"title":"দৈনিক মার্কেট র‍্যাপ-আপ","report_date":"2026-03-31","summary":"ব্যাপক ক্রয়ে ডিএসইএক্স উচ্চতর পর্যায়ে বন্ধ হয়েছে।","pages":[{"page":1,"heading":"বাজার সারাংশ","content":"ব্যাংক ও ফার্মা খাতে লাভের নেতৃত্বে টার্নওভার বেড়েছে।"}]}
```

---

## Expected responses

**Success (201)**

```json
{
  "status": true,
  "message": "Market Updates report uploaded successfully",
  "data": {
    "id": 1,
    "category_id": 1,
    "report_type_id": 1,
    "report_title": "Daily Market Wrap-up_2026-03-31",
    "sub_heading": null,
    "quarter": null,
    "report_date": "2026-03-31",
    "featured_image_url": null,
    "is_featured": false,
    "english_pdf_url": "research_reports/...",
    "bangla_pdf_url": "research_reports/...",
    "en_json": "{\"pages\":[]}",
    "bn_json": "{\"pages\":[]}",
    "report_type": { "id": 1, "name": "Daily Market Wrap-up" },
    "category": { "id": 1, "name": "Market Updates" }
  }
}
```

**Validation fail (422)**

```json
{
  "status": false,
  "message": "Validation failed",
  "errors": { ... }
}
```

**Server error (500)**

```json
{
  "status": false,
  "message": "Failed to upload Market Updates report",
  "error": "..."
}
```

