idosell 0.1.5 → 0.1.6
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/dist/gates.def.js +7 -1
- package/dist/helpers.js +6 -2
- package/dist/methods/getProductsAuctions.js +1 -0
- package/dist/methods/putProducts copy.js +20 -0
- package/dist/methods/putProducts.js +8 -3
- package/package.json +1 -1
- package/tests/getProductsAuctions.test.js +5 -0
- package/tests/putProducts.test.js +23 -3
- package/tests/putProductsImages.test.js +1 -1
- /package/{readme.md → README.md} +0 -0
package/dist/gates.def.js
CHANGED
|
@@ -1569,6 +1569,7 @@
|
|
|
1569
1569
|
* @property {(resultsPage: Integer) => GetProductsAuctionsRequest} resultsPage Page with results number. Numeration starts from 0
|
|
1570
1570
|
* @property {(resultsLimit: Integer) => GetProductsAuctionsRequest} resultsLimit Number of results on page. Value from 1 to 100
|
|
1571
1571
|
* @property {(ids: Array<Integer>) => GetProductsAuctionsRequest} ids Define products by passing array of values
|
|
1572
|
+
* @property {() => GetProductsAuctionsRequest} fromAllegro Get auction data on products
|
|
1572
1573
|
* @property {(page: Integer, limit: Integer) => GetProductsAuctionsRequest} page Define page number and maximum results per page
|
|
1573
1574
|
* @property {() => Integer} count Returns total numer of results
|
|
1574
1575
|
* @property {function} exec Excecute request
|
|
@@ -1808,7 +1809,7 @@
|
|
|
1808
1809
|
* @property {(groups: Array<Object>) => PutProductsGroupsOrderRequest} groups
|
|
1809
1810
|
* @property {(productsInOrder: Array<Object>) => PutProductsGroupsOrderRequest} productsInOrder
|
|
1810
1811
|
* @property {function} append Append current data to array and start modifying next row
|
|
1811
|
-
* @property {() => PutProductsGroupsOrderRequest} productIdsInOrder Defines order of products within group by automatically setting proprities in order of appearance
|
|
1812
|
+
* @property {(Array<Integer>) => PutProductsGroupsOrderRequest} productIdsInOrder Defines order of products within group by automatically setting proprities in order of appearance
|
|
1812
1813
|
* @property {function} exec Excecute request
|
|
1813
1814
|
*/
|
|
1814
1815
|
|
|
@@ -2363,6 +2364,11 @@
|
|
|
2363
2364
|
* @property {(productDimensions: Object) => PutProductsRequest} productDimensions Dimensions and overall weight
|
|
2364
2365
|
* @property {function} append Append current data to array and start modifying next row
|
|
2365
2366
|
* @property {(text: String, type: "name"|"short"|"long"|"metatitle"|"metadescription"|"metakeywords"|"acutionname"|"auctiondescription", language: String, shopId: Integer) => PutProductsRequest} setText Set various types of names or descriptions to the product
|
|
2367
|
+
* @property {() => PutProductsRequest} editMode Set edit mode - disables adding new product
|
|
2368
|
+
* @property {() => PutProductsRequest} addMode Set add mode - Api is allowed to create new products
|
|
2369
|
+
* @property {(value: Float, type: 'retail'|'wholesale'|'pos'|'minimal'|'StrikethroughRetail'|'strikethroughWholesale'|'suggested') => PutProductsRequest} addPrice Increases product price by amount
|
|
2370
|
+
* @property {(value: Float, type: 'retail'|'wholesale'|'pos'|'minimal'|'StrikethroughRetail'|'strikethroughWholesale'|'suggested') => PutProductsRequest} setPrice Sets product price by amount
|
|
2371
|
+
* @property {(shopId: Integer, menuIds: Integer) => PutProductsRequest} setMenu Sets product selected IDs
|
|
2366
2372
|
* @property {function} exec Excecute request
|
|
2367
2373
|
*/
|
|
2368
2374
|
|
package/dist/helpers.js
CHANGED
|
@@ -119,11 +119,15 @@ export const nest = (valueName, nodeName, obj = {}, forceArray = false) => (valu
|
|
|
119
119
|
return params;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
export const getCurrentAppendableArray = (object, nodeName) => {
|
|
123
|
+
const arr = object.params[object.appendable.arrayNode];
|
|
124
|
+
return arr[object.appendable.index][nodeName] ?? [];
|
|
125
|
+
}
|
|
126
|
+
|
|
122
127
|
export const nestArray = (object, valueName, nodeName, obj = {}) => (value) => {
|
|
123
128
|
const node = { ...obj }, params = {};
|
|
124
129
|
if (object.appendable) {
|
|
125
|
-
|
|
126
|
-
params[nodeName] = arr[arr.length - 1][nodeName] ?? [];
|
|
130
|
+
params[nodeName] = getCurrentAppendableArray(object, nodeName)
|
|
127
131
|
} else {
|
|
128
132
|
params[nodeName] = object.params[nodeName] ?? [];
|
|
129
133
|
}
|
|
@@ -5,6 +5,7 @@ export default (object) => {
|
|
|
5
5
|
object.gate = { method: 'get', node: '/products/auctions' };
|
|
6
6
|
object.custom = {
|
|
7
7
|
ids: arrayOfObjects("products", "identValue", {"identType":"id"}),
|
|
8
|
+
fromAllegro: () => { const auctionSites = object.params[object.appendable.index]; console.log("auctionSites"); auctionSites.push("allegro"); return { auctionSites }},
|
|
8
9
|
page
|
|
9
10
|
};
|
|
10
11
|
return new Proxy(object, paramsProxy);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
import { setProductText, nestArray, getCurrentAppendableArray } from "../helpers.js";
|
|
3
|
+
|
|
4
|
+
export default (object) => {
|
|
5
|
+
object.gate = { method: 'put', node: '/products/products' };
|
|
6
|
+
object.custom = {
|
|
7
|
+
setText: setProductText(object),
|
|
8
|
+
editMode: () => { const settings = object.params.settings ?? {}; settings.settingModificationType = 'edit'; return { settings } },
|
|
9
|
+
addMode: () => { const settings = object.params.settings ?? {}; settings.settingModificationType = 'edit'; return { settings } },
|
|
10
|
+
setPrice: (value, type = 'retail', net = false) => { const node = ['product', type[0].toUpperCase() + type.substring(1).toLowerCase(), 'Price']; if (net) node.push('Net'); const params = { priceChangeMode: 'amount_set' }; params[node.join('')] = value; return params; },
|
|
11
|
+
setMenu: (shopId, menuIds) => { if (!Array.isArray(menuIds)) menuIds = [menuIds]; const productMenuItems = getCurrentAppendableArray(object, "productMenuItems"); for (const menuItemId of menuIds) { productMenuItems.push({ productMenuOperation: "add_product", shopId, menuItemId }) } return { productMenuItems}; },
|
|
12
|
+
// dimensions: (width, height, length) => ({ productDimensions: { productWidth: width, productHeight: height, productLength: length } })
|
|
13
|
+
};
|
|
14
|
+
object.appendable = {
|
|
15
|
+
except: ["settings","picturesSettings","editMode","addMode"],
|
|
16
|
+
arrayNode: "products",
|
|
17
|
+
index: 0
|
|
18
|
+
}
|
|
19
|
+
return new Proxy(object, paramsProxy);
|
|
20
|
+
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { paramsProxy } from "../params.js";
|
|
2
|
-
import { setProductText } from "../helpers.js";
|
|
2
|
+
import { setProductText, getCurrentAppendableArray } from "../helpers.js";
|
|
3
3
|
|
|
4
4
|
export default (object) => {
|
|
5
5
|
object.gate = { method: 'put', node: '/products/products' };
|
|
6
6
|
object.custom = {
|
|
7
|
-
setText: setProductText(object)
|
|
7
|
+
setText: setProductText(object),
|
|
8
|
+
editMode: () => { const settings = object.params.settings ?? {}; settings.settingModificationType = "edit"; return { settings } },
|
|
9
|
+
addMode: () => { const settings = object.params.settings ?? {}; settings.settingModificationType = "edit"; return { settings } },
|
|
10
|
+
addPrice: (value, type = "retail", net = false) => { const node = ["product", type[0].toUpperCase() + type.substring(1).toLowerCase(), "Price"]; if (net) node.push("Net"); const params = { priceChangeMode: "amount_diff" }; params[node.join("")] = value; return params; },
|
|
11
|
+
setPrice: (value, type = "retail", net = false) => { const node = ["product", type[0].toUpperCase() + type.substring(1).toLowerCase(), "Price"]; if (net) node.push("Net"); const params = { priceChangeMode: "amount_set" }; params[node.join("")] = value; return params; },
|
|
12
|
+
setMenu: (shopId, menuIds) => { if (!Array.isArray(menuIds)) menuIds = [menuIds]; const productMenuItems = getCurrentAppendableArray(object, "productMenuItems"); for (const menuItemId of menuIds) { productMenuItems.push({ productMenuOperation: "add_product", shopId, menuItemId }) } return { productMenuItems}; }
|
|
8
13
|
};
|
|
9
14
|
object.appendable = {
|
|
10
|
-
except: ["settings","picturesSettings"],
|
|
15
|
+
except: ["settings","picturesSettings","editMode","addMode"],
|
|
11
16
|
arrayNode: "products",
|
|
12
17
|
index: 0
|
|
13
18
|
}
|
package/package.json
CHANGED
|
@@ -4,4 +4,9 @@ import { expect, test } from "vitest"
|
|
|
4
4
|
test("getProductsAuctionsPage", () => {
|
|
5
5
|
const params = idosell().getProductsAuctions.page(2,10).getParams();
|
|
6
6
|
expect(params).toEqual({"resultsPage":2,"resultsLimit":10});
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test("getProductsAuctionsFromAllegro", () => {
|
|
10
|
+
const params = idosell().getProductsAuctions.ids(33).fromAllegro().getParams();
|
|
11
|
+
expect(params).toEqual({"products":[{"identType":"id","identValue":33}],"auctionSites":["allegro"]});
|
|
7
12
|
})
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import idosell from "./dist/index.js"
|
|
2
2
|
import { expect, test } from "vitest"
|
|
3
3
|
|
|
4
|
+
test("putProductsCountryOfOrigin", () => {
|
|
5
|
+
const params = idosell().putProducts.productId(33).countryOfOrigin("PL").getParams();
|
|
6
|
+
expect(params).toEqual({"products":[{"productId":33,"countryOfOrigin":"PL"}]});
|
|
7
|
+
})
|
|
8
|
+
|
|
4
9
|
test("putProductsSetText", () => {
|
|
5
10
|
const params = idosell().putProducts.productId(33).setText("Krzesło Pavon", "name").getParams();
|
|
6
11
|
expect(params).toEqual({"products":[{"productId":33,"productNames":{"productNamesLangData":[{"langId":"pol","productName":"Krzesło Pavon"}]}}]});
|
|
7
12
|
})
|
|
8
13
|
|
|
9
|
-
test("
|
|
10
|
-
const params = idosell().putProducts.productId(33).
|
|
11
|
-
expect(params).toEqual({"products":[{"productId":33,"
|
|
14
|
+
test("putProductsEditMode", () => {
|
|
15
|
+
const params = idosell().putProducts.editMode().productId(33).productDisplayedCode("PD01").getParams();
|
|
16
|
+
expect(params).toEqual({"settings":{"settingModificationType":"edit"},"products":[{"productId":33,"productDisplayedCode":"PD01"}]});
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test("putProductsSetRetailPrice", () => {
|
|
20
|
+
const params = idosell().putProducts.productId(33).setPrice(219).getParams();
|
|
21
|
+
expect(params).toEqual({"products":[{"productId":33,"priceChangeMode":"amount_set","productRetailPrice":219}]});
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test("putProductsSetWholesalePrice", () => {
|
|
25
|
+
const params = idosell().putProducts.productId(33).setPrice(169, "wholesale", true).getParams();
|
|
26
|
+
expect(params).toEqual({"products":[{"productId":33,"priceChangeMode":"amount_set","productWholesalePriceNet":169}]});
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test("putProductsSetMenu", () => {
|
|
30
|
+
const params = idosell().putProducts.productId(33).setMenu(1,252).getParams();
|
|
31
|
+
expect(params).toEqual({"products":[{"productId":33,"productMenuItems":[{"productMenuOperation":"add_product","shopId":1,"menuItemId":252}]}]});
|
|
12
32
|
})
|
|
@@ -8,7 +8,7 @@ test("putProductsImagesProductImages", () => {
|
|
|
8
8
|
|
|
9
9
|
test("putProductsImagesAddSingleImage", () => {
|
|
10
10
|
const params = idosell().putProductsImages.productId(31).addImage("https://www.idosell.com/panel/file-gate.php?id=279794&ext=.webp").getParams();
|
|
11
|
-
expect(params).toEqual({"productsImagesSettings":{"productsImagesSourceType":"url","productsImagesApplyMacro":true},"productsImages":[{"productIdent":{"productIdentType":"id","identValue":31},"productImages":[{"productImageNumber":1,"productImageSource":"https://www.idosell.com/panel/file-gate.php?id=279794&ext=.webp"}
|
|
11
|
+
expect(params).toEqual({"productsImagesSettings":{"productsImagesSourceType":"url","productsImagesApplyMacro":true},"productsImages":[{"productIdent":{"productIdentType":"id","identValue":31},"productImages":[{"productImageNumber":1,"productImageSource":"https://www.idosell.com/panel/file-gate.php?id=279794&ext=.webp"}]}]});
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
test("putProductsImagesAddMultipleImage", () => {
|
/package/{readme.md → README.md}
RENAMED
|
File without changes
|