feat: add private product management endpoints for updating canonical names and merging products
Test Suite / test (24.15.0) (push) Has been cancelled

This commit is contained in:
Nils-Johan Gynther
2026-05-09 23:19:28 +02:00
parent 8e276a34fe
commit 14a1107466
4 changed files with 134 additions and 34 deletions
+2
View File
@@ -10,11 +10,13 @@ class ProductApiPaths {
static const aiCategorizeBulk = '/products/ai-categorize-bulk';
static const deleted = '/products/deleted';
static const merge = '/products/merge';
static const mergePrivate = '/products/private/merge';
static String mergePreview(int sourceProductId, int targetProductId) =>
'/products/merge-preview?sourceProductId=$sourceProductId&targetProductId=$targetProductId';
static String setStatus(int id) => '/products/$id/status';
static String update(int id) => '/products/$id';
static String canonicalName(int id) => '/products/$id/canonical-name';
static String canonicalNamePrivate(int id) => '/products/private/$id/canonical-name';
static String remove(int id) => '/products/$id';
static String restore(int id) => '/products/$id/restore';
static const bulkUpdate = '/products/bulk-update';
@@ -191,12 +191,33 @@ class AdminRepository {
Future<void> restoreProduct(int productId) =>
_postVoid(ProductApiPaths.restore(productId));
// ── Product canonical name updates ────────────────────────────────────────
// Admin can update any product; users can only update their own private products
Future<void> updateCanonicalName(int productId, String canonicalName) =>
_patchVoid(
ProductApiPaths.canonicalName(productId),
{'canonicalName': canonicalName.trim()},
);
Future<void> updateCanonicalNamePrivate(int productId, String canonicalName) =>
_patchVoid(
ProductApiPaths.canonicalNamePrivate(productId),
{'canonicalName': canonicalName.trim()},
);
// ── Product merging ────────────────────────────────────────────────────────
// Admin can merge any products; users can only merge their own private products
Future<void> mergeProductsPrivate({
required int sourceProductId,
required int targetProductId,
}) =>
_postVoid(ProductApiPaths.mergePrivate, {
'sourceProductId': sourceProductId,
'targetProductId': targetProductId,
});
/// Skapar en ny aktiv produkt (kräver admin). Returnerar `{id, name, categoryId?}`.
Future<Map<String, dynamic>> createProduct(String name, {int? categoryId}) =>
_post<Map<String, dynamic>>(