# Mobile REST API

Base URL:

https://catalog.snyt.xyz/api

## Authentication

The mobile app uses Bearer token authentication.

After login, Flutter must send:

Authorization: Bearer MOBILE_TOKEN
Accept: application/json

## POST /api/mobile/login

Login salesman or admin account.

Request:

{
  "email": "salesman@example.com",
  "password": "password"
}

Response:

{
  "success": true,
  "message": "Login successful.",
  "token_type": "Bearer",
  "token": "TOKEN_HERE",
  "user": {
    "id": 1,
    "name": "Abdallah",
    "email": "email@example.com",
    "role": "salesman"
  }
}

## GET /api/mobile/me

Returns logged-in mobile user.

## POST /api/mobile/logout

Deletes the current mobile token.

## GET /api/mobile/dashboard

Returns salesman dashboard data.

## GET /api/mobile/boxes

Returns boxes owned by the logged-in salesman.

## GET /api/mobile/boxes/{id}

Returns one box.

## GET /api/mobile/boxes/{id}/items

Returns products inside one box.

## GET /api/mobile/products/barcode/{barcode}

Finds a product by barcode, prioritizing current salesman's van stock.





curl -X GET https://catalog.snyt.xyz/api/mobile/me \
  -H "Accept: application/json" \
  -H "Authorization: Bearer XKcpHhyITKxcbBGbhd8zZl917ZXlId83Kr9dQLUPMQ7akUNFEe79RArkWmCagwb86X6wqWoVbF8uMXNx"




curl -X GET https://catalog.snyt.xyz/api/mobile/dashboard \
  -H "Accept: application/json" \
  -H "Authorization: Bearer XKcpHhyITKxcbBGbhd8zZl917ZXlId83Kr9dQLUPMQ7akUNFEe79RArkWmCagwb86X6wqWoVbF8uMXNx"
## GET /api/mobile/van-stock

Returns the logged-in salesman's van stock items.

Optional query:

search=SKU_OR_BARCODE_OR_NAME

Example:

/api/mobile/van-stock?search=charger

## Update - /api/mobile/van-stock

The endpoint now:

- Groups duplicated van stock rows by product or SKU.
- Sums quantities for repeated products.
- Returns product image URL.
- Returns meta data including salesman name and van name.

## Mobile Inventory Check API

### GET /api/mobile/inventory-check

Returns current inventory check status, latest van stock import, progress summary, and items.

### POST /api/mobile/inventory-check/start

Starts a new inventory check for the logged-in salesman.

If another check is open, it is closed automatically.

### POST /api/mobile/inventory-check/mark

Marks one item.

Request:

{
  "van_stock_item_id": 1,
  "status": "correct",
  "counted_qty": 10,
  "note": "optional"
}

Allowed statuses:

- correct
- wrong
- missing
- unchecked

### POST /api/mobile/inventory-check/finish

Completes the open inventory check.
