idosell 0.1.2 → 0.1.3
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 +2 -11
- package/dist/index.js +1 -1
- package/dist/methods/getProductsMarketingZones.js +0 -6
- package/dist/methods/getProductsOmnibusPrices.js +0 -6
- package/dist/methods/getProductsReservations.js +3 -3
- package/dist/methods/getProductsStocks.js +3 -3
- package/dist/methods/getProductsStrikethroughPrices.js +0 -6
- package/dist/request.js +5 -1
- package/package.json +1 -1
- package/tests/getProductsCodeExistence.test.js +17 -0
- package/tests/getProductsReservations.test.js +17 -0
- package/tests/getProductsStocks.test.js +17 -0
package/dist/gates.def.js
CHANGED
|
@@ -1895,9 +1895,6 @@
|
|
|
1895
1895
|
/**
|
|
1896
1896
|
* @typedef {Object} GetProductsMarketingZonesRequest
|
|
1897
1897
|
* @property {(products: Array<Object>) => GetProductsMarketingZonesRequest} products Products list.
|
|
1898
|
-
* @property {(ids: Array<Integer>) => GetProductsMarketingZonesRequest} ids Define products by passing array of values
|
|
1899
|
-
* @property {(externalCodes: Array<String>) => GetProductsMarketingZonesRequest} externalCodes Define products by passing array of values
|
|
1900
|
-
* @property {(producerCodes: Array<String>) => GetProductsMarketingZonesRequest} producerCodes Define products by passing array of values
|
|
1901
1898
|
* @property {function} exec Excecute request
|
|
1902
1899
|
*/
|
|
1903
1900
|
|
|
@@ -1918,9 +1915,6 @@
|
|
|
1918
1915
|
/**
|
|
1919
1916
|
* @typedef {Object} GetProductsOmnibusPricesRequest
|
|
1920
1917
|
* @property {(products: Array<Object>) => GetProductsOmnibusPricesRequest} products Products list.
|
|
1921
|
-
* @property {(ids: Array<[object Object]>) => GetProductsOmnibusPricesRequest} ids Define products by passing array of values
|
|
1922
|
-
* @property {(externalCodes: Array<String>) => GetProductsOmnibusPricesRequest} externalCodes Define products by passing array of values
|
|
1923
|
-
* @property {(producerCodes: Array<String>) => GetProductsOmnibusPricesRequest} producerCodes Define products by passing array of values
|
|
1924
1918
|
* @property {function} exec Excecute request
|
|
1925
1919
|
*/
|
|
1926
1920
|
|
|
@@ -2419,7 +2413,7 @@
|
|
|
2419
2413
|
/**
|
|
2420
2414
|
* @typedef {Object} GetProductsReservationsRequest
|
|
2421
2415
|
* @property {(productsIdents: Array<Object>) => GetProductsReservationsRequest} productsIdents Products list.
|
|
2422
|
-
* @property {(ids: Array<
|
|
2416
|
+
* @property {(ids: Array<Integer>) => GetProductsReservationsRequest} ids Define productsIdents by passing array of values
|
|
2423
2417
|
* @property {(externalCodes: Array<String>) => GetProductsReservationsRequest} externalCodes Define productsIdents by passing array of values
|
|
2424
2418
|
* @property {(producerCodes: Array<String>) => GetProductsReservationsRequest} producerCodes Define productsIdents by passing array of values
|
|
2425
2419
|
* @property {function} exec Excecute request
|
|
@@ -2529,7 +2523,7 @@
|
|
|
2529
2523
|
/**
|
|
2530
2524
|
* @typedef {Object} GetProductsStocksRequest
|
|
2531
2525
|
* @property {(products: Array<Object>) => GetProductsStocksRequest} products Products list.
|
|
2532
|
-
* @property {(ids: Array<
|
|
2526
|
+
* @property {(ids: Array<Integer>) => GetProductsStocksRequest} ids Define products by passing array of values
|
|
2533
2527
|
* @property {(externalCodes: Array<String>) => GetProductsStocksRequest} externalCodes Define products by passing array of values
|
|
2534
2528
|
* @property {(producerCodes: Array<String>) => GetProductsStocksRequest} producerCodes Define products by passing array of values
|
|
2535
2529
|
* @property {function} exec Excecute request
|
|
@@ -2549,9 +2543,6 @@
|
|
|
2549
2543
|
/**
|
|
2550
2544
|
* @typedef {Object} GetProductsStrikethroughPricesRequest
|
|
2551
2545
|
* @property {(products: Array<Object>) => GetProductsStrikethroughPricesRequest} products Products list.
|
|
2552
|
-
* @property {(ids: Array<[object Object]>) => GetProductsStrikethroughPricesRequest} ids Define products by passing array of values
|
|
2553
|
-
* @property {(externalCodes: Array<String>) => GetProductsStrikethroughPricesRequest} externalCodes Define products by passing array of values
|
|
2554
|
-
* @property {(producerCodes: Array<String>) => GetProductsStrikethroughPricesRequest} producerCodes Define products by passing array of values
|
|
2555
2546
|
* @property {function} exec Excecute request
|
|
2556
2547
|
*/
|
|
2557
2548
|
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { paramsProxy } from "../params.js";
|
|
2
|
-
import { arrayOfObjects } from "../helpers.js";
|
|
3
2
|
|
|
4
3
|
export default (object) => {
|
|
5
4
|
object.gate = { method: 'get', node: '/products/marketingZones' }
|
|
6
|
-
object.custom = {
|
|
7
|
-
ids: arrayOfObjects("products", "value", {"type":"id"}),
|
|
8
|
-
externalCodes: arrayOfObjects("products", "value", {"type":"codeExtern"}),
|
|
9
|
-
producerCodes: arrayOfObjects("products", "value", {"type":"codeProducer"})
|
|
10
|
-
};
|
|
11
5
|
return new Proxy(object, paramsProxy);
|
|
12
6
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { paramsProxy } from "../params.js";
|
|
2
|
-
import { arrayOfObjects } from "../helpers.js";
|
|
3
2
|
|
|
4
3
|
export default (object) => {
|
|
5
4
|
object.gate = { method: 'get', node: '/products/omnibusPrices' }
|
|
6
|
-
object.custom = {
|
|
7
|
-
ids: arrayOfObjects("products", "value"),
|
|
8
|
-
externalCodes: arrayOfObjects("products", "value", {"type":"codeExtern"}),
|
|
9
|
-
producerCodes: arrayOfObjects("products", "value", {"type":"codeProducer"})
|
|
10
|
-
};
|
|
11
5
|
return new Proxy(object, paramsProxy);
|
|
12
6
|
}
|
|
@@ -4,9 +4,9 @@ import { arrayOfObjects } from "../helpers.js";
|
|
|
4
4
|
export default (object) => {
|
|
5
5
|
object.gate = { method: 'get', node: '/products/reservations' }
|
|
6
6
|
object.custom = {
|
|
7
|
-
ids: arrayOfObjects("productsIdents", "
|
|
8
|
-
externalCodes: arrayOfObjects("productsIdents", "
|
|
9
|
-
producerCodes: arrayOfObjects("productsIdents", "
|
|
7
|
+
ids: arrayOfObjects("productsIdents", "identValue", {"identType":"id"}),
|
|
8
|
+
externalCodes: arrayOfObjects("productsIdents", "identValue", {"identType":"codeExtern"}),
|
|
9
|
+
producerCodes: arrayOfObjects("productsIdents", "identValue", {"identType":"codeProducer"})
|
|
10
10
|
};
|
|
11
11
|
return new Proxy(object, paramsProxy);
|
|
12
12
|
}
|
|
@@ -4,9 +4,9 @@ import { arrayOfObjects } from "../helpers.js";
|
|
|
4
4
|
export default (object) => {
|
|
5
5
|
object.gate = { method: 'get', node: '/products/stocks' }
|
|
6
6
|
object.custom = {
|
|
7
|
-
ids: arrayOfObjects("products", "
|
|
8
|
-
externalCodes: arrayOfObjects("products", "
|
|
9
|
-
producerCodes: arrayOfObjects("products", "
|
|
7
|
+
ids: arrayOfObjects("products", "identValue", {"identType":"id"}),
|
|
8
|
+
externalCodes: arrayOfObjects("products", "identValue", {"identType":"codeExtern"}),
|
|
9
|
+
producerCodes: arrayOfObjects("products", "identValue", {"identType":"codeProducer"})
|
|
10
10
|
};
|
|
11
11
|
return new Proxy(object, paramsProxy);
|
|
12
12
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { paramsProxy } from "../params.js";
|
|
2
|
-
import { arrayOfObjects } from "../helpers.js";
|
|
3
2
|
|
|
4
3
|
export default (object) => {
|
|
5
4
|
object.gate = { method: 'get', node: '/products/strikethroughPrices' }
|
|
6
|
-
object.custom = {
|
|
7
|
-
ids: arrayOfObjects("products", "value"),
|
|
8
|
-
externalCodes: arrayOfObjects("products", "value", {"type":"codeExtern"}),
|
|
9
|
-
producerCodes: arrayOfObjects("products", "value", {"type":"codeProducer"})
|
|
10
|
-
};
|
|
11
5
|
return new Proxy(object, paramsProxy);
|
|
12
6
|
}
|
package/dist/request.js
CHANGED
|
@@ -31,7 +31,11 @@ export const queryfy = (params) => {
|
|
|
31
31
|
let output = '';
|
|
32
32
|
for (const [ key, value ] of Object.entries(params)) {
|
|
33
33
|
if (Array.isArray(value)) {
|
|
34
|
-
|
|
34
|
+
if (typeof value[0] === 'object') {
|
|
35
|
+
const newValue = value.map(obj => encodeURIComponent(JSON.stringify(obj)));
|
|
36
|
+
output += `${key}=${newValue.join('%2C')}&`;
|
|
37
|
+
}
|
|
38
|
+
else output += `${key}=${value.join('%2C')}&`;
|
|
35
39
|
} else if (typeof value === 'object') {
|
|
36
40
|
for (const [ subkey, subvalue ] of Object.entries(value)) {
|
|
37
41
|
output += `${key}%5B${subkey}%5D=${subvalue}&`;
|
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import idosell from "./dist/index.js"
|
|
2
|
+
import { expect, test } from "vitest"
|
|
3
|
+
|
|
4
|
+
test("getProductsCodeExistenceExternalCodes", () => {
|
|
5
|
+
const params = idosell().getProductsCodeExistence.externalCodes(["pav01"]).getParams();
|
|
6
|
+
expect(params).toEqual({"products":[{"productIdentType":"codeExtern","productId":"pav01"}]});
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test("getProductsCodeExistenceProducerCodes", () => {
|
|
10
|
+
const params = idosell().getProductsCodeExistence.producerCodes(99099099099).getParams();
|
|
11
|
+
expect(params).toEqual({"products":[{"productIdentType":"codeProducer","productId":99099099099}]});
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test("getProductsCodeExistenceIds", () => {
|
|
15
|
+
const params = idosell().getProductsCodeExistence.ids([30,33]).getParams();
|
|
16
|
+
expect(params).toEqual({"products":[{"productIdentType":"id","productId":30},{"productIdentType":"id","productId":33}]});
|
|
17
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import idosell from "./dist/index.js"
|
|
2
|
+
import { expect, test } from "vitest"
|
|
3
|
+
|
|
4
|
+
test("getProductsReservationsIds", () => {
|
|
5
|
+
const params = idosell().getProductsReservations.ids(33).getParams();
|
|
6
|
+
expect(params).toEqual({"productsIdents":[{"identType":"id","identValue":33}]});
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test("getProductsReservationsExternalCodes", () => {
|
|
10
|
+
const params = idosell().getProductsReservations.externalCodes(["pav01"]).getParams();
|
|
11
|
+
expect(params).toEqual({"productsIdents":[{"identType":"codeExtern","identValue":"pav01"}]});
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test("getProductsReservationsProducerCodes", () => {
|
|
15
|
+
const params = idosell().getProductsReservations.producerCodes([99099099099]).getParams();
|
|
16
|
+
expect(params).toEqual({"productsIdents":[{"identType":"codeProducer","identValue":99099099099}]});
|
|
17
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import idosell from "./dist/index.js"
|
|
2
|
+
import { expect, test } from "vitest"
|
|
3
|
+
|
|
4
|
+
test("getProductsStocksIds", () => {
|
|
5
|
+
const params = idosell().getProductsStocks.ids(33).getParams();
|
|
6
|
+
expect(params).toEqual({"products":[{"identType":"id","identValue":33}]});
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test("getProductsStocksExternalCodes", () => {
|
|
10
|
+
const params = idosell().getProductsStocks.externalCodes(["pav01"]).getParams();
|
|
11
|
+
expect(params).toEqual({"products":[{"identType":"codeExtern","identValue":"pav01"}]});
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test("getProductsStocksProducerCodes", () => {
|
|
15
|
+
const params = idosell().getProductsStocks.producerCodes(99099099099).getParams();
|
|
16
|
+
expect(params).toEqual({"products":[{"identType":"codeProducer","identValue":99099099099}]});
|
|
17
|
+
})
|