@revenexx/sdk 0.0.9 → 0.0.11
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/cjs/sdk.js +1051 -49
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +1050 -50
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +1051 -49
- package/package.json +1 -1
- package/src/client.ts +30 -1
- package/src/enums/order-fulfillment-status.ts +5 -0
- package/src/enums/order-status.ts +7 -0
- package/src/index.ts +3 -1
- package/src/services/carts.ts +65 -2
- package/src/services/customers.ts +57 -1
- package/src/services/inventories.ts +5 -5
- package/src/services/orderlists.ts +66 -3
- package/src/services/orders.ts +23 -21
- package/src/services/prices.ts +3 -3
- package/src/services/products.ts +688 -16
- package/src/services/search.ts +1 -1
- package/src/services/shipping.ts +1 -1
- package/types/client.d.ts +11 -0
- package/types/enums/order-fulfillment-status.d.ts +5 -0
- package/types/enums/order-status.d.ts +7 -0
- package/types/index.d.ts +3 -1
- package/types/services/carts.d.ts +27 -1
- package/types/services/customers.d.ts +24 -1
- package/types/services/orderlists.d.ts +27 -1
- package/types/services/orders.d.ts +13 -11
- package/types/services/products.d.ts +288 -16
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -388,7 +388,7 @@ class Client {
|
|
|
388
388
|
'x-sdk-name': 'Revenexx Web',
|
|
389
389
|
'x-sdk-platform': '',
|
|
390
390
|
'x-sdk-language': 'web',
|
|
391
|
-
'x-sdk-version': '0.0.
|
|
391
|
+
'x-sdk-version': '0.0.11',
|
|
392
392
|
};
|
|
393
393
|
|
|
394
394
|
/**
|
|
@@ -927,6 +927,35 @@ class Client {
|
|
|
927
927
|
return data;
|
|
928
928
|
}
|
|
929
929
|
|
|
930
|
+
/**
|
|
931
|
+
* Recursively renames an argument's DECLARED keys to their snake_case wire
|
|
932
|
+
* names, using a map generated from the API contract. Free-form subtrees
|
|
933
|
+
* (metadata / user_data — keys absent from the map, with no `children`) are
|
|
934
|
+
* passed through untouched, so user data is never mangled. For arrays the
|
|
935
|
+
* same element map is applied to every item.
|
|
936
|
+
*/
|
|
937
|
+
static toWireKeys(value: any, map: Record<string, { wire: string, children: any }>): any {
|
|
938
|
+
if (Array.isArray(value)) {
|
|
939
|
+
return value.map((item) => Client.toWireKeys(item, map));
|
|
940
|
+
}
|
|
941
|
+
if (
|
|
942
|
+
value === null
|
|
943
|
+
|| typeof value !== 'object'
|
|
944
|
+
|| value instanceof File
|
|
945
|
+
|| value instanceof Blob
|
|
946
|
+
|| value instanceof Date
|
|
947
|
+
) {
|
|
948
|
+
return value;
|
|
949
|
+
}
|
|
950
|
+
const output: Record<string, any> = {};
|
|
951
|
+
for (const [key, item] of Object.entries(value)) {
|
|
952
|
+
const entry = map[key];
|
|
953
|
+
const wireKey = entry ? entry.wire : key;
|
|
954
|
+
output[wireKey] = (entry && entry.children) ? Client.toWireKeys(item, entry.children) : item;
|
|
955
|
+
}
|
|
956
|
+
return output;
|
|
957
|
+
}
|
|
958
|
+
|
|
930
959
|
static flatten(data: Payload, prefix = ''): Payload {
|
|
931
960
|
let output: Payload = {};
|
|
932
961
|
|
package/src/index.ts
CHANGED
|
@@ -64,8 +64,10 @@ export { LocationType } from './enums/location-type';
|
|
|
64
64
|
export { MarketStatus } from './enums/market-status';
|
|
65
65
|
export { Priority } from './enums/priority';
|
|
66
66
|
export { OrderListKind } from './enums/order-list-kind';
|
|
67
|
-
export {
|
|
67
|
+
export { OrderStatus } from './enums/order-status';
|
|
68
68
|
export { OrderPaymentStatus } from './enums/order-payment-status';
|
|
69
|
+
export { OrderFulfillmentStatus } from './enums/order-fulfillment-status';
|
|
70
|
+
export { OrderCommentVisibility } from './enums/order-comment-visibility';
|
|
69
71
|
export { PageStatus } from './enums/page-status';
|
|
70
72
|
export { PaymentFeeType } from './enums/payment-fee-type';
|
|
71
73
|
export { PaymentMethodKind } from './enums/payment-method-kind';
|
package/src/services/carts.ts
CHANGED
|
@@ -18,13 +18,76 @@ export class Carts {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
|
+
* @param {string} params.contactId - Filter to one owning contact.
|
|
22
|
+
* @param {string} params.sessionKey - Filter to one guest session.
|
|
23
|
+
* @param {string} params.status - Filter by cart status (e.g. active).
|
|
24
|
+
* @param {number} params.limit - Page size (default 50, max 200).
|
|
25
|
+
* @param {number} params.offset - Row offset for pagination (default 0).
|
|
26
|
+
* @param {string} params.order - Sort as 'column.asc' | 'column.desc', e.g. 'created_at.desc'.
|
|
21
27
|
* @throws {RevenexxException}
|
|
22
28
|
* @returns {Promise<{}>}
|
|
23
29
|
*/
|
|
24
|
-
cartsList(): Promise<{}
|
|
30
|
+
cartsList(params?: { contactId?: string, sessionKey?: string, status?: string, limit?: number, offset?: number, order?: string }): Promise<{}>;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {string} contactId - Filter to one owning contact.
|
|
34
|
+
* @param {string} sessionKey - Filter to one guest session.
|
|
35
|
+
* @param {string} status - Filter by cart status (e.g. active).
|
|
36
|
+
* @param {number} limit - Page size (default 50, max 200).
|
|
37
|
+
* @param {number} offset - Row offset for pagination (default 0).
|
|
38
|
+
* @param {string} order - Sort as 'column.asc' | 'column.desc', e.g. 'created_at.desc'.
|
|
39
|
+
* @throws {RevenexxException}
|
|
40
|
+
* @returns {Promise<{}>}
|
|
41
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
42
|
+
*/
|
|
43
|
+
cartsList(contactId?: string, sessionKey?: string, status?: string, limit?: number, offset?: number, order?: string): Promise<{}>;
|
|
44
|
+
cartsList(
|
|
45
|
+
paramsOrFirst?: { contactId?: string, sessionKey?: string, status?: string, limit?: number, offset?: number, order?: string } | string,
|
|
46
|
+
...rest: [(string)?, (string)?, (number)?, (number)?, (string)?]
|
|
47
|
+
): Promise<{}> {
|
|
48
|
+
let params: { contactId?: string, sessionKey?: string, status?: string, limit?: number, offset?: number, order?: string };
|
|
49
|
+
|
|
50
|
+
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
51
|
+
params = (paramsOrFirst || {}) as { contactId?: string, sessionKey?: string, status?: string, limit?: number, offset?: number, order?: string };
|
|
52
|
+
} else {
|
|
53
|
+
params = {
|
|
54
|
+
contactId: paramsOrFirst as string,
|
|
55
|
+
sessionKey: rest[0] as string,
|
|
56
|
+
status: rest[1] as string,
|
|
57
|
+
limit: rest[2] as number,
|
|
58
|
+
offset: rest[3] as number,
|
|
59
|
+
order: rest[4] as string
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const contactId = params.contactId;
|
|
64
|
+
const sessionKey = params.sessionKey;
|
|
65
|
+
const status = params.status;
|
|
66
|
+
const limit = params.limit;
|
|
67
|
+
const offset = params.offset;
|
|
68
|
+
const order = params.order;
|
|
69
|
+
|
|
25
70
|
|
|
26
71
|
const apiPath = '/v1/carts';
|
|
27
72
|
const apiPayload: Payload = {};
|
|
73
|
+
if (typeof contactId !== 'undefined') {
|
|
74
|
+
apiPayload['contact_id'] = contactId;
|
|
75
|
+
}
|
|
76
|
+
if (typeof sessionKey !== 'undefined') {
|
|
77
|
+
apiPayload['session_key'] = sessionKey;
|
|
78
|
+
}
|
|
79
|
+
if (typeof status !== 'undefined') {
|
|
80
|
+
apiPayload['status'] = status;
|
|
81
|
+
}
|
|
82
|
+
if (typeof limit !== 'undefined') {
|
|
83
|
+
apiPayload['limit'] = limit;
|
|
84
|
+
}
|
|
85
|
+
if (typeof offset !== 'undefined') {
|
|
86
|
+
apiPayload['offset'] = offset;
|
|
87
|
+
}
|
|
88
|
+
if (typeof order !== 'undefined') {
|
|
89
|
+
apiPayload['order'] = order;
|
|
90
|
+
}
|
|
28
91
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
29
92
|
|
|
30
93
|
const apiHeaders: { [header: string]: string } = {
|
|
@@ -957,7 +1020,7 @@ export class Carts {
|
|
|
957
1020
|
const apiPath = '/v1/carts/{cart_id}/items'.replace('{cart_id}', cartId);
|
|
958
1021
|
const apiPayload: Payload = {};
|
|
959
1022
|
if (typeof items !== 'undefined') {
|
|
960
|
-
apiPayload['items'] = items;
|
|
1023
|
+
apiPayload['items'] = Client.toWireKeys(items, {"productId":{"wire":"product_id","children":null},"taxRate":{"wire":"tax_rate","children":null},"unitPrice":{"wire":"unit_price","children":null}});
|
|
961
1024
|
}
|
|
962
1025
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
963
1026
|
|
|
@@ -16,13 +16,69 @@ export class Customers {
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
*
|
|
19
|
+
* @param {string} params.contactId - Filter to one owning contact.
|
|
20
|
+
* @param {string} params.organizationId - Filter to one organization.
|
|
21
|
+
* @param {number} params.limit - Page size (default 50, max 200).
|
|
22
|
+
* @param {number} params.offset - Row offset for pagination (default 0).
|
|
23
|
+
* @param {string} params.order - Sort as 'column.asc' | 'column.desc', e.g. 'created_at.desc'.
|
|
19
24
|
* @throws {RevenexxException}
|
|
20
25
|
* @returns {Promise<{}>}
|
|
21
26
|
*/
|
|
22
|
-
customersAddressesList(): Promise<{}
|
|
27
|
+
customersAddressesList(params?: { contactId?: string, organizationId?: string, limit?: number, offset?: number, order?: string }): Promise<{}>;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param {string} contactId - Filter to one owning contact.
|
|
31
|
+
* @param {string} organizationId - Filter to one organization.
|
|
32
|
+
* @param {number} limit - Page size (default 50, max 200).
|
|
33
|
+
* @param {number} offset - Row offset for pagination (default 0).
|
|
34
|
+
* @param {string} order - Sort as 'column.asc' | 'column.desc', e.g. 'created_at.desc'.
|
|
35
|
+
* @throws {RevenexxException}
|
|
36
|
+
* @returns {Promise<{}>}
|
|
37
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
38
|
+
*/
|
|
39
|
+
customersAddressesList(contactId?: string, organizationId?: string, limit?: number, offset?: number, order?: string): Promise<{}>;
|
|
40
|
+
customersAddressesList(
|
|
41
|
+
paramsOrFirst?: { contactId?: string, organizationId?: string, limit?: number, offset?: number, order?: string } | string,
|
|
42
|
+
...rest: [(string)?, (number)?, (number)?, (string)?]
|
|
43
|
+
): Promise<{}> {
|
|
44
|
+
let params: { contactId?: string, organizationId?: string, limit?: number, offset?: number, order?: string };
|
|
45
|
+
|
|
46
|
+
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
47
|
+
params = (paramsOrFirst || {}) as { contactId?: string, organizationId?: string, limit?: number, offset?: number, order?: string };
|
|
48
|
+
} else {
|
|
49
|
+
params = {
|
|
50
|
+
contactId: paramsOrFirst as string,
|
|
51
|
+
organizationId: rest[0] as string,
|
|
52
|
+
limit: rest[1] as number,
|
|
53
|
+
offset: rest[2] as number,
|
|
54
|
+
order: rest[3] as string
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const contactId = params.contactId;
|
|
59
|
+
const organizationId = params.organizationId;
|
|
60
|
+
const limit = params.limit;
|
|
61
|
+
const offset = params.offset;
|
|
62
|
+
const order = params.order;
|
|
63
|
+
|
|
23
64
|
|
|
24
65
|
const apiPath = '/v1/customers/addresses';
|
|
25
66
|
const apiPayload: Payload = {};
|
|
67
|
+
if (typeof contactId !== 'undefined') {
|
|
68
|
+
apiPayload['contact_id'] = contactId;
|
|
69
|
+
}
|
|
70
|
+
if (typeof organizationId !== 'undefined') {
|
|
71
|
+
apiPayload['organization_id'] = organizationId;
|
|
72
|
+
}
|
|
73
|
+
if (typeof limit !== 'undefined') {
|
|
74
|
+
apiPayload['limit'] = limit;
|
|
75
|
+
}
|
|
76
|
+
if (typeof offset !== 'undefined') {
|
|
77
|
+
apiPayload['offset'] = offset;
|
|
78
|
+
}
|
|
79
|
+
if (typeof order !== 'undefined') {
|
|
80
|
+
apiPayload['order'] = order;
|
|
81
|
+
}
|
|
26
82
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
27
83
|
|
|
28
84
|
const apiHeaders: { [header: string]: string } = {
|
|
@@ -60,7 +60,7 @@ export class Inventories {
|
|
|
60
60
|
const apiPath = '/v1/inventories/adjust';
|
|
61
61
|
const apiPayload: Payload = {};
|
|
62
62
|
if (typeof items !== 'undefined') {
|
|
63
|
-
apiPayload['items'] = items;
|
|
63
|
+
apiPayload['items'] = Client.toWireKeys(items, {"productId":{"wire":"product_id","children":null}});
|
|
64
64
|
}
|
|
65
65
|
if (typeof locationCode !== 'undefined') {
|
|
66
66
|
apiPayload['location_code'] = locationCode;
|
|
@@ -124,7 +124,7 @@ export class Inventories {
|
|
|
124
124
|
const apiPath = '/v1/inventories/availability';
|
|
125
125
|
const apiPayload: Payload = {};
|
|
126
126
|
if (typeof items !== 'undefined') {
|
|
127
|
-
apiPayload['items'] = items;
|
|
127
|
+
apiPayload['items'] = Client.toWireKeys(items, {"productId":{"wire":"product_id","children":null}});
|
|
128
128
|
}
|
|
129
129
|
if (typeof locationCode !== 'undefined') {
|
|
130
130
|
apiPayload['location_code'] = locationCode;
|
|
@@ -668,7 +668,7 @@ export class Inventories {
|
|
|
668
668
|
const apiPath = '/v1/inventories/receive';
|
|
669
669
|
const apiPayload: Payload = {};
|
|
670
670
|
if (typeof items !== 'undefined') {
|
|
671
|
-
apiPayload['items'] = items;
|
|
671
|
+
apiPayload['items'] = Client.toWireKeys(items, {"productId":{"wire":"product_id","children":null}});
|
|
672
672
|
}
|
|
673
673
|
if (typeof locationCode !== 'undefined') {
|
|
674
674
|
apiPayload['location_code'] = locationCode;
|
|
@@ -866,7 +866,7 @@ export class Inventories {
|
|
|
866
866
|
apiPayload['expires_at'] = expiresAt;
|
|
867
867
|
}
|
|
868
868
|
if (typeof items !== 'undefined') {
|
|
869
|
-
apiPayload['items'] = items;
|
|
869
|
+
apiPayload['items'] = Client.toWireKeys(items, {"productId":{"wire":"product_id","children":null}});
|
|
870
870
|
}
|
|
871
871
|
if (typeof orderRef !== 'undefined') {
|
|
872
872
|
apiPayload['order_ref'] = orderRef;
|
|
@@ -935,7 +935,7 @@ export class Inventories {
|
|
|
935
935
|
const apiPath = '/v1/inventories/restock';
|
|
936
936
|
const apiPayload: Payload = {};
|
|
937
937
|
if (typeof items !== 'undefined') {
|
|
938
|
-
apiPayload['items'] = items;
|
|
938
|
+
apiPayload['items'] = Client.toWireKeys(items, {"productId":{"wire":"product_id","children":null}});
|
|
939
939
|
}
|
|
940
940
|
if (typeof locationCode !== 'undefined') {
|
|
941
941
|
apiPayload['location_code'] = locationCode;
|
|
@@ -13,13 +13,76 @@ export class Orderlists {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
|
+
* @param {string} params.ownerId - Filter to one owning contact.
|
|
17
|
+
* @param {string} params.organizationId - Filter to one organization.
|
|
18
|
+
* @param {string} params.kind - Filter by list kind (shopping | label).
|
|
19
|
+
* @param {number} params.limit - Page size (default 50, max 200).
|
|
20
|
+
* @param {number} params.offset - Row offset for pagination (default 0).
|
|
21
|
+
* @param {string} params.order - Sort as 'column.asc' | 'column.desc', e.g. 'created_at.desc'.
|
|
16
22
|
* @throws {RevenexxException}
|
|
17
23
|
* @returns {Promise<{}>}
|
|
18
24
|
*/
|
|
19
|
-
orderlistsList(): Promise<{}
|
|
25
|
+
orderlistsList(params?: { ownerId?: string, organizationId?: string, kind?: string, limit?: number, offset?: number, order?: string }): Promise<{}>;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param {string} ownerId - Filter to one owning contact.
|
|
29
|
+
* @param {string} organizationId - Filter to one organization.
|
|
30
|
+
* @param {string} kind - Filter by list kind (shopping | label).
|
|
31
|
+
* @param {number} limit - Page size (default 50, max 200).
|
|
32
|
+
* @param {number} offset - Row offset for pagination (default 0).
|
|
33
|
+
* @param {string} order - Sort as 'column.asc' | 'column.desc', e.g. 'created_at.desc'.
|
|
34
|
+
* @throws {RevenexxException}
|
|
35
|
+
* @returns {Promise<{}>}
|
|
36
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
37
|
+
*/
|
|
38
|
+
orderlistsList(ownerId?: string, organizationId?: string, kind?: string, limit?: number, offset?: number, order?: string): Promise<{}>;
|
|
39
|
+
orderlistsList(
|
|
40
|
+
paramsOrFirst?: { ownerId?: string, organizationId?: string, kind?: string, limit?: number, offset?: number, order?: string } | string,
|
|
41
|
+
...rest: [(string)?, (string)?, (number)?, (number)?, (string)?]
|
|
42
|
+
): Promise<{}> {
|
|
43
|
+
let params: { ownerId?: string, organizationId?: string, kind?: string, limit?: number, offset?: number, order?: string };
|
|
44
|
+
|
|
45
|
+
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
46
|
+
params = (paramsOrFirst || {}) as { ownerId?: string, organizationId?: string, kind?: string, limit?: number, offset?: number, order?: string };
|
|
47
|
+
} else {
|
|
48
|
+
params = {
|
|
49
|
+
ownerId: paramsOrFirst as string,
|
|
50
|
+
organizationId: rest[0] as string,
|
|
51
|
+
kind: rest[1] as string,
|
|
52
|
+
limit: rest[2] as number,
|
|
53
|
+
offset: rest[3] as number,
|
|
54
|
+
order: rest[4] as string
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const ownerId = params.ownerId;
|
|
59
|
+
const organizationId = params.organizationId;
|
|
60
|
+
const kind = params.kind;
|
|
61
|
+
const limit = params.limit;
|
|
62
|
+
const offset = params.offset;
|
|
63
|
+
const order = params.order;
|
|
64
|
+
|
|
20
65
|
|
|
21
66
|
const apiPath = '/v1/orderlists';
|
|
22
67
|
const apiPayload: Payload = {};
|
|
68
|
+
if (typeof ownerId !== 'undefined') {
|
|
69
|
+
apiPayload['owner_id'] = ownerId;
|
|
70
|
+
}
|
|
71
|
+
if (typeof organizationId !== 'undefined') {
|
|
72
|
+
apiPayload['organization_id'] = organizationId;
|
|
73
|
+
}
|
|
74
|
+
if (typeof kind !== 'undefined') {
|
|
75
|
+
apiPayload['kind'] = kind;
|
|
76
|
+
}
|
|
77
|
+
if (typeof limit !== 'undefined') {
|
|
78
|
+
apiPayload['limit'] = limit;
|
|
79
|
+
}
|
|
80
|
+
if (typeof offset !== 'undefined') {
|
|
81
|
+
apiPayload['offset'] = offset;
|
|
82
|
+
}
|
|
83
|
+
if (typeof order !== 'undefined') {
|
|
84
|
+
apiPayload['order'] = order;
|
|
85
|
+
}
|
|
23
86
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
24
87
|
|
|
25
88
|
const apiHeaders: { [header: string]: string } = {
|
|
@@ -105,7 +168,7 @@ export class Orderlists {
|
|
|
105
168
|
const apiPath = '/v1/orderlists';
|
|
106
169
|
const apiPayload: Payload = {};
|
|
107
170
|
if (typeof items !== 'undefined') {
|
|
108
|
-
apiPayload['items'] = items;
|
|
171
|
+
apiPayload['items'] = Client.toWireKeys(items, {"categorySlug":{"wire":"category_slug","children":null},"costCenterId":{"wire":"cost_center_id","children":null},"customSku":{"wire":"custom_sku","children":null},"positionTexts":{"wire":"position_texts","children":null},"productId":{"wire":"product_id","children":null},"subcategorySlug":{"wire":"subcategory_slug","children":null},"taxRate":{"wire":"tax_rate","children":null}});
|
|
109
172
|
}
|
|
110
173
|
if (typeof kind !== 'undefined') {
|
|
111
174
|
apiPayload['kind'] = kind;
|
|
@@ -594,7 +657,7 @@ export class Orderlists {
|
|
|
594
657
|
const apiPath = '/v1/orderlists/{list_id}/items'.replace('{list_id}', listId);
|
|
595
658
|
const apiPayload: Payload = {};
|
|
596
659
|
if (typeof items !== 'undefined') {
|
|
597
|
-
apiPayload['items'] = items;
|
|
660
|
+
apiPayload['items'] = Client.toWireKeys(items, {"categorySlug":{"wire":"category_slug","children":null},"costCenterId":{"wire":"cost_center_id","children":null},"customSku":{"wire":"custom_sku","children":null},"positionTexts":{"wire":"position_texts","children":null},"productId":{"wire":"product_id","children":null},"subcategorySlug":{"wire":"subcategory_slug","children":null},"taxRate":{"wire":"tax_rate","children":null}});
|
|
598
661
|
}
|
|
599
662
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
600
663
|
|
package/src/services/orders.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { Service } from '../service';
|
|
|
2
2
|
import { RevenexxException, Client, type Payload, UploadProgress } from '../client';
|
|
3
3
|
import type { Models } from '../models';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { OrderStatus } from '../enums/order-status';
|
|
6
6
|
import { OrderPaymentStatus } from '../enums/order-payment-status';
|
|
7
|
+
import { OrderFulfillmentStatus } from '../enums/order-fulfillment-status';
|
|
8
|
+
import { OrderCommentVisibility } from '../enums/order-comment-visibility';
|
|
7
9
|
|
|
8
10
|
export class Orders {
|
|
9
11
|
client: Client;
|
|
@@ -14,9 +16,9 @@ export class Orders {
|
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
*
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
19
|
+
* @param {OrderStatus} params.status - Filter by order status (exact match).
|
|
20
|
+
* @param {OrderPaymentStatus} params.paymentStatus - Filter by payment status (exact match).
|
|
21
|
+
* @param {OrderFulfillmentStatus} params.fulfillmentStatus - Filter by fulfillment status (exact match).
|
|
20
22
|
* @param {string} params.contactId - Filter to one ordering contact.
|
|
21
23
|
* @param {string} params.organizationId - Filter to one B2B organization.
|
|
22
24
|
* @param {string} params.channelId - Filter to one sales channel.
|
|
@@ -28,12 +30,12 @@ export class Orders {
|
|
|
28
30
|
* @throws {RevenexxException}
|
|
29
31
|
* @returns {Promise<{}>}
|
|
30
32
|
*/
|
|
31
|
-
ordersList(params?: { status?:
|
|
33
|
+
ordersList(params?: { status?: OrderStatus, paymentStatus?: OrderPaymentStatus, fulfillmentStatus?: OrderFulfillmentStatus, contactId?: string, organizationId?: string, channelId?: string, marketId?: string, number?: string, limit?: number, offset?: number, order?: string }): Promise<{}>;
|
|
32
34
|
/**
|
|
33
35
|
*
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {OrderStatus} status - Filter by order status (exact match).
|
|
37
|
+
* @param {OrderPaymentStatus} paymentStatus - Filter by payment status (exact match).
|
|
38
|
+
* @param {OrderFulfillmentStatus} fulfillmentStatus - Filter by fulfillment status (exact match).
|
|
37
39
|
* @param {string} contactId - Filter to one ordering contact.
|
|
38
40
|
* @param {string} organizationId - Filter to one B2B organization.
|
|
39
41
|
* @param {string} channelId - Filter to one sales channel.
|
|
@@ -46,20 +48,20 @@ export class Orders {
|
|
|
46
48
|
* @returns {Promise<{}>}
|
|
47
49
|
* @deprecated Use the object parameter style method for a better developer experience.
|
|
48
50
|
*/
|
|
49
|
-
ordersList(status?:
|
|
51
|
+
ordersList(status?: OrderStatus, paymentStatus?: OrderPaymentStatus, fulfillmentStatus?: OrderFulfillmentStatus, contactId?: string, organizationId?: string, channelId?: string, marketId?: string, number?: string, limit?: number, offset?: number, order?: string): Promise<{}>;
|
|
50
52
|
ordersList(
|
|
51
|
-
paramsOrFirst?: { status?:
|
|
52
|
-
...rest: [(
|
|
53
|
+
paramsOrFirst?: { status?: OrderStatus, paymentStatus?: OrderPaymentStatus, fulfillmentStatus?: OrderFulfillmentStatus, contactId?: string, organizationId?: string, channelId?: string, marketId?: string, number?: string, limit?: number, offset?: number, order?: string } | OrderStatus,
|
|
54
|
+
...rest: [(OrderPaymentStatus)?, (OrderFulfillmentStatus)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (number)?, (string)?]
|
|
53
55
|
): Promise<{}> {
|
|
54
|
-
let params: { status?:
|
|
56
|
+
let params: { status?: OrderStatus, paymentStatus?: OrderPaymentStatus, fulfillmentStatus?: OrderFulfillmentStatus, contactId?: string, organizationId?: string, channelId?: string, marketId?: string, number?: string, limit?: number, offset?: number, order?: string };
|
|
55
57
|
|
|
56
|
-
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
57
|
-
params = (paramsOrFirst || {}) as { status?:
|
|
58
|
+
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('status' in paramsOrFirst || 'paymentStatus' in paramsOrFirst || 'fulfillmentStatus' in paramsOrFirst || 'contactId' in paramsOrFirst || 'organizationId' in paramsOrFirst || 'channelId' in paramsOrFirst || 'marketId' in paramsOrFirst || 'number' in paramsOrFirst || 'limit' in paramsOrFirst || 'offset' in paramsOrFirst || 'order' in paramsOrFirst))) {
|
|
59
|
+
params = (paramsOrFirst || {}) as { status?: OrderStatus, paymentStatus?: OrderPaymentStatus, fulfillmentStatus?: OrderFulfillmentStatus, contactId?: string, organizationId?: string, channelId?: string, marketId?: string, number?: string, limit?: number, offset?: number, order?: string };
|
|
58
60
|
} else {
|
|
59
61
|
params = {
|
|
60
|
-
status: paramsOrFirst as
|
|
61
|
-
paymentStatus: rest[0] as
|
|
62
|
-
fulfillmentStatus: rest[1] as
|
|
62
|
+
status: paramsOrFirst as OrderStatus,
|
|
63
|
+
paymentStatus: rest[0] as OrderPaymentStatus,
|
|
64
|
+
fulfillmentStatus: rest[1] as OrderFulfillmentStatus,
|
|
63
65
|
contactId: rest[2] as string,
|
|
64
66
|
organizationId: rest[3] as string,
|
|
65
67
|
channelId: rest[4] as string,
|
|
@@ -624,7 +626,7 @@ export class Orders {
|
|
|
624
626
|
apiPayload['grand_total'] = grandTotal;
|
|
625
627
|
}
|
|
626
628
|
if (typeof items !== 'undefined') {
|
|
627
|
-
apiPayload['items'] = items;
|
|
629
|
+
apiPayload['items'] = Client.toWireKeys(items, {"costCenter":{"wire":"cost_center","children":null},"positionText":{"wire":"position_text","children":null},"productId":{"wire":"product_id","children":null},"taxAmount":{"wire":"tax_amount","children":null},"taxRate":{"wire":"tax_rate","children":null},"unitPrice":{"wire":"unit_price","children":null},"userData":{"wire":"user_data","children":null}});
|
|
628
630
|
}
|
|
629
631
|
if (typeof marketId !== 'undefined') {
|
|
630
632
|
apiPayload['market_id'] = marketId;
|
|
@@ -1216,7 +1218,7 @@ export class Orders {
|
|
|
1216
1218
|
apiPayload['cancelled_by'] = cancelledBy;
|
|
1217
1219
|
}
|
|
1218
1220
|
if (typeof positions !== 'undefined') {
|
|
1219
|
-
apiPayload['positions'] = positions;
|
|
1221
|
+
apiPayload['positions'] = Client.toWireKeys(positions, {"orderItemId":{"wire":"order_item_id","children":null}});
|
|
1220
1222
|
}
|
|
1221
1223
|
if (typeof reason !== 'undefined') {
|
|
1222
1224
|
apiPayload['reason'] = reason;
|
|
@@ -1359,7 +1361,7 @@ export class Orders {
|
|
|
1359
1361
|
apiPayload['metadata'] = metadata;
|
|
1360
1362
|
}
|
|
1361
1363
|
if (typeof positions !== 'undefined') {
|
|
1362
|
-
apiPayload['positions'] = positions;
|
|
1364
|
+
apiPayload['positions'] = Client.toWireKeys(positions, {"orderItemId":{"wire":"order_item_id","children":null}});
|
|
1363
1365
|
}
|
|
1364
1366
|
if (typeof reason !== 'undefined') {
|
|
1365
1367
|
apiPayload['reason'] = reason;
|
|
@@ -1658,7 +1660,7 @@ export class Orders {
|
|
|
1658
1660
|
apiPayload['number'] = number;
|
|
1659
1661
|
}
|
|
1660
1662
|
if (typeof positions !== 'undefined') {
|
|
1661
|
-
apiPayload['positions'] = positions;
|
|
1663
|
+
apiPayload['positions'] = Client.toWireKeys(positions, {"orderItemId":{"wire":"order_item_id","children":null}});
|
|
1662
1664
|
}
|
|
1663
1665
|
if (typeof shippedAt !== 'undefined') {
|
|
1664
1666
|
apiPayload['shipped_at'] = shippedAt;
|
package/src/services/prices.ts
CHANGED
|
@@ -687,7 +687,7 @@ export class Prices {
|
|
|
687
687
|
const apiPath = '/v1/prices/lists/{list_id}/entries'.replace('{list_id}', listId);
|
|
688
688
|
const apiPayload: Payload = {};
|
|
689
689
|
if (typeof entries !== 'undefined') {
|
|
690
|
-
apiPayload['entries'] = entries;
|
|
690
|
+
apiPayload['entries'] = Client.toWireKeys(entries, {"priceType":{"wire":"price_type","children":null},"productId":{"wire":"product_id","children":null},"quantityMin":{"wire":"quantity_min","children":null},"unitPrice":{"wire":"unit_price","children":null},"validFrom":{"wire":"valid_from","children":null},"validUntil":{"wire":"valid_until","children":null}});
|
|
691
691
|
}
|
|
692
692
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
693
693
|
|
|
@@ -748,7 +748,7 @@ export class Prices {
|
|
|
748
748
|
const apiPath = '/v1/prices/lists/{list_id}/entries/bulk'.replace('{list_id}', listId);
|
|
749
749
|
const apiPayload: Payload = {};
|
|
750
750
|
if (typeof entries !== 'undefined') {
|
|
751
|
-
apiPayload['entries'] = entries;
|
|
751
|
+
apiPayload['entries'] = Client.toWireKeys(entries, {"priceType":{"wire":"price_type","children":null},"productId":{"wire":"product_id","children":null},"quantityMin":{"wire":"quantity_min","children":null},"unitPrice":{"wire":"unit_price","children":null},"validFrom":{"wire":"valid_from","children":null},"validUntil":{"wire":"valid_until","children":null}});
|
|
752
752
|
}
|
|
753
753
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
754
754
|
|
|
@@ -1073,7 +1073,7 @@ export class Prices {
|
|
|
1073
1073
|
apiPayload['currency'] = currency;
|
|
1074
1074
|
}
|
|
1075
1075
|
if (typeof items !== 'undefined') {
|
|
1076
|
-
apiPayload['items'] = items;
|
|
1076
|
+
apiPayload['items'] = Client.toWireKeys(items, {"productId":{"wire":"product_id","children":null}});
|
|
1077
1077
|
}
|
|
1078
1078
|
if (typeof marketId !== 'undefined') {
|
|
1079
1079
|
apiPayload['market_id'] = marketId;
|