@revenexx/sdk 0.0.9 → 0.0.10
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 +291 -29
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +290 -30
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +291 -29
- 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 +1 -1
- package/src/services/inventories.ts +5 -5
- package/src/services/orderlists.ts +2 -2
- package/src/services/orders.ts +23 -21
- package/src/services/prices.ts +3 -3
- 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/orders.d.ts +13 -11
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;
|
package/src/services/search.ts
CHANGED
|
@@ -328,7 +328,7 @@ export class Search {
|
|
|
328
328
|
const apiPath = '/v1/search/multi_search';
|
|
329
329
|
const apiPayload: Payload = {};
|
|
330
330
|
if (typeof searches !== 'undefined') {
|
|
331
|
-
apiPayload['searches'] = searches;
|
|
331
|
+
apiPayload['searches'] = Client.toWireKeys(searches, {"facetBy":{"wire":"facet_by","children":null},"filterBy":{"wire":"filter_by","children":null},"perPage":{"wire":"per_page","children":null},"queryBy":{"wire":"query_by","children":null},"sortBy":{"wire":"sort_by","children":null}});
|
|
332
332
|
}
|
|
333
333
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
334
334
|
|
package/src/services/shipping.ts
CHANGED
|
@@ -659,7 +659,7 @@ export class Shipping {
|
|
|
659
659
|
const apiPath = '/v1/shipping/methods/{method_id}/tiers'.replace('{method_id}', methodId);
|
|
660
660
|
const apiPayload: Payload = {};
|
|
661
661
|
if (typeof tiers !== 'undefined') {
|
|
662
|
-
apiPayload['tiers'] = tiers;
|
|
662
|
+
apiPayload['tiers'] = Client.toWireKeys(tiers, {"fromValue":{"wire":"from_value","children":null}});
|
|
663
663
|
}
|
|
664
664
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
665
665
|
|
package/types/client.d.ts
CHANGED
|
@@ -202,6 +202,17 @@ declare class Client {
|
|
|
202
202
|
chunkedUpload(method: string, url: URL, headers: Headers | undefined, originalPayload: Payload | undefined, onProgress: (progress: UploadProgress) => void): Promise<any>;
|
|
203
203
|
ping(): Promise<string>;
|
|
204
204
|
call(method: string, url: URL, headers?: Headers, params?: Payload, responseType?: string): Promise<any>;
|
|
205
|
+
/**
|
|
206
|
+
* Recursively renames an argument's DECLARED keys to their snake_case wire
|
|
207
|
+
* names, using a map generated from the API contract. Free-form subtrees
|
|
208
|
+
* (metadata / user_data — keys absent from the map, with no `children`) are
|
|
209
|
+
* passed through untouched, so user data is never mangled. For arrays the
|
|
210
|
+
* same element map is applied to every item.
|
|
211
|
+
*/
|
|
212
|
+
static toWireKeys(value: any, map: Record<string, {
|
|
213
|
+
wire: string;
|
|
214
|
+
children: any;
|
|
215
|
+
}>): any;
|
|
205
216
|
static flatten(data: Payload, prefix?: string): Payload;
|
|
206
217
|
}
|
|
207
218
|
export { Client, RevenexxException };
|
package/types/index.d.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';
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Client } from '../client';
|
|
2
2
|
import type { Models } from '../models';
|
|
3
|
-
import {
|
|
3
|
+
import { OrderStatus } from '../enums/order-status';
|
|
4
4
|
import { OrderPaymentStatus } from '../enums/order-payment-status';
|
|
5
|
+
import { OrderFulfillmentStatus } from '../enums/order-fulfillment-status';
|
|
6
|
+
import { OrderCommentVisibility } from '../enums/order-comment-visibility';
|
|
5
7
|
export declare class Orders {
|
|
6
8
|
client: Client;
|
|
7
9
|
constructor(client: Client);
|
|
8
10
|
/**
|
|
9
11
|
*
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {OrderStatus} params.status - Filter by order status (exact match).
|
|
13
|
+
* @param {OrderPaymentStatus} params.paymentStatus - Filter by payment status (exact match).
|
|
14
|
+
* @param {OrderFulfillmentStatus} params.fulfillmentStatus - Filter by fulfillment status (exact match).
|
|
13
15
|
* @param {string} params.contactId - Filter to one ordering contact.
|
|
14
16
|
* @param {string} params.organizationId - Filter to one B2B organization.
|
|
15
17
|
* @param {string} params.channelId - Filter to one sales channel.
|
|
@@ -22,9 +24,9 @@ export declare class Orders {
|
|
|
22
24
|
* @returns {Promise<{}>}
|
|
23
25
|
*/
|
|
24
26
|
ordersList(params?: {
|
|
25
|
-
status?:
|
|
26
|
-
paymentStatus?:
|
|
27
|
-
fulfillmentStatus?:
|
|
27
|
+
status?: OrderStatus;
|
|
28
|
+
paymentStatus?: OrderPaymentStatus;
|
|
29
|
+
fulfillmentStatus?: OrderFulfillmentStatus;
|
|
28
30
|
contactId?: string;
|
|
29
31
|
organizationId?: string;
|
|
30
32
|
channelId?: string;
|
|
@@ -36,9 +38,9 @@ export declare class Orders {
|
|
|
36
38
|
}): Promise<{}>;
|
|
37
39
|
/**
|
|
38
40
|
*
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {
|
|
41
|
+
* @param {OrderStatus} status - Filter by order status (exact match).
|
|
42
|
+
* @param {OrderPaymentStatus} paymentStatus - Filter by payment status (exact match).
|
|
43
|
+
* @param {OrderFulfillmentStatus} fulfillmentStatus - Filter by fulfillment status (exact match).
|
|
42
44
|
* @param {string} contactId - Filter to one ordering contact.
|
|
43
45
|
* @param {string} organizationId - Filter to one B2B organization.
|
|
44
46
|
* @param {string} channelId - Filter to one sales channel.
|
|
@@ -51,7 +53,7 @@ export declare class Orders {
|
|
|
51
53
|
* @returns {Promise<{}>}
|
|
52
54
|
* @deprecated Use the object parameter style method for a better developer experience.
|
|
53
55
|
*/
|
|
54
|
-
ordersList(status?:
|
|
56
|
+
ordersList(status?: OrderStatus, paymentStatus?: OrderPaymentStatus, fulfillmentStatus?: OrderFulfillmentStatus, contactId?: string, organizationId?: string, channelId?: string, marketId?: string, number?: string, limit?: number, offset?: number, order?: string): Promise<{}>;
|
|
55
57
|
/**
|
|
56
58
|
*
|
|
57
59
|
* @throws {RevenexxException}
|