v2.0: massive test data (104 products, 41 postings, 20 returns, 20 payouts, 25 txs, 3 companies)
- Remove unused gin dependency from go.mod - Remove credential logging from startup - Remove dead parseOfferIDs function - Add method check to GET /v1/product/list - Complete all filter implementations (since, to, status, product_id, return_id, dir, analytics, page) - CancelPosting now validates posting existence (404 for unknown) - Implement MOCK_STOCKS_JSON file loading - Add Phase 2 endpoints: v3/product/import, v1/product/info/description, v1/product/info/attributes, v2/category/tree, v3/category/attribute, v3/category/attribute/values - Generate 104 products/stocks/prices across 3 companies: TechGiant (TG-0001..TG-0035), FashionLine (FL-0001..FL-0035), HomeStyle (HS-0001..HS-0034) - 41 postings, 20 returns, 20 payouts, 25 transactions - 31 tests (all PASS with race detector) - Add Makefile
This commit is contained in:
@ -14,28 +14,42 @@ func main() {
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
auth := func(h http.HandlerFunc) http.HandlerFunc {
|
||||
return middleware.Auth(cfg.ClientID, cfg.APIKey, h)
|
||||
}
|
||||
|
||||
// Products
|
||||
mux.HandleFunc("/v1/product/import/prices", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.ImportPrices))
|
||||
mux.HandleFunc("/v1/product/list", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.ProductList))
|
||||
mux.HandleFunc("/v3/product/info/list", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.ProductInfoList))
|
||||
mux.HandleFunc("/v3/product/info/stocks", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.ProductStocks))
|
||||
mux.HandleFunc("/v4/product/info/prices", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.ProductPrices))
|
||||
mux.HandleFunc("/v1/product/import/prices", auth(handlers.ImportPrices))
|
||||
mux.HandleFunc("/v1/product/list", auth(handlers.ProductList))
|
||||
mux.HandleFunc("/v3/product/info/list", auth(handlers.ProductInfoList))
|
||||
mux.HandleFunc("/v3/product/info/stocks", auth(handlers.ProductStocks))
|
||||
mux.HandleFunc("/v4/product/info/prices", auth(handlers.ProductPrices))
|
||||
|
||||
// Product cards (Phase 2)
|
||||
mux.HandleFunc("/v3/product/import", auth(handlers.ImportProducts))
|
||||
mux.HandleFunc("/v1/product/info/description", auth(handlers.ProductDescriptions))
|
||||
mux.HandleFunc("/v1/product/info/attributes", auth(handlers.ProductAttributes))
|
||||
|
||||
// Categories (Phase 2)
|
||||
mux.HandleFunc("/v2/category/tree", auth(handlers.CategoryTree))
|
||||
mux.HandleFunc("/v3/category/attribute", auth(handlers.CategoryAttributes))
|
||||
mux.HandleFunc("/v3/category/attribute/values", auth(handlers.CategoryAttributeValues))
|
||||
|
||||
// Postings
|
||||
mux.HandleFunc("/v2/posting/fbs/list", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.PostingFBSList))
|
||||
mux.HandleFunc("/v2/posting/fbs/get", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.PostingFBSGet))
|
||||
mux.HandleFunc("/v1/posting/fbs/cancel", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.CancelPosting))
|
||||
mux.HandleFunc("/v2/posting/fbs/list", auth(handlers.PostingFBSList))
|
||||
mux.HandleFunc("/v2/posting/fbs/get", auth(handlers.PostingFBSGet))
|
||||
mux.HandleFunc("/v1/posting/fbs/cancel", auth(handlers.CancelPosting))
|
||||
|
||||
// Finance
|
||||
mux.HandleFunc("/v1/finance/transaction/list", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.FinanceTransactionList))
|
||||
mux.HandleFunc("/v1/finance/payout/list", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.FinancePayoutList))
|
||||
mux.HandleFunc("/v1/finance/transaction/list", auth(handlers.FinanceTransactionList))
|
||||
mux.HandleFunc("/v1/finance/payout/list", auth(handlers.FinancePayoutList))
|
||||
|
||||
// Returns
|
||||
mux.HandleFunc("/v1/returns/list", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.ReturnsList))
|
||||
mux.HandleFunc("/v1/returns/list", auth(handlers.ReturnsList))
|
||||
|
||||
// Analytics
|
||||
mux.HandleFunc("/v1/analytics/data", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.AnalyticsData))
|
||||
mux.HandleFunc("/v1/analytics/turnover/stocks", middleware.Auth(cfg.ClientID, cfg.APIKey, handlers.TurnoverStocks))
|
||||
mux.HandleFunc("/v1/analytics/data", auth(handlers.AnalyticsData))
|
||||
mux.HandleFunc("/v1/analytics/turnover/stocks", auth(handlers.TurnoverStocks))
|
||||
|
||||
// Health
|
||||
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -52,6 +66,5 @@ func main() {
|
||||
|
||||
addr := ":" + cfg.Port
|
||||
log.Printf("Starting ozon-mock on %s", addr)
|
||||
log.Printf("Auth: client_id=%s, api_key=%s", cfg.ClientID, cfg.APIKey)
|
||||
log.Fatal(http.ListenAndServe(addr, mux))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user