Initial commit: ozon-mock Go server

- Mock Ozon Seller API endpoints
- Products, Postings, Finance, Returns, Analytics
- JSON fixtures for testing
- Docker support
- Gitea Actions CI/CD
This commit is contained in:
Rinat
2026-07-15 16:19:24 +03:00
commit 842f87f576
13 changed files with 1285 additions and 0 deletions

106
README.md Normal file
View File

@ -0,0 +1,106 @@
# Ozon Mock API Server
Mock-сервер для тестирования интеграции с Ozon Seller API.
## Быстрый старт
```bash
# Запуск
go run ./cmd/server
# Или с переменными окружения
OZON_CLIENT_ID=test-client OZON_API_KEY=test-key PORT=8080 go run ./cmd/server
```
## Тестовые запросы
```bash
# Stocks
curl -X POST http://localhost:8080/v3/product/info/stocks \
-H "Client-Id: test-client" \
-H "Api-Key: test-key" \
-H "Content-Type: application/json" \
-d '{"filter": {"offer_id": ["TEST-SKU-001"]}, "limit": 100}'
# Postings list
curl -X POST http://localhost:8080/v2/posting/fbs/list \
-H "Client-Id: test-client" \
-H "Api-Key: test-key" \
-H "Content-Type: application/json" \
-d '{"dir": "desc", "limit": 100}'
# Posting details
curl -X POST http://localhost:8080/v2/posting/fbs/get \
-H "Client-Id: test-client" \
-H "Api-Key: test-key" \
-H "Content-Type: application/json" \
-d '{"posting_number": "TEST-POST-001"}'
# Import prices
curl -X POST http://localhost:8080/v1/product/import/prices \
-H "Client-Id: test-client" \
-H "Api-Key: test-key" \
-H "Content-Type: application/json" \
-d '{"items": [{"offer_id": "TEST-SKU-001", "price": 1990.00}]}'
```
## Переменные окружения
| Переменная | Обязательна | По умолчанию | Описание |
|------------|-------------|---------------|----------|
| `PORT` | Нет | 8080 | Порт |
| `OZON_CLIENT_ID` | Нет | (пусто) | Ожидаемый Client-ID. Если пусто - не проверяется |
| `OZON_API_KEY` | Нет | (пусто) | Ожидаемый API-Key. Если пусто - не проверяется |
## Эндпоинты
### Products
- `POST /v1/product/import/prices` - Import prices
- `GET /v1/product/list` - List products
- `POST /v3/product/info/list` - Get product info
- `POST /v3/product/info/stocks` - Get product stocks
- `POST /v4/product/info/prices` - Get product prices
### Postings
- `POST /v2/posting/fbs/list` - List FBS postings
- `POST /v2/posting/fbs/get` - Get posting details
- `POST /v1/posting/fbs/cancel` - Cancel posting
### Finance
- `POST /v1/finance/transaction/list` - List transactions
- `POST /v1/finance/payout/list` - List payouts
### Returns
- `POST /v1/returns/list` - List returns
### Analytics
- `POST /v1/analytics/data` - Analytics data
- `POST /v1/analytics/turnover/stocks` - Stock turnover
### Health
- `GET /health` - Health check
## Тестовые данные
### Offer IDs
- `TEST-SKU-001` - Тестовый товар 1 (price: 1990, stock: 150)
- `TEST-SKU-002` - Тестовый товар 2 (price: 990, stock: 75)
- `TEST-SKU-003` - Тестовый товар 3 (price: 3990, stock: 200)
- `TEST-SKU-004` - Тестовый товар 4 (price: 590, stock: 0)
- `TEST-SKU-005` - Тестовый товар 5 (price: 1590, stock: 50)
### Posting Numbers
- `TEST-POST-001` - delivered
- `TEST-POST-002` - delivered
- `TEST-POST-003` - awaiting_deliver
- `TEST-POST-004` - cancelled
## Deployment
```bash
# Build
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ozon-mock ./cmd/server
# Run
./ozon-mock
```