@wix/auto_sdk_stores_products 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.d.ts +1 -0
- package/build/cjs/index.js +18 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/index.typings.d.ts +1 -0
- package/build/cjs/index.typings.js +18 -0
- package/build/cjs/index.typings.js.map +1 -0
- package/build/cjs/meta.d.ts +1 -0
- package/build/cjs/meta.js +18 -0
- package/build/cjs/meta.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product-products.context.d.ts +66 -0
- package/build/cjs/src/stores-catalog-v1-product-products.context.js +79 -0
- package/build/cjs/src/stores-catalog-v1-product-products.context.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product-products.http.d.ts +75 -0
- package/build/cjs/src/stores-catalog-v1-product-products.http.js +1158 -0
- package/build/cjs/src/stores-catalog-v1-product-products.http.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product-products.meta.d.ts +78 -0
- package/build/cjs/src/stores-catalog-v1-product-products.meta.js +522 -0
- package/build/cjs/src/stores-catalog-v1-product-products.meta.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product-products.public.d.ts +242 -0
- package/build/cjs/src/stores-catalog-v1-product-products.public.js +196 -0
- package/build/cjs/src/stores-catalog-v1-product-products.public.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product-products.types.d.ts +1868 -0
- package/build/cjs/src/stores-catalog-v1-product-products.types.js +106 -0
- package/build/cjs/src/stores-catalog-v1-product-products.types.js.map +1 -0
- package/build/cjs/src/stores-catalog-v1-product-products.universal.d.ts +2682 -0
- package/build/cjs/src/stores-catalog-v1-product-products.universal.js +1236 -0
- package/build/cjs/src/stores-catalog-v1-product-products.universal.js.map +1 -0
- package/build/es/index.d.ts +1 -0
- package/build/es/index.js +2 -0
- package/build/es/index.js.map +1 -0
- package/build/es/index.typings.d.ts +1 -0
- package/build/es/index.typings.js +2 -0
- package/build/es/index.typings.js.map +1 -0
- package/build/es/meta.d.ts +1 -0
- package/build/es/meta.js +2 -0
- package/build/es/meta.js.map +1 -0
- package/build/es/package.json +3 -0
- package/build/es/src/stores-catalog-v1-product-products.context.d.ts +66 -0
- package/build/es/src/stores-catalog-v1-product-products.context.js +66 -0
- package/build/es/src/stores-catalog-v1-product-products.context.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product-products.http.d.ts +75 -0
- package/build/es/src/stores-catalog-v1-product-products.http.js +1129 -0
- package/build/es/src/stores-catalog-v1-product-products.http.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product-products.meta.d.ts +78 -0
- package/build/es/src/stores-catalog-v1-product-products.meta.js +470 -0
- package/build/es/src/stores-catalog-v1-product-products.meta.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product-products.public.d.ts +242 -0
- package/build/es/src/stores-catalog-v1-product-products.public.js +157 -0
- package/build/es/src/stores-catalog-v1-product-products.public.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product-products.types.d.ts +1868 -0
- package/build/es/src/stores-catalog-v1-product-products.types.js +103 -0
- package/build/es/src/stores-catalog-v1-product-products.types.js.map +1 -0
- package/build/es/src/stores-catalog-v1-product-products.universal.d.ts +2682 -0
- package/build/es/src/stores-catalog-v1-product-products.universal.js +1184 -0
- package/build/es/src/stores-catalog-v1-product-products.universal.js.map +1 -0
- package/build/internal/cjs/index.d.ts +1 -0
- package/build/internal/cjs/index.js +18 -0
- package/build/internal/cjs/index.js.map +1 -0
- package/build/internal/cjs/index.typings.d.ts +1 -0
- package/build/internal/cjs/index.typings.js +18 -0
- package/build/internal/cjs/index.typings.js.map +1 -0
- package/build/internal/cjs/meta.d.ts +1 -0
- package/build/internal/cjs/meta.js +18 -0
- package/build/internal/cjs/meta.js.map +1 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.context.d.ts +66 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.context.js +79 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.context.js.map +1 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.http.d.ts +75 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.http.js +1158 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.http.js.map +1 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.meta.d.ts +78 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.meta.js +522 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.meta.js.map +1 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.public.d.ts +242 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.public.js +196 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.public.js.map +1 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.types.d.ts +1868 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.types.js +106 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.types.js.map +1 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.universal.d.ts +2682 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.universal.js +1236 -0
- package/build/internal/cjs/src/stores-catalog-v1-product-products.universal.js.map +1 -0
- package/build/internal/es/index.d.ts +1 -0
- package/build/internal/es/index.js +2 -0
- package/build/internal/es/index.js.map +1 -0
- package/build/internal/es/index.typings.d.ts +1 -0
- package/build/internal/es/index.typings.js +2 -0
- package/build/internal/es/index.typings.js.map +1 -0
- package/build/internal/es/meta.d.ts +1 -0
- package/build/internal/es/meta.js +2 -0
- package/build/internal/es/meta.js.map +1 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.context.d.ts +66 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.context.js +66 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.context.js.map +1 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.http.d.ts +75 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.http.js +1129 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.http.js.map +1 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.meta.d.ts +78 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.meta.js +470 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.meta.js.map +1 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.public.d.ts +242 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.public.js +157 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.public.js.map +1 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.types.d.ts +1868 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.types.js +103 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.types.js.map +1 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.universal.d.ts +2682 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.universal.js +1184 -0
- package/build/internal/es/src/stores-catalog-v1-product-products.universal.js.map +1 -0
- package/meta/package.json +3 -0
- package/package.json +52 -0
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';
|
|
2
|
+
import { queryBuilder } from '@wix/sdk-runtime/query-builder';
|
|
3
|
+
import { renameKeysFromSDKRequestToRESTRequest, renameKeysFromRESTResponseToSDKResponse, } from '@wix/sdk-runtime/rename-all-nested-keys';
|
|
4
|
+
import * as ambassadorWixStoresCatalogV1Product from './stores-catalog-v1-product-products.http.js';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { transformRESTImageToSDKImage } from '@wix/sdk-runtime/transformations/image';
|
|
7
|
+
import { transformRESTVideoV2ToSDKVideoV2 } from '@wix/sdk-runtime/transformations/video-v2';
|
|
8
|
+
import { transformPaths } from '@wix/sdk-runtime/transformations/transform-paths';
|
|
9
|
+
export var ProductType;
|
|
10
|
+
(function (ProductType) {
|
|
11
|
+
ProductType["unspecified_product_type"] = "unspecified_product_type";
|
|
12
|
+
ProductType["physical"] = "physical";
|
|
13
|
+
ProductType["digital"] = "digital";
|
|
14
|
+
})(ProductType || (ProductType = {}));
|
|
15
|
+
export var InventoryStatus;
|
|
16
|
+
(function (InventoryStatus) {
|
|
17
|
+
/** In stock */
|
|
18
|
+
InventoryStatus["IN_STOCK"] = "IN_STOCK";
|
|
19
|
+
/** Not in stock */
|
|
20
|
+
InventoryStatus["OUT_OF_STOCK"] = "OUT_OF_STOCK";
|
|
21
|
+
/** Some of the variants are not in stock */
|
|
22
|
+
InventoryStatus["PARTIALLY_OUT_OF_STOCK"] = "PARTIALLY_OUT_OF_STOCK";
|
|
23
|
+
})(InventoryStatus || (InventoryStatus = {}));
|
|
24
|
+
export var MeasurementUnit;
|
|
25
|
+
(function (MeasurementUnit) {
|
|
26
|
+
MeasurementUnit["UNSPECIFIED"] = "UNSPECIFIED";
|
|
27
|
+
MeasurementUnit["ML"] = "ML";
|
|
28
|
+
MeasurementUnit["CL"] = "CL";
|
|
29
|
+
MeasurementUnit["L"] = "L";
|
|
30
|
+
MeasurementUnit["CBM"] = "CBM";
|
|
31
|
+
MeasurementUnit["MG"] = "MG";
|
|
32
|
+
MeasurementUnit["G"] = "G";
|
|
33
|
+
MeasurementUnit["KG"] = "KG";
|
|
34
|
+
MeasurementUnit["MM"] = "MM";
|
|
35
|
+
MeasurementUnit["CM"] = "CM";
|
|
36
|
+
MeasurementUnit["M"] = "M";
|
|
37
|
+
MeasurementUnit["SQM"] = "SQM";
|
|
38
|
+
MeasurementUnit["OZ"] = "OZ";
|
|
39
|
+
MeasurementUnit["LB"] = "LB";
|
|
40
|
+
MeasurementUnit["FLOZ"] = "FLOZ";
|
|
41
|
+
MeasurementUnit["PT"] = "PT";
|
|
42
|
+
MeasurementUnit["QT"] = "QT";
|
|
43
|
+
MeasurementUnit["GAL"] = "GAL";
|
|
44
|
+
MeasurementUnit["IN"] = "IN";
|
|
45
|
+
MeasurementUnit["FT"] = "FT";
|
|
46
|
+
MeasurementUnit["YD"] = "YD";
|
|
47
|
+
MeasurementUnit["SQFT"] = "SQFT";
|
|
48
|
+
})(MeasurementUnit || (MeasurementUnit = {}));
|
|
49
|
+
export var MediaItemType;
|
|
50
|
+
(function (MediaItemType) {
|
|
51
|
+
MediaItemType["unspecified_media_item_type"] = "unspecified_media_item_type";
|
|
52
|
+
/** Image media type. */
|
|
53
|
+
MediaItemType["image"] = "image";
|
|
54
|
+
/** Video media type. */
|
|
55
|
+
MediaItemType["video"] = "video";
|
|
56
|
+
/** Audio media type. */
|
|
57
|
+
MediaItemType["audio"] = "audio";
|
|
58
|
+
/** Document media type. */
|
|
59
|
+
MediaItemType["document"] = "document";
|
|
60
|
+
/** Zip media type. */
|
|
61
|
+
MediaItemType["zip"] = "zip";
|
|
62
|
+
})(MediaItemType || (MediaItemType = {}));
|
|
63
|
+
export var OptionType;
|
|
64
|
+
(function (OptionType) {
|
|
65
|
+
/** Unspecified option type. */
|
|
66
|
+
OptionType["unspecified_option_type"] = "unspecified_option_type";
|
|
67
|
+
/** Drop down. */
|
|
68
|
+
OptionType["drop_down"] = "drop_down";
|
|
69
|
+
/** Color. */
|
|
70
|
+
OptionType["color"] = "color";
|
|
71
|
+
})(OptionType || (OptionType = {}));
|
|
72
|
+
export var DiscountType;
|
|
73
|
+
(function (DiscountType) {
|
|
74
|
+
DiscountType["UNDEFINED"] = "UNDEFINED";
|
|
75
|
+
/** No discount */
|
|
76
|
+
DiscountType["NONE"] = "NONE";
|
|
77
|
+
/** Discount by a fixed amount */
|
|
78
|
+
DiscountType["AMOUNT"] = "AMOUNT";
|
|
79
|
+
/** Discount by a percentage */
|
|
80
|
+
DiscountType["PERCENT"] = "PERCENT";
|
|
81
|
+
})(DiscountType || (DiscountType = {}));
|
|
82
|
+
export var FileType;
|
|
83
|
+
(function (FileType) {
|
|
84
|
+
FileType["UNSPECIFIED"] = "UNSPECIFIED";
|
|
85
|
+
FileType["SECURE_PICTURE"] = "SECURE_PICTURE";
|
|
86
|
+
FileType["SECURE_VIDEO"] = "SECURE_VIDEO";
|
|
87
|
+
FileType["SECURE_DOCUMENT"] = "SECURE_DOCUMENT";
|
|
88
|
+
FileType["SECURE_MUSIC"] = "SECURE_MUSIC";
|
|
89
|
+
FileType["SECURE_ARCHIVE"] = "SECURE_ARCHIVE";
|
|
90
|
+
})(FileType || (FileType = {}));
|
|
91
|
+
export var Version;
|
|
92
|
+
(function (Version) {
|
|
93
|
+
/** Version 1 of the catalog. */
|
|
94
|
+
Version["V1_CATALOG"] = "V1_CATALOG";
|
|
95
|
+
/** Version 3 of the catalog. */
|
|
96
|
+
Version["V3_CATALOG"] = "V3_CATALOG";
|
|
97
|
+
})(Version || (Version = {}));
|
|
98
|
+
export var SortOrder;
|
|
99
|
+
(function (SortOrder) {
|
|
100
|
+
SortOrder["ASC"] = "ASC";
|
|
101
|
+
SortOrder["DESC"] = "DESC";
|
|
102
|
+
})(SortOrder || (SortOrder = {}));
|
|
103
|
+
export var WebhookIdentityType;
|
|
104
|
+
(function (WebhookIdentityType) {
|
|
105
|
+
WebhookIdentityType["UNKNOWN"] = "UNKNOWN";
|
|
106
|
+
WebhookIdentityType["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
|
|
107
|
+
WebhookIdentityType["MEMBER"] = "MEMBER";
|
|
108
|
+
WebhookIdentityType["WIX_USER"] = "WIX_USER";
|
|
109
|
+
WebhookIdentityType["APP"] = "APP";
|
|
110
|
+
})(WebhookIdentityType || (WebhookIdentityType = {}));
|
|
111
|
+
/**
|
|
112
|
+
* Creates a new product.
|
|
113
|
+
* @param product - Product information.
|
|
114
|
+
* @public
|
|
115
|
+
* @requiredField product
|
|
116
|
+
* @requiredField product.costAndProfitData.itemCost
|
|
117
|
+
* @requiredField product.name
|
|
118
|
+
* @requiredField product.priceData
|
|
119
|
+
* @requiredField product.priceData.price
|
|
120
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
121
|
+
* @permissionScope Manage Stores - all permissions
|
|
122
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
123
|
+
* @permissionScope Manage Products
|
|
124
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
125
|
+
* @applicableIdentity APP
|
|
126
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.CreateProduct
|
|
127
|
+
*/
|
|
128
|
+
export async function createProduct(product) {
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
131
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ product: product });
|
|
132
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.createProduct(payload);
|
|
133
|
+
sideEffects?.onSiteCall?.();
|
|
134
|
+
try {
|
|
135
|
+
const result = await httpClient.request(reqOpts);
|
|
136
|
+
sideEffects?.onSuccess?.(result);
|
|
137
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
const transformedError = sdkTransformError(err, {
|
|
141
|
+
spreadPathsToArguments: {},
|
|
142
|
+
explicitPathsToArguments: { product: '$[0]' },
|
|
143
|
+
singleArgumentUnchanged: false,
|
|
144
|
+
}, ['product']);
|
|
145
|
+
sideEffects?.onError?.(err);
|
|
146
|
+
throw transformedError;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Updates specified fields in a product.
|
|
151
|
+
* @param _id - Product ID (generated automatically by the catalog).
|
|
152
|
+
* @public
|
|
153
|
+
* @requiredField _id
|
|
154
|
+
* @requiredField product
|
|
155
|
+
* @param product - Product info to update.
|
|
156
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
157
|
+
* @permissionScope Manage Stores - all permissions
|
|
158
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
159
|
+
* @permissionScope Manage Products
|
|
160
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
161
|
+
* @applicableIdentity APP
|
|
162
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.UpdateProduct
|
|
163
|
+
*/
|
|
164
|
+
export async function updateProduct(_id, product) {
|
|
165
|
+
// @ts-ignore
|
|
166
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
167
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
168
|
+
product: { ...product, id: _id },
|
|
169
|
+
});
|
|
170
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.updateProduct(payload);
|
|
171
|
+
sideEffects?.onSiteCall?.();
|
|
172
|
+
try {
|
|
173
|
+
const result = await httpClient.request(reqOpts);
|
|
174
|
+
sideEffects?.onSuccess?.(result);
|
|
175
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
const transformedError = sdkTransformError(err, {
|
|
179
|
+
spreadPathsToArguments: { product: '$[1]' },
|
|
180
|
+
explicitPathsToArguments: { 'product.id': '$[0]' },
|
|
181
|
+
singleArgumentUnchanged: false,
|
|
182
|
+
}, ['_id', 'product']);
|
|
183
|
+
sideEffects?.onError?.(err);
|
|
184
|
+
throw transformedError;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Deletes a product.
|
|
189
|
+
* @param _id - ID of the product to delete.
|
|
190
|
+
* @public
|
|
191
|
+
* @requiredField _id
|
|
192
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
193
|
+
* @permissionScope Manage Stores - all permissions
|
|
194
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
195
|
+
* @permissionScope Manage Products
|
|
196
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
197
|
+
* @applicableIdentity APP
|
|
198
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.DeleteProduct
|
|
199
|
+
*/
|
|
200
|
+
export async function deleteProduct(_id) {
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
203
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
204
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.deleteProduct(payload);
|
|
205
|
+
sideEffects?.onSiteCall?.();
|
|
206
|
+
try {
|
|
207
|
+
const result = await httpClient.request(reqOpts);
|
|
208
|
+
sideEffects?.onSuccess?.(result);
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
const transformedError = sdkTransformError(err, {
|
|
212
|
+
spreadPathsToArguments: {},
|
|
213
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
214
|
+
singleArgumentUnchanged: false,
|
|
215
|
+
}, ['_id']);
|
|
216
|
+
sideEffects?.onError?.(err);
|
|
217
|
+
throw transformedError;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Updates variants of a specified product.
|
|
222
|
+
* @param _id - ID of the product with managed variants.
|
|
223
|
+
* @param variants - Variant info to update.
|
|
224
|
+
* @public
|
|
225
|
+
* @requiredField _id
|
|
226
|
+
* @requiredField variants
|
|
227
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
228
|
+
* @permissionScope Manage Stores - all permissions
|
|
229
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
230
|
+
* @permissionScope Manage Products
|
|
231
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
232
|
+
* @applicableIdentity APP
|
|
233
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.UpdateVariants
|
|
234
|
+
*/
|
|
235
|
+
export async function updateProductVariants(_id, variants) {
|
|
236
|
+
// @ts-ignore
|
|
237
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
238
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
239
|
+
id: _id,
|
|
240
|
+
variants: variants,
|
|
241
|
+
});
|
|
242
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.updateVariants(payload);
|
|
243
|
+
sideEffects?.onSiteCall?.();
|
|
244
|
+
try {
|
|
245
|
+
const result = await httpClient.request(reqOpts);
|
|
246
|
+
sideEffects?.onSuccess?.(result);
|
|
247
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
const transformedError = sdkTransformError(err, {
|
|
251
|
+
spreadPathsToArguments: {},
|
|
252
|
+
explicitPathsToArguments: { id: '$[0]', variants: '$[1]' },
|
|
253
|
+
singleArgumentUnchanged: false,
|
|
254
|
+
}, ['_id', 'variants']);
|
|
255
|
+
sideEffects?.onError?.(err);
|
|
256
|
+
throw transformedError;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Resets the data (such as the price and the weight) of all variants for a given product to their default values.
|
|
261
|
+
* @param _id - Product ID.
|
|
262
|
+
* @public
|
|
263
|
+
* @requiredField _id
|
|
264
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
265
|
+
* @permissionScope Manage Stores - all permissions
|
|
266
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
267
|
+
* @permissionScope Manage Products
|
|
268
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
269
|
+
* @applicableIdentity APP
|
|
270
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.ResetAllVariantData
|
|
271
|
+
*/
|
|
272
|
+
export async function resetAllProductVariantData(_id) {
|
|
273
|
+
// @ts-ignore
|
|
274
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
275
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
276
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.resetAllVariantData(payload);
|
|
277
|
+
sideEffects?.onSiteCall?.();
|
|
278
|
+
try {
|
|
279
|
+
const result = await httpClient.request(reqOpts);
|
|
280
|
+
sideEffects?.onSuccess?.(result);
|
|
281
|
+
}
|
|
282
|
+
catch (err) {
|
|
283
|
+
const transformedError = sdkTransformError(err, {
|
|
284
|
+
spreadPathsToArguments: {},
|
|
285
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
286
|
+
singleArgumentUnchanged: false,
|
|
287
|
+
}, ['_id']);
|
|
288
|
+
sideEffects?.onError?.(err);
|
|
289
|
+
throw transformedError;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Adds products to a specified collection.
|
|
294
|
+
* @param _id - Collection ID.
|
|
295
|
+
* @param productIds - IDs of the products to add to the collection, separated by commas.
|
|
296
|
+
* @public
|
|
297
|
+
* @requiredField _id
|
|
298
|
+
* @requiredField productIds
|
|
299
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
300
|
+
* @permissionScope Manage Stores - all permissions
|
|
301
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
302
|
+
* @permissionScope Manage Products
|
|
303
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
304
|
+
* @applicableIdentity APP
|
|
305
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.AddProductsToCollection
|
|
306
|
+
*/
|
|
307
|
+
export async function addProductsToCollection(_id, productIds) {
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
310
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
311
|
+
id: _id,
|
|
312
|
+
productIds: productIds,
|
|
313
|
+
});
|
|
314
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.addProductsToCollection(payload);
|
|
315
|
+
sideEffects?.onSiteCall?.();
|
|
316
|
+
try {
|
|
317
|
+
const result = await httpClient.request(reqOpts);
|
|
318
|
+
sideEffects?.onSuccess?.(result);
|
|
319
|
+
}
|
|
320
|
+
catch (err) {
|
|
321
|
+
const transformedError = sdkTransformError(err, {
|
|
322
|
+
spreadPathsToArguments: {},
|
|
323
|
+
explicitPathsToArguments: { id: '$[0]', productIds: '$[1]' },
|
|
324
|
+
singleArgumentUnchanged: false,
|
|
325
|
+
}, ['_id', 'productIds']);
|
|
326
|
+
sideEffects?.onError?.(err);
|
|
327
|
+
throw transformedError;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Deletes products from a specified collection.
|
|
332
|
+
* @param _id - ID of the collection from which to remove products.
|
|
333
|
+
* @param productIds - IDs of the products to remove from the collection.
|
|
334
|
+
* @public
|
|
335
|
+
* @documentationMaturity preview
|
|
336
|
+
* @requiredField _id
|
|
337
|
+
* @requiredField productIds
|
|
338
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
339
|
+
* @permissionScope Manage Stores - all permissions
|
|
340
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
341
|
+
* @permissionScope Manage Products
|
|
342
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
343
|
+
* @applicableIdentity APP
|
|
344
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.RemoveProductsFromCollection
|
|
345
|
+
*/
|
|
346
|
+
export async function removeProductsFromCollection(_id, productIds) {
|
|
347
|
+
// @ts-ignore
|
|
348
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
349
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
350
|
+
id: _id,
|
|
351
|
+
productIds: productIds,
|
|
352
|
+
});
|
|
353
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductsFromCollection(payload);
|
|
354
|
+
sideEffects?.onSiteCall?.();
|
|
355
|
+
try {
|
|
356
|
+
const result = await httpClient.request(reqOpts);
|
|
357
|
+
sideEffects?.onSuccess?.(result);
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
const transformedError = sdkTransformError(err, {
|
|
361
|
+
spreadPathsToArguments: {},
|
|
362
|
+
explicitPathsToArguments: { id: '$[0]', productIds: '$[1]' },
|
|
363
|
+
singleArgumentUnchanged: false,
|
|
364
|
+
}, ['_id', 'productIds']);
|
|
365
|
+
sideEffects?.onError?.(err);
|
|
366
|
+
throw transformedError;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Adds media items to a specified product, either via URL or existing media ID.
|
|
371
|
+
*
|
|
372
|
+
* > **NOTE:** The URL is not validated and no event is triggered to indicate if the media was added successfully.
|
|
373
|
+
* @param _id - Product ID.
|
|
374
|
+
* @param media - Sources of media items already uploaded to the Wix site.
|
|
375
|
+
* @public
|
|
376
|
+
* @requiredField _id
|
|
377
|
+
* @requiredField media
|
|
378
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
379
|
+
* @permissionScope Manage Stores - all permissions
|
|
380
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
381
|
+
* @permissionScope Manage Products
|
|
382
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
383
|
+
* @applicableIdentity APP
|
|
384
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.AddProductMedia
|
|
385
|
+
*/
|
|
386
|
+
export async function addProductMedia(_id, media) {
|
|
387
|
+
// @ts-ignore
|
|
388
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
389
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
390
|
+
id: _id,
|
|
391
|
+
media: media,
|
|
392
|
+
});
|
|
393
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.addProductMedia(payload);
|
|
394
|
+
sideEffects?.onSiteCall?.();
|
|
395
|
+
try {
|
|
396
|
+
const result = await httpClient.request(reqOpts);
|
|
397
|
+
sideEffects?.onSuccess?.(result);
|
|
398
|
+
}
|
|
399
|
+
catch (err) {
|
|
400
|
+
const transformedError = sdkTransformError(err, {
|
|
401
|
+
spreadPathsToArguments: {},
|
|
402
|
+
explicitPathsToArguments: { id: '$[0]', media: '$[1]' },
|
|
403
|
+
singleArgumentUnchanged: false,
|
|
404
|
+
}, ['_id', 'media']);
|
|
405
|
+
sideEffects?.onError?.(err);
|
|
406
|
+
throw transformedError;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Removes specified media items from a product.
|
|
411
|
+
* Pass an empty array to remove all media items.
|
|
412
|
+
* @param _id - Product ID.
|
|
413
|
+
* @param mediaIds - List of media IDs to remove. Pass an empty array to delete all media items for the product.
|
|
414
|
+
* @public
|
|
415
|
+
* @requiredField _id
|
|
416
|
+
* @requiredField mediaIds
|
|
417
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
418
|
+
* @permissionScope Manage Stores - all permissions
|
|
419
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
420
|
+
* @permissionScope Manage Products
|
|
421
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
422
|
+
* @applicableIdentity APP
|
|
423
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.RemoveProductMedia
|
|
424
|
+
*/
|
|
425
|
+
export async function removeProductMedia(_id, mediaIds) {
|
|
426
|
+
// @ts-ignore
|
|
427
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
428
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
429
|
+
id: _id,
|
|
430
|
+
mediaIds: mediaIds,
|
|
431
|
+
});
|
|
432
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductMedia(payload);
|
|
433
|
+
sideEffects?.onSiteCall?.();
|
|
434
|
+
try {
|
|
435
|
+
const result = await httpClient.request(reqOpts);
|
|
436
|
+
sideEffects?.onSuccess?.(result);
|
|
437
|
+
}
|
|
438
|
+
catch (err) {
|
|
439
|
+
const transformedError = sdkTransformError(err, {
|
|
440
|
+
spreadPathsToArguments: {},
|
|
441
|
+
explicitPathsToArguments: { id: '$[0]', mediaIds: '$[1]' },
|
|
442
|
+
singleArgumentUnchanged: false,
|
|
443
|
+
}, ['_id', 'mediaIds']);
|
|
444
|
+
sideEffects?.onError?.(err);
|
|
445
|
+
throw transformedError;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Links media items that are already associated with a specific product to a choice within the same product.
|
|
450
|
+
*
|
|
451
|
+
* Media items can only be set for choices within one option at a time - e.g., if you set media items for some or all of the choices within the Colors option (blue, green, and red), you won't be able to also assign media items to choices within the Size option (S, M, and L).
|
|
452
|
+
*
|
|
453
|
+
* To remove all existing media items, call the [Remove Product Media From Choices](https://dev.wix.com/api/rest/wix-stores/catalog/products/remove-product-media-from-choices) endpoint.
|
|
454
|
+
* @param _id - Product ID.
|
|
455
|
+
* @param media - Product media items and the choices to add the media to.
|
|
456
|
+
* @public
|
|
457
|
+
* @documentationMaturity preview
|
|
458
|
+
* @requiredField _id
|
|
459
|
+
* @requiredField media
|
|
460
|
+
* @requiredField media.choice
|
|
461
|
+
* @requiredField media.option
|
|
462
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
463
|
+
* @permissionScope Manage Stores - all permissions
|
|
464
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
465
|
+
* @permissionScope Manage Products
|
|
466
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
467
|
+
* @applicableIdentity APP
|
|
468
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.AddProductMediaToChoices
|
|
469
|
+
*/
|
|
470
|
+
export async function addProductMediaToChoices(_id, media) {
|
|
471
|
+
// @ts-ignore
|
|
472
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
473
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
474
|
+
id: _id,
|
|
475
|
+
media: media,
|
|
476
|
+
});
|
|
477
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.addProductMediaToChoices(payload);
|
|
478
|
+
sideEffects?.onSiteCall?.();
|
|
479
|
+
try {
|
|
480
|
+
const result = await httpClient.request(reqOpts);
|
|
481
|
+
sideEffects?.onSuccess?.(result);
|
|
482
|
+
}
|
|
483
|
+
catch (err) {
|
|
484
|
+
const transformedError = sdkTransformError(err, {
|
|
485
|
+
spreadPathsToArguments: {},
|
|
486
|
+
explicitPathsToArguments: { id: '$[0]', media: '$[1]' },
|
|
487
|
+
singleArgumentUnchanged: false,
|
|
488
|
+
}, ['_id', 'media']);
|
|
489
|
+
sideEffects?.onError?.(err);
|
|
490
|
+
throw transformedError;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Removes media items from all or some of a product's choices.
|
|
495
|
+
* (Media items can only be set for choices within one option at a time - e.g., if you set media items for some or all of the choices within the Colors option (blue, green, and red), you won't be able to also assign media items to choices within the Size option (S, M, and L).)
|
|
496
|
+
* @param _id - Product ID from whose choices to remove media items.
|
|
497
|
+
* @param media - Media to remove from choices. If an empty array is passed, all media will be removed from all choices for the given product.
|
|
498
|
+
* @public
|
|
499
|
+
* @documentationMaturity preview
|
|
500
|
+
* @requiredField _id
|
|
501
|
+
* @requiredField media
|
|
502
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
503
|
+
* @permissionScope Manage Stores - all permissions
|
|
504
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
505
|
+
* @permissionScope Manage Products
|
|
506
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
507
|
+
* @applicableIdentity APP
|
|
508
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.RemoveProductMediaFromChoices
|
|
509
|
+
*/
|
|
510
|
+
export async function removeProductMediaFromChoices(_id, media) {
|
|
511
|
+
// @ts-ignore
|
|
512
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
513
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
514
|
+
id: _id,
|
|
515
|
+
media: media,
|
|
516
|
+
});
|
|
517
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeProductMediaFromChoices(payload);
|
|
518
|
+
sideEffects?.onSiteCall?.();
|
|
519
|
+
try {
|
|
520
|
+
const result = await httpClient.request(reqOpts);
|
|
521
|
+
sideEffects?.onSuccess?.(result);
|
|
522
|
+
}
|
|
523
|
+
catch (err) {
|
|
524
|
+
const transformedError = sdkTransformError(err, {
|
|
525
|
+
spreadPathsToArguments: {},
|
|
526
|
+
explicitPathsToArguments: { id: '$[0]', media: '$[1]' },
|
|
527
|
+
singleArgumentUnchanged: false,
|
|
528
|
+
}, ['_id', 'media']);
|
|
529
|
+
sideEffects?.onError?.(err);
|
|
530
|
+
throw transformedError;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Delete all options from a specific product. Only available when [variant management](https://support.wix.com/en/article/wix-stores-adding-and-customizing-product-options#setting-different-prices-for-variants) is disabled.
|
|
535
|
+
* @param _id - ID of the product with options to delete.
|
|
536
|
+
* @public
|
|
537
|
+
* @documentationMaturity preview
|
|
538
|
+
* @requiredField _id
|
|
539
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
540
|
+
* @permissionScope Manage Stores - all permissions
|
|
541
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
542
|
+
* @permissionScope Manage Products
|
|
543
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
544
|
+
* @applicableIdentity APP
|
|
545
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.DeleteProductOptions
|
|
546
|
+
*/
|
|
547
|
+
export async function deleteProductOptions(_id) {
|
|
548
|
+
// @ts-ignore
|
|
549
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
550
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
551
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.deleteProductOptions(payload);
|
|
552
|
+
sideEffects?.onSiteCall?.();
|
|
553
|
+
try {
|
|
554
|
+
const result = await httpClient.request(reqOpts);
|
|
555
|
+
sideEffects?.onSuccess?.(result);
|
|
556
|
+
}
|
|
557
|
+
catch (err) {
|
|
558
|
+
const transformedError = sdkTransformError(err, {
|
|
559
|
+
spreadPathsToArguments: {},
|
|
560
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
561
|
+
singleArgumentUnchanged: false,
|
|
562
|
+
}, ['_id']);
|
|
563
|
+
sideEffects?.onError?.(err);
|
|
564
|
+
throw transformedError;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Deletes a product's brand.
|
|
569
|
+
* @param _id - Product ID.
|
|
570
|
+
* @public
|
|
571
|
+
* @requiredField _id
|
|
572
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
573
|
+
* @permissionScope Manage Stores - all permissions
|
|
574
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
575
|
+
* @permissionScope Manage Products
|
|
576
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
577
|
+
* @applicableIdentity APP
|
|
578
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.RemoveBrand
|
|
579
|
+
*/
|
|
580
|
+
export async function removeBrand(_id) {
|
|
581
|
+
// @ts-ignore
|
|
582
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
583
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
584
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeBrand(payload);
|
|
585
|
+
sideEffects?.onSiteCall?.();
|
|
586
|
+
try {
|
|
587
|
+
const result = await httpClient.request(reqOpts);
|
|
588
|
+
sideEffects?.onSuccess?.(result);
|
|
589
|
+
}
|
|
590
|
+
catch (err) {
|
|
591
|
+
const transformedError = sdkTransformError(err, {
|
|
592
|
+
spreadPathsToArguments: {},
|
|
593
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
594
|
+
singleArgumentUnchanged: false,
|
|
595
|
+
}, ['_id']);
|
|
596
|
+
sideEffects?.onError?.(err);
|
|
597
|
+
throw transformedError;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Creates a new collection.
|
|
602
|
+
* @param collection - Collection info.
|
|
603
|
+
* @public
|
|
604
|
+
* @requiredField collection
|
|
605
|
+
* @requiredField collection.name
|
|
606
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
607
|
+
* @permissionScope Manage Stores - all permissions
|
|
608
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
609
|
+
* @permissionScope Manage Products
|
|
610
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
611
|
+
* @applicableIdentity APP
|
|
612
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.CreateCollection
|
|
613
|
+
*/
|
|
614
|
+
export async function createCollection(collection) {
|
|
615
|
+
// @ts-ignore
|
|
616
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
617
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
618
|
+
collection: collection,
|
|
619
|
+
});
|
|
620
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.createCollection(payload);
|
|
621
|
+
sideEffects?.onSiteCall?.();
|
|
622
|
+
try {
|
|
623
|
+
const result = await httpClient.request(reqOpts);
|
|
624
|
+
sideEffects?.onSuccess?.(result);
|
|
625
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
626
|
+
}
|
|
627
|
+
catch (err) {
|
|
628
|
+
const transformedError = sdkTransformError(err, {
|
|
629
|
+
spreadPathsToArguments: {},
|
|
630
|
+
explicitPathsToArguments: { collection: '$[0]' },
|
|
631
|
+
singleArgumentUnchanged: false,
|
|
632
|
+
}, ['collection']);
|
|
633
|
+
sideEffects?.onError?.(err);
|
|
634
|
+
throw transformedError;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Updates specified properties of a collection. To add products to a collection, call the [addProductsToCollection](#addproductstocollection) function.
|
|
639
|
+
* @param _id - Collection ID (generated automatically by the catalog).
|
|
640
|
+
* @public
|
|
641
|
+
* @documentationMaturity preview
|
|
642
|
+
* @requiredField _id
|
|
643
|
+
* @requiredField collection
|
|
644
|
+
* @param collection - Collection info to update.
|
|
645
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
646
|
+
* @permissionScope Manage Stores - all permissions
|
|
647
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
648
|
+
* @permissionScope Manage Products
|
|
649
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
650
|
+
* @applicableIdentity APP
|
|
651
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.UpdateCollection
|
|
652
|
+
*/
|
|
653
|
+
export async function updateCollection(_id, collection) {
|
|
654
|
+
// @ts-ignore
|
|
655
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
656
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
657
|
+
collection: { ...collection, id: _id },
|
|
658
|
+
});
|
|
659
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.updateCollection(payload);
|
|
660
|
+
sideEffects?.onSiteCall?.();
|
|
661
|
+
try {
|
|
662
|
+
const result = await httpClient.request(reqOpts);
|
|
663
|
+
sideEffects?.onSuccess?.(result);
|
|
664
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
665
|
+
}
|
|
666
|
+
catch (err) {
|
|
667
|
+
const transformedError = sdkTransformError(err, {
|
|
668
|
+
spreadPathsToArguments: { collection: '$[1]' },
|
|
669
|
+
explicitPathsToArguments: { 'collection.id': '$[0]' },
|
|
670
|
+
singleArgumentUnchanged: false,
|
|
671
|
+
}, ['_id', 'collection']);
|
|
672
|
+
sideEffects?.onError?.(err);
|
|
673
|
+
throw transformedError;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Deletes a collection.
|
|
678
|
+
* @public
|
|
679
|
+
* @documentationMaturity preview
|
|
680
|
+
* @requiredField _id
|
|
681
|
+
* @param _id - ID of the collection to delete.
|
|
682
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
683
|
+
* @permissionScope Manage Stores - all permissions
|
|
684
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
685
|
+
* @permissionScope Manage Products
|
|
686
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
687
|
+
* @applicableIdentity APP
|
|
688
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.DeleteCollection
|
|
689
|
+
*/
|
|
690
|
+
export async function deleteCollection(_id) {
|
|
691
|
+
// @ts-ignore
|
|
692
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
693
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
694
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.deleteCollection(payload);
|
|
695
|
+
sideEffects?.onSiteCall?.();
|
|
696
|
+
try {
|
|
697
|
+
const result = await httpClient.request(reqOpts);
|
|
698
|
+
sideEffects?.onSuccess?.(result);
|
|
699
|
+
}
|
|
700
|
+
catch (err) {
|
|
701
|
+
const transformedError = sdkTransformError(err, {
|
|
702
|
+
spreadPathsToArguments: {},
|
|
703
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
704
|
+
singleArgumentUnchanged: false,
|
|
705
|
+
}, ['_id']);
|
|
706
|
+
sideEffects?.onError?.(err);
|
|
707
|
+
throw transformedError;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Deletes a product's ribbon.
|
|
712
|
+
* @param _id - Product ID.
|
|
713
|
+
* @public
|
|
714
|
+
* @requiredField _id
|
|
715
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
716
|
+
* @permissionScope Manage Stores - all permissions
|
|
717
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
718
|
+
* @permissionScope Manage Products
|
|
719
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
720
|
+
* @applicableIdentity APP
|
|
721
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.RemoveRibbon
|
|
722
|
+
*/
|
|
723
|
+
export async function removeRibbon(_id) {
|
|
724
|
+
// @ts-ignore
|
|
725
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
726
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
727
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.removeRibbon(payload);
|
|
728
|
+
sideEffects?.onSiteCall?.();
|
|
729
|
+
try {
|
|
730
|
+
const result = await httpClient.request(reqOpts);
|
|
731
|
+
sideEffects?.onSuccess?.(result);
|
|
732
|
+
}
|
|
733
|
+
catch (err) {
|
|
734
|
+
const transformedError = sdkTransformError(err, {
|
|
735
|
+
spreadPathsToArguments: {},
|
|
736
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
737
|
+
singleArgumentUnchanged: false,
|
|
738
|
+
}, ['_id']);
|
|
739
|
+
sideEffects?.onError?.(err);
|
|
740
|
+
throw transformedError;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Updates a specified property for up to 100 products at a time.
|
|
745
|
+
* @param ids - Product IDs.
|
|
746
|
+
* @param set - Field to update.
|
|
747
|
+
* @public
|
|
748
|
+
* @documentationMaturity preview
|
|
749
|
+
* @requiredField ids
|
|
750
|
+
* @requiredField set
|
|
751
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
752
|
+
* @permissionScope Manage Stores - all permissions
|
|
753
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
754
|
+
* @permissionScope Manage Products
|
|
755
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
756
|
+
* @applicableIdentity APP
|
|
757
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.BulkUpdateProducts
|
|
758
|
+
*/
|
|
759
|
+
export async function bulkUpdateProductsProperty(ids, set) {
|
|
760
|
+
// @ts-ignore
|
|
761
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
762
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ ids: ids, set: set });
|
|
763
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.bulkUpdateProducts(payload);
|
|
764
|
+
sideEffects?.onSiteCall?.();
|
|
765
|
+
try {
|
|
766
|
+
const result = await httpClient.request(reqOpts);
|
|
767
|
+
sideEffects?.onSuccess?.(result);
|
|
768
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
769
|
+
}
|
|
770
|
+
catch (err) {
|
|
771
|
+
const transformedError = sdkTransformError(err, {
|
|
772
|
+
spreadPathsToArguments: {},
|
|
773
|
+
explicitPathsToArguments: { ids: '$[0]', set: '$[1]' },
|
|
774
|
+
singleArgumentUnchanged: false,
|
|
775
|
+
}, ['ids', 'set']);
|
|
776
|
+
sideEffects?.onError?.(err);
|
|
777
|
+
throw transformedError;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Adjusts a specified numerical property for up to 100 products at a time.
|
|
782
|
+
* The property can be increased or decreased either by percentage or amount.
|
|
783
|
+
* @param adjust - Numerical property to adjust.
|
|
784
|
+
* @param ids - Product IDs.
|
|
785
|
+
* @public
|
|
786
|
+
* @documentationMaturity preview
|
|
787
|
+
* @requiredField adjust
|
|
788
|
+
* @requiredField ids
|
|
789
|
+
* @permissionId WIX_STORES.MODIFY_PRODUCTS
|
|
790
|
+
* @permissionScope Manage Stores - all permissions
|
|
791
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
792
|
+
* @permissionScope Manage Products
|
|
793
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
794
|
+
* @applicableIdentity APP
|
|
795
|
+
* @fqn wix.catalog.api.v1.CatalogWriteApi.BulkAdjustProductProperties
|
|
796
|
+
*/
|
|
797
|
+
export async function bulkAdjustProductProperty(adjust, ids) {
|
|
798
|
+
// @ts-ignore
|
|
799
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
800
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
801
|
+
adjust: adjust,
|
|
802
|
+
ids: ids,
|
|
803
|
+
});
|
|
804
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.bulkAdjustProductProperties(payload);
|
|
805
|
+
sideEffects?.onSiteCall?.();
|
|
806
|
+
try {
|
|
807
|
+
const result = await httpClient.request(reqOpts);
|
|
808
|
+
sideEffects?.onSuccess?.(result);
|
|
809
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
810
|
+
}
|
|
811
|
+
catch (err) {
|
|
812
|
+
const transformedError = sdkTransformError(err, {
|
|
813
|
+
spreadPathsToArguments: {},
|
|
814
|
+
explicitPathsToArguments: { adjust: '$[0]', ids: '$[1]' },
|
|
815
|
+
singleArgumentUnchanged: false,
|
|
816
|
+
}, ['adjust', 'ids']);
|
|
817
|
+
sideEffects?.onError?.(err);
|
|
818
|
+
throw transformedError;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Returns a list of up to 100 products, given the provided paging, sorting and filtering.
|
|
823
|
+
* @public
|
|
824
|
+
* @permissionScope Manage Stores - all permissions
|
|
825
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
826
|
+
* @permissionScope Manage Products
|
|
827
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
828
|
+
* @permissionScope Read Stores - all read permissions
|
|
829
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.READ-STORES
|
|
830
|
+
* @permissionScope Read Products
|
|
831
|
+
* @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
|
|
832
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
833
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
834
|
+
* @permissionScope Manage Orders
|
|
835
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
|
|
836
|
+
* @permissionId WIX_STORES.READ_PRODUCTS
|
|
837
|
+
* @applicableIdentity APP
|
|
838
|
+
* @applicableIdentity VISITOR
|
|
839
|
+
* @fqn wix.catalog.api.v1.CatalogReadApi.QueryProductsPlatformized
|
|
840
|
+
*/
|
|
841
|
+
export function queryProducts() {
|
|
842
|
+
// @ts-ignore
|
|
843
|
+
const { httpClient, sideEffects } = arguments[0];
|
|
844
|
+
return queryBuilder({
|
|
845
|
+
func: async (payload) => {
|
|
846
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.queryProductsPlatformized(payload);
|
|
847
|
+
sideEffects?.onSiteCall?.();
|
|
848
|
+
try {
|
|
849
|
+
const result = await httpClient.request(reqOpts);
|
|
850
|
+
sideEffects?.onSuccess?.(result);
|
|
851
|
+
return result;
|
|
852
|
+
}
|
|
853
|
+
catch (err) {
|
|
854
|
+
sideEffects?.onError?.(err);
|
|
855
|
+
throw err;
|
|
856
|
+
}
|
|
857
|
+
},
|
|
858
|
+
requestTransformer: (query) => {
|
|
859
|
+
const args = [query, {}];
|
|
860
|
+
return renameKeysFromSDKRequestToRESTRequest({
|
|
861
|
+
...args?.[1],
|
|
862
|
+
query: args?.[0],
|
|
863
|
+
});
|
|
864
|
+
},
|
|
865
|
+
responseTransformer: ({ data, }) => {
|
|
866
|
+
const transformedData = renameKeysFromRESTResponseToSDKResponse(data);
|
|
867
|
+
return {
|
|
868
|
+
items: transformedData?.products,
|
|
869
|
+
pagingMetadata: transformedData?.metadata,
|
|
870
|
+
};
|
|
871
|
+
},
|
|
872
|
+
errorTransformer: (err) => {
|
|
873
|
+
const transformedError = sdkTransformError(err, {
|
|
874
|
+
spreadPathsToArguments: {},
|
|
875
|
+
explicitPathsToArguments: { query: '$[0]' },
|
|
876
|
+
singleArgumentUnchanged: false,
|
|
877
|
+
});
|
|
878
|
+
throw transformedError;
|
|
879
|
+
},
|
|
880
|
+
pagingMethod: 'OFFSET',
|
|
881
|
+
transformationPaths: {},
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Retrieves a product with the provided ID.
|
|
886
|
+
* @param _id - Requested product ID.
|
|
887
|
+
* @public
|
|
888
|
+
* @requiredField _id
|
|
889
|
+
* @permissionId WIX_STORES.READ_PRODUCTS
|
|
890
|
+
* @permissionScope Manage Stores - all permissions
|
|
891
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
892
|
+
* @permissionScope Manage Products
|
|
893
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
894
|
+
* @permissionScope Read Stores - all read permissions
|
|
895
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.READ-STORES
|
|
896
|
+
* @permissionScope Read Products
|
|
897
|
+
* @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
|
|
898
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
899
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
900
|
+
* @permissionScope Manage Orders
|
|
901
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
|
|
902
|
+
* @applicableIdentity APP
|
|
903
|
+
* @applicableIdentity VISITOR
|
|
904
|
+
* @fqn wix.catalog.api.v1.CatalogReadApi.GetProduct
|
|
905
|
+
*/
|
|
906
|
+
export async function getProduct(_id, options) {
|
|
907
|
+
// @ts-ignore
|
|
908
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
909
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
910
|
+
id: _id,
|
|
911
|
+
includeMerchantSpecificData: options?.includeMerchantSpecificData,
|
|
912
|
+
});
|
|
913
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.getProduct(payload);
|
|
914
|
+
sideEffects?.onSiteCall?.();
|
|
915
|
+
try {
|
|
916
|
+
const result = await httpClient.request(reqOpts);
|
|
917
|
+
sideEffects?.onSuccess?.(result);
|
|
918
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
919
|
+
}
|
|
920
|
+
catch (err) {
|
|
921
|
+
const transformedError = sdkTransformError(err, {
|
|
922
|
+
spreadPathsToArguments: {},
|
|
923
|
+
explicitPathsToArguments: {
|
|
924
|
+
id: '$[0]',
|
|
925
|
+
includeMerchantSpecificData: '$[1].includeMerchantSpecificData',
|
|
926
|
+
},
|
|
927
|
+
singleArgumentUnchanged: false,
|
|
928
|
+
}, ['_id', 'options']);
|
|
929
|
+
sideEffects?.onError?.(err);
|
|
930
|
+
throw transformedError;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Retrieves a collection with the provided slug.
|
|
935
|
+
* @param slug - Slug of the collection to retrieve.
|
|
936
|
+
* @public
|
|
937
|
+
* @requiredField slug
|
|
938
|
+
* @permissionId WIX_STORES.READ_PRODUCTS
|
|
939
|
+
* @permissionScope Manage Stores - all permissions
|
|
940
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
941
|
+
* @permissionScope Manage Products
|
|
942
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
943
|
+
* @permissionScope Read Stores - all read permissions
|
|
944
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.READ-STORES
|
|
945
|
+
* @permissionScope Read Products
|
|
946
|
+
* @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
|
|
947
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
948
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
949
|
+
* @permissionScope Manage Orders
|
|
950
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
|
|
951
|
+
* @applicableIdentity APP
|
|
952
|
+
* @applicableIdentity VISITOR
|
|
953
|
+
* @fqn wix.catalog.api.v1.CatalogReadApi.GetCollectionBySlug
|
|
954
|
+
*/
|
|
955
|
+
export async function getCollectionBySlug(slug) {
|
|
956
|
+
// @ts-ignore
|
|
957
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
958
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ slug: slug });
|
|
959
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.getCollectionBySlug(payload);
|
|
960
|
+
sideEffects?.onSiteCall?.();
|
|
961
|
+
try {
|
|
962
|
+
const result = await httpClient.request(reqOpts);
|
|
963
|
+
sideEffects?.onSuccess?.(result);
|
|
964
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
965
|
+
}
|
|
966
|
+
catch (err) {
|
|
967
|
+
const transformedError = sdkTransformError(err, {
|
|
968
|
+
spreadPathsToArguments: {},
|
|
969
|
+
explicitPathsToArguments: { slug: '$[0]' },
|
|
970
|
+
singleArgumentUnchanged: false,
|
|
971
|
+
}, ['slug']);
|
|
972
|
+
sideEffects?.onError?.(err);
|
|
973
|
+
throw transformedError;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Gets the availability of relevant product variants based on the product ID and selections provided. See [Use Cases](https://dev.wix.com/api/rest/wix-stores/catalog/use-cases) for an example.
|
|
978
|
+
* @param _id - Requested product ID.
|
|
979
|
+
* @param options - Array containing the selected options. For example, `["color": "Blue", "size": "Large"]`.
|
|
980
|
+
* @public
|
|
981
|
+
* @requiredField _id
|
|
982
|
+
* @requiredField options
|
|
983
|
+
* @permissionId WIX_STORES.READ_PRODUCTS
|
|
984
|
+
* @permissionScope Manage Stores - all permissions
|
|
985
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
986
|
+
* @permissionScope Manage Products
|
|
987
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
988
|
+
* @permissionScope Read Stores - all read permissions
|
|
989
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.READ-STORES
|
|
990
|
+
* @permissionScope Read Products
|
|
991
|
+
* @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
|
|
992
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
993
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
994
|
+
* @permissionScope Manage Orders
|
|
995
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
|
|
996
|
+
* @applicableIdentity APP
|
|
997
|
+
* @applicableIdentity VISITOR
|
|
998
|
+
* @fqn wix.catalog.api.v1.CatalogReadApi.ProductOptionsAvailability
|
|
999
|
+
*/
|
|
1000
|
+
export async function getProductOptionsAvailability(_id, options) {
|
|
1001
|
+
// @ts-ignore
|
|
1002
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
1003
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
1004
|
+
id: _id,
|
|
1005
|
+
options: options,
|
|
1006
|
+
});
|
|
1007
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.productOptionsAvailability(payload);
|
|
1008
|
+
sideEffects?.onSiteCall?.();
|
|
1009
|
+
try {
|
|
1010
|
+
const result = await httpClient.request(reqOpts);
|
|
1011
|
+
sideEffects?.onSuccess?.(result);
|
|
1012
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
1013
|
+
}
|
|
1014
|
+
catch (err) {
|
|
1015
|
+
const transformedError = sdkTransformError(err, {
|
|
1016
|
+
spreadPathsToArguments: {},
|
|
1017
|
+
explicitPathsToArguments: { id: '$[0]', options: '$[1]' },
|
|
1018
|
+
singleArgumentUnchanged: false,
|
|
1019
|
+
}, ['_id', 'options']);
|
|
1020
|
+
sideEffects?.onError?.(err);
|
|
1021
|
+
throw transformedError;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Retrieves product variants, based on either choices (option-choice key-value pairs) or variant IDs.
|
|
1026
|
+
* See [Stores Pagination](https://dev.wix.com/api/rest/wix-stores/pagination) for more information.
|
|
1027
|
+
* @param _id - Requested product ID.
|
|
1028
|
+
* @public
|
|
1029
|
+
* @requiredField _id
|
|
1030
|
+
* @permissionId WIX_STORES.READ_PRODUCTS
|
|
1031
|
+
* @permissionScope Manage Stores - all permissions
|
|
1032
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
1033
|
+
* @permissionScope Manage Products
|
|
1034
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
1035
|
+
* @permissionScope Read Stores - all read permissions
|
|
1036
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.READ-STORES
|
|
1037
|
+
* @permissionScope Read Products
|
|
1038
|
+
* @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
|
|
1039
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
1040
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
1041
|
+
* @permissionScope Manage Orders
|
|
1042
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
|
|
1043
|
+
* @applicableIdentity APP
|
|
1044
|
+
* @applicableIdentity VISITOR
|
|
1045
|
+
* @fqn wix.catalog.api.v1.CatalogReadApi.QueryProductVariants
|
|
1046
|
+
*/
|
|
1047
|
+
export async function queryProductVariants(_id, options) {
|
|
1048
|
+
// @ts-ignore
|
|
1049
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
1050
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
1051
|
+
id: _id,
|
|
1052
|
+
choices: options?.choices,
|
|
1053
|
+
variantIds: options?.variantIds,
|
|
1054
|
+
paging: options?.paging,
|
|
1055
|
+
includeMerchantSpecificData: options?.includeMerchantSpecificData,
|
|
1056
|
+
});
|
|
1057
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.queryProductVariants(payload);
|
|
1058
|
+
sideEffects?.onSiteCall?.();
|
|
1059
|
+
try {
|
|
1060
|
+
const result = await httpClient.request(reqOpts);
|
|
1061
|
+
sideEffects?.onSuccess?.(result);
|
|
1062
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
1063
|
+
}
|
|
1064
|
+
catch (err) {
|
|
1065
|
+
const transformedError = sdkTransformError(err, {
|
|
1066
|
+
spreadPathsToArguments: {},
|
|
1067
|
+
explicitPathsToArguments: {
|
|
1068
|
+
id: '$[0]',
|
|
1069
|
+
choices: '$[1].choices',
|
|
1070
|
+
variantIds: '$[1].variantIds',
|
|
1071
|
+
paging: '$[1].paging',
|
|
1072
|
+
includeMerchantSpecificData: '$[1].includeMerchantSpecificData',
|
|
1073
|
+
},
|
|
1074
|
+
singleArgumentUnchanged: false,
|
|
1075
|
+
}, ['_id', 'options']);
|
|
1076
|
+
sideEffects?.onError?.(err);
|
|
1077
|
+
throw transformedError;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Retrieves up to 100 store variants, given the provided paging, filtering, and sorting.
|
|
1082
|
+
* @param query - Query options.
|
|
1083
|
+
* @public
|
|
1084
|
+
* @requiredField query
|
|
1085
|
+
* @permissionId WIX_STORES.READ_PRODUCTS
|
|
1086
|
+
* @permissionScope Manage Stores - all permissions
|
|
1087
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
1088
|
+
* @permissionScope Manage Products
|
|
1089
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
1090
|
+
* @permissionScope Read Stores - all read permissions
|
|
1091
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.READ-STORES
|
|
1092
|
+
* @permissionScope Read Products
|
|
1093
|
+
* @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
|
|
1094
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
1095
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
1096
|
+
* @permissionScope Manage Orders
|
|
1097
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
|
|
1098
|
+
* @applicableIdentity APP
|
|
1099
|
+
* @applicableIdentity VISITOR
|
|
1100
|
+
* @fqn wix.catalog.api.v1.CatalogReadApi.QueryStoreVariants
|
|
1101
|
+
*/
|
|
1102
|
+
export async function queryStoreVariants(query) {
|
|
1103
|
+
// @ts-ignore
|
|
1104
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
1105
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ query: query });
|
|
1106
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.queryStoreVariants(payload);
|
|
1107
|
+
sideEffects?.onSiteCall?.();
|
|
1108
|
+
try {
|
|
1109
|
+
const result = await httpClient.request(reqOpts);
|
|
1110
|
+
sideEffects?.onSuccess?.(result);
|
|
1111
|
+
return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
|
|
1112
|
+
{
|
|
1113
|
+
transformFn: transformRESTImageToSDKImage,
|
|
1114
|
+
paths: [{ path: 'variants.media.image' }],
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
transformFn: transformRESTVideoV2ToSDKVideoV2,
|
|
1118
|
+
paths: [{ path: 'variants.media.video' }],
|
|
1119
|
+
},
|
|
1120
|
+
]));
|
|
1121
|
+
}
|
|
1122
|
+
catch (err) {
|
|
1123
|
+
const transformedError = sdkTransformError(err, {
|
|
1124
|
+
spreadPathsToArguments: {},
|
|
1125
|
+
explicitPathsToArguments: { query: '$[0]' },
|
|
1126
|
+
singleArgumentUnchanged: false,
|
|
1127
|
+
}, ['query']);
|
|
1128
|
+
sideEffects?.onError?.(err);
|
|
1129
|
+
throw transformedError;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Retrieves a store variant with the provided ID.
|
|
1134
|
+
* @param _id - Store variant ID. Comprised of the `productId` and the `variantId`, separated by a hyphen. For example, `{productId}-{variantId}`.
|
|
1135
|
+
* @public
|
|
1136
|
+
* @requiredField _id
|
|
1137
|
+
* @permissionId WIX_STORES.READ_PRODUCTS
|
|
1138
|
+
* @permissionScope Manage Stores - all permissions
|
|
1139
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.MANAGE-STORES
|
|
1140
|
+
* @permissionScope Manage Products
|
|
1141
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-PRODUCTS
|
|
1142
|
+
* @permissionScope Read Stores - all read permissions
|
|
1143
|
+
* @permissionScopeId SCOPE.DC-STORES-MEGA.READ-STORES
|
|
1144
|
+
* @permissionScope Read Products
|
|
1145
|
+
* @permissionScopeId SCOPE.DC-STORES.READ-PRODUCTS
|
|
1146
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
1147
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
1148
|
+
* @permissionScope Manage Orders
|
|
1149
|
+
* @permissionScopeId SCOPE.DC-STORES.MANAGE-ORDERS
|
|
1150
|
+
* @applicableIdentity APP
|
|
1151
|
+
* @applicableIdentity VISITOR
|
|
1152
|
+
* @fqn wix.catalog.api.v1.CatalogReadApi.GetStoreVariant
|
|
1153
|
+
*/
|
|
1154
|
+
export async function getStoreVariant(_id) {
|
|
1155
|
+
// @ts-ignore
|
|
1156
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
1157
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
1158
|
+
const reqOpts = ambassadorWixStoresCatalogV1Product.getStoreVariant(payload);
|
|
1159
|
+
sideEffects?.onSiteCall?.();
|
|
1160
|
+
try {
|
|
1161
|
+
const result = await httpClient.request(reqOpts);
|
|
1162
|
+
sideEffects?.onSuccess?.(result);
|
|
1163
|
+
return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
|
|
1164
|
+
{
|
|
1165
|
+
transformFn: transformRESTImageToSDKImage,
|
|
1166
|
+
paths: [{ path: 'variant.media.image' }],
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
transformFn: transformRESTVideoV2ToSDKVideoV2,
|
|
1170
|
+
paths: [{ path: 'variant.media.video' }],
|
|
1171
|
+
},
|
|
1172
|
+
]));
|
|
1173
|
+
}
|
|
1174
|
+
catch (err) {
|
|
1175
|
+
const transformedError = sdkTransformError(err, {
|
|
1176
|
+
spreadPathsToArguments: {},
|
|
1177
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
1178
|
+
singleArgumentUnchanged: false,
|
|
1179
|
+
}, ['_id']);
|
|
1180
|
+
sideEffects?.onError?.(err);
|
|
1181
|
+
throw transformedError;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
//# sourceMappingURL=stores-catalog-v1-product-products.universal.js.map
|