@djust-b2b/djust-front-sdk 2.6.0 → 2.7.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/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
export declare const DjustSDK: {
|
|
2
2
|
initialize: (initConfig: import("./settings/fetch-instance").ClientConfig) => void;
|
|
3
3
|
updateConfiguration: (newConfig: Partial<import("./settings/fetch-instance").ClientConfig>) => void;
|
|
4
|
+
getOperations({ page, size, sort, type, status, ids, name, startDateFrom, startDateTo, endDateFrom, endDateTo, ownerIds, idType, locale, }: import("./services/operation/definitions").GetOperationsParameters): Promise<import("./services/operation/definitions").GetOperationsResponse>;
|
|
5
|
+
getOperation({ operationId, }: import("./services/operation/definitions").GetOperationParameters): Promise<import("./services/operation/definitions").GetOperationResponse>;
|
|
6
|
+
updateOperation({ operationId, status, }: import("./services/operation/definitions").UpdateOperationParameters): Promise<void>;
|
|
7
|
+
updateOperationDetails({ operationId, customFieldValues, descriptions, endDate, names, startDate, }: import("./services/operation/definitions").UpdateOperationDetailsParameters): Promise<import("./services/operation/definitions").UpdateOperationDetailsResponse>;
|
|
8
|
+
removeOperationAccounts({ operationId, accountIds, }: import("./services/operation/definitions").RemoveOperationAccountsParameters): Promise<void>;
|
|
9
|
+
getOperationAccounts({ operationId, page, size, sort, accountIds, accountName, }: import("./services/operation/definitions").GetOperationAccountsParameters): Promise<import("./services/operation/definitions").GetOperationAccountsResponse>;
|
|
10
|
+
addOperationAccounts({ operationId, accountIds, }: import("./services/operation/definitions").AddOperationAccountsParameters): Promise<void>;
|
|
11
|
+
removeOperationLines({ operationId, variantIds, }: import("./services/operation/definitions").RemoveOperationLinesParameters): Promise<void>;
|
|
12
|
+
getOperationLines({ operationId, page, size, sort, variantIds, variantName, minQuantity, maxQuantity, recommendedQuantity, locale, }: import("./services/operation/definitions").GetOperationLinesParameters): Promise<import("./services/operation/definitions").GetOperationLinesResponse>;
|
|
13
|
+
addOperationLines({ operationId, lines, }: import("./services/operation/definitions").AddOperationLinesParameters): Promise<void>;
|
|
14
|
+
createOperation({ customFieldValues, descriptions, endDate, externalId, names, startDate, type, }: import("./services/operation/definitions").CreateOperationParameters): Promise<import("./services/operation/definitions").CreateOperationResponse>;
|
|
15
|
+
deleteOperation({ operationId, }: import("./services/operation/definitions").DeleteOperationParameters): Promise<void>;
|
|
4
16
|
initPayment({ browserInfo, countryCode, customerUserIP, paymentMethodData, reference, referenceType, returnPath, storePaymentMethod, }: import("./services/payment/definitions").InitPaymentRequest): Promise<import("./services/payment/definitions").InitPaymentResponse>;
|
|
5
17
|
getPaymentDetails({ details, }: import("./services/payment/definitions").GetPaymentDetailsRequest): Promise<import("./services/payment/definitions").GetPaymentDetailsResponse>;
|
|
6
18
|
getPaymentMethods({ reference, countryCode, referenceType, locale, }: import("./services/payment/definitions").GetPaymentMethodsRequest): Promise<import("./services/payment/definitions").GetPaymentMethodsResponse>;
|
package/lib/index.js
CHANGED
|
@@ -52,6 +52,7 @@ const IncidentServices = __importStar(require("./services/incident"));
|
|
|
52
52
|
const OfferServices = __importStar(require("./services/offer-inventories"));
|
|
53
53
|
const CustomFieldServices = __importStar(require("./services/custom-field"));
|
|
54
54
|
const PaymentServices = __importStar(require("./services/payment"));
|
|
55
|
+
const OperationServices = __importStar(require("./services/operation"));
|
|
55
56
|
const fetch_instance_1 = require("./settings/fetch-instance");
|
|
56
57
|
exports.DjustSDK = {
|
|
57
58
|
...AuthServices,
|
|
@@ -69,6 +70,7 @@ exports.DjustSDK = {
|
|
|
69
70
|
...OfferServices,
|
|
70
71
|
...CustomFieldServices,
|
|
71
72
|
...PaymentServices,
|
|
73
|
+
...OperationServices,
|
|
72
74
|
initialize: fetch_instance_1.initialize,
|
|
73
75
|
updateConfiguration: fetch_instance_1.updateConfiguration,
|
|
74
76
|
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { IdType } from "../../interfaces/models/common";
|
|
2
|
+
/**
|
|
3
|
+
* Enums
|
|
4
|
+
*/
|
|
5
|
+
export declare enum OperationType {
|
|
6
|
+
PUBLIC = "PUBLIC",
|
|
7
|
+
PRIVATE = "PRIVATE"
|
|
8
|
+
}
|
|
9
|
+
export declare enum OperationStatus {
|
|
10
|
+
DRAFT = "DRAFT",
|
|
11
|
+
ACTIVE = "ACTIVE",
|
|
12
|
+
INACTIVE = "INACTIVE"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Request parameters type definitions
|
|
16
|
+
*/
|
|
17
|
+
export interface GetOperationsParameters {
|
|
18
|
+
page?: number;
|
|
19
|
+
size?: number;
|
|
20
|
+
sort?: string[];
|
|
21
|
+
type?: OperationType;
|
|
22
|
+
status?: OperationStatus;
|
|
23
|
+
ids?: string[];
|
|
24
|
+
name?: string;
|
|
25
|
+
startDateFrom?: string;
|
|
26
|
+
startDateTo?: string;
|
|
27
|
+
endDateFrom?: string;
|
|
28
|
+
endDateTo?: string;
|
|
29
|
+
ownerIds?: string[];
|
|
30
|
+
idType?: IdType;
|
|
31
|
+
locale?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface CreateOperationParameters {
|
|
34
|
+
customFieldValues?: {
|
|
35
|
+
customFieldId: string;
|
|
36
|
+
customFieldValue: string;
|
|
37
|
+
}[];
|
|
38
|
+
descriptions?: string;
|
|
39
|
+
endDate: string;
|
|
40
|
+
externalId: string;
|
|
41
|
+
names: string;
|
|
42
|
+
startDate: string;
|
|
43
|
+
type: OperationType;
|
|
44
|
+
}
|
|
45
|
+
export interface DeleteOperationParameters {
|
|
46
|
+
operationId: string;
|
|
47
|
+
}
|
|
48
|
+
export interface GetOperationParameters {
|
|
49
|
+
operationId: string;
|
|
50
|
+
}
|
|
51
|
+
export interface UpdateOperationParameters {
|
|
52
|
+
operationId: string;
|
|
53
|
+
status: OperationStatus;
|
|
54
|
+
}
|
|
55
|
+
export interface UpdateOperationDetailsParameters {
|
|
56
|
+
operationId: string;
|
|
57
|
+
customFieldValues?: {
|
|
58
|
+
customFieldId: string;
|
|
59
|
+
customFieldValue: string;
|
|
60
|
+
}[];
|
|
61
|
+
descriptions?: string;
|
|
62
|
+
endDate?: string;
|
|
63
|
+
names?: string;
|
|
64
|
+
startDate?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface RemoveOperationAccountsParameters {
|
|
67
|
+
operationId: string;
|
|
68
|
+
accountIds: string[];
|
|
69
|
+
}
|
|
70
|
+
export interface GetOperationAccountsParameters {
|
|
71
|
+
operationId: string;
|
|
72
|
+
page?: number;
|
|
73
|
+
size?: number;
|
|
74
|
+
sort?: string[];
|
|
75
|
+
accountIds?: string[];
|
|
76
|
+
accountName?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface AddOperationAccountsParameters {
|
|
79
|
+
operationId: string;
|
|
80
|
+
accountIds: string[];
|
|
81
|
+
}
|
|
82
|
+
export interface RemoveOperationLinesParameters {
|
|
83
|
+
operationId: string;
|
|
84
|
+
variantIds: string[];
|
|
85
|
+
}
|
|
86
|
+
export interface GetOperationLinesParameters {
|
|
87
|
+
operationId: string;
|
|
88
|
+
page?: number;
|
|
89
|
+
size?: number;
|
|
90
|
+
sort?: string[];
|
|
91
|
+
variantIds?: string[];
|
|
92
|
+
variantName?: string;
|
|
93
|
+
minQuantity?: number;
|
|
94
|
+
maxQuantity?: number;
|
|
95
|
+
recommendedQuantity?: number;
|
|
96
|
+
locale?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface AddOperationLinesParameters {
|
|
99
|
+
operationId: string;
|
|
100
|
+
lines: {
|
|
101
|
+
variantId: string;
|
|
102
|
+
minQuantity: number;
|
|
103
|
+
maxQuantity: number;
|
|
104
|
+
recommendedQuantity: number;
|
|
105
|
+
}[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Response type definitions
|
|
109
|
+
*/
|
|
110
|
+
export interface Operation {
|
|
111
|
+
id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
type: OperationType;
|
|
114
|
+
status: OperationStatus;
|
|
115
|
+
startDate: string;
|
|
116
|
+
endDate: string;
|
|
117
|
+
createdDate: string;
|
|
118
|
+
updatedDate: string;
|
|
119
|
+
ownerId: string;
|
|
120
|
+
ownerExternalId: string;
|
|
121
|
+
ownerFirstName: string;
|
|
122
|
+
ownerLastName: string;
|
|
123
|
+
externalId: string;
|
|
124
|
+
}
|
|
125
|
+
export interface GetOperationsResponse {
|
|
126
|
+
content: Operation[];
|
|
127
|
+
empty: boolean;
|
|
128
|
+
first: boolean;
|
|
129
|
+
last: boolean;
|
|
130
|
+
number: number;
|
|
131
|
+
numberOfElements: number;
|
|
132
|
+
size: number;
|
|
133
|
+
sort: string[];
|
|
134
|
+
}
|
|
135
|
+
export interface CreateOperationResponse {
|
|
136
|
+
id: string;
|
|
137
|
+
}
|
|
138
|
+
export interface UpdateOperationDetailsResponse {
|
|
139
|
+
id: string;
|
|
140
|
+
}
|
|
141
|
+
export interface OperationAccount {
|
|
142
|
+
accountId: string;
|
|
143
|
+
accountName: string;
|
|
144
|
+
}
|
|
145
|
+
export interface GetOperationAccountsResponse {
|
|
146
|
+
content: OperationAccount[];
|
|
147
|
+
empty: boolean;
|
|
148
|
+
first: boolean;
|
|
149
|
+
last: boolean;
|
|
150
|
+
number: number;
|
|
151
|
+
numberOfElements: number;
|
|
152
|
+
size: number;
|
|
153
|
+
sort: string[];
|
|
154
|
+
}
|
|
155
|
+
export interface OperationLine {
|
|
156
|
+
variantId: string;
|
|
157
|
+
variantName: string;
|
|
158
|
+
minQuantity: number;
|
|
159
|
+
maxQuantity: number;
|
|
160
|
+
recommendedQuantity: number;
|
|
161
|
+
}
|
|
162
|
+
export interface GetOperationLinesResponse {
|
|
163
|
+
content: OperationLine[];
|
|
164
|
+
empty: boolean;
|
|
165
|
+
first: boolean;
|
|
166
|
+
last: boolean;
|
|
167
|
+
number: number;
|
|
168
|
+
numberOfElements: number;
|
|
169
|
+
size: number;
|
|
170
|
+
sort: string[];
|
|
171
|
+
}
|
|
172
|
+
export interface CustomField {
|
|
173
|
+
externalId: string;
|
|
174
|
+
externalSource: string;
|
|
175
|
+
faceted: boolean;
|
|
176
|
+
id: string;
|
|
177
|
+
indexable: boolean;
|
|
178
|
+
mandatory: boolean;
|
|
179
|
+
name: Record<string, string>;
|
|
180
|
+
role: string;
|
|
181
|
+
sealedTarget: string;
|
|
182
|
+
searchable: boolean;
|
|
183
|
+
sortable: boolean;
|
|
184
|
+
status: string;
|
|
185
|
+
}
|
|
186
|
+
export interface CustomFieldValue {
|
|
187
|
+
customField: CustomField;
|
|
188
|
+
value: any;
|
|
189
|
+
}
|
|
190
|
+
export interface GetOperationResponse {
|
|
191
|
+
id: string;
|
|
192
|
+
name: string;
|
|
193
|
+
type: OperationType;
|
|
194
|
+
status: OperationStatus;
|
|
195
|
+
startDate: string;
|
|
196
|
+
endDate: string;
|
|
197
|
+
createdDate: string;
|
|
198
|
+
updatedDate: string;
|
|
199
|
+
ownerId: string;
|
|
200
|
+
ownerExternalId: string;
|
|
201
|
+
ownerFirstName: string;
|
|
202
|
+
ownerLastName: string;
|
|
203
|
+
externalId: string;
|
|
204
|
+
names: string;
|
|
205
|
+
descriptions: string;
|
|
206
|
+
customFieldValues: CustomFieldValue[];
|
|
207
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationStatus = exports.OperationType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enums
|
|
6
|
+
*/
|
|
7
|
+
var OperationType;
|
|
8
|
+
(function (OperationType) {
|
|
9
|
+
OperationType["PUBLIC"] = "PUBLIC";
|
|
10
|
+
OperationType["PRIVATE"] = "PRIVATE";
|
|
11
|
+
})(OperationType || (exports.OperationType = OperationType = {}));
|
|
12
|
+
var OperationStatus;
|
|
13
|
+
(function (OperationStatus) {
|
|
14
|
+
OperationStatus["DRAFT"] = "DRAFT";
|
|
15
|
+
OperationStatus["ACTIVE"] = "ACTIVE";
|
|
16
|
+
OperationStatus["INACTIVE"] = "INACTIVE";
|
|
17
|
+
})(OperationStatus || (exports.OperationStatus = OperationStatus = {}));
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import { GetOperationsParameters, GetOperationsResponse, CreateOperationParameters, CreateOperationResponse, DeleteOperationParameters, GetOperationParameters, GetOperationResponse, UpdateOperationParameters, UpdateOperationDetailsParameters, UpdateOperationDetailsResponse, RemoveOperationAccountsParameters, GetOperationAccountsParameters, GetOperationAccountsResponse, AddOperationAccountsParameters, RemoveOperationLinesParameters, GetOperationLinesParameters, GetOperationLinesResponse, AddOperationLinesParameters } from "./definitions";
|
|
2
|
+
/**
|
|
3
|
+
* OPERATION ENDPOINT
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 🎯 Gets operations.
|
|
7
|
+
*
|
|
8
|
+
* This function retrieves all operations with optional filtering and pagination.
|
|
9
|
+
* The function supports various filters including type, status, date ranges, and more.
|
|
10
|
+
*
|
|
11
|
+
* 🛠 **Endpoint**: `GET /v1/operations`
|
|
12
|
+
*
|
|
13
|
+
* | Parameter | Type | Required | Description |
|
|
14
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
15
|
+
* | `page` | `number` | ❌ | The page number to retrieve (0-based). |
|
|
16
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
17
|
+
* | `sort` | `string[]` | ❌ | The sort to apply to the results. |
|
|
18
|
+
* | `type` | `OperationType` | ❌ | Visibility type filter; accepts OperationType.PUBLIC or OperationType.PRIVATE. |
|
|
19
|
+
* | `status` | `OperationStatus` | ❌ | Operation status filter; accepts OperationStatus.DRAFT, OperationStatus.ACTIVE or OperationStatus.INACTIVE. |
|
|
20
|
+
* | `ids` | `string[]` | ❌ | Filter by operation IDs. |
|
|
21
|
+
* | `name` | `string` | ❌ | Case-insensitive substring match on Operation name. |
|
|
22
|
+
* | `startDateFrom` | `string` | ❌ | Return Operations starting on or after this ISO date (inclusive). |
|
|
23
|
+
* | `startDateTo` | `string` | ❌ | Return Operations starting on or before this ISO date (inclusive). |
|
|
24
|
+
* | `endDateFrom` | `string` | ❌ | Return Operations ending on or after this ISO date (inclusive). |
|
|
25
|
+
* | `endDateTo` | `string` | ❌ | Return Operations ending on or before this ISO date (inclusive). |
|
|
26
|
+
* | `ownerIds` | `string[]` | ❌ | Filter by Owner user identifier (Operator only). |
|
|
27
|
+
* | `idType` | `string` | ❌ | Type of operation identifiers provided in the id query parameter. |
|
|
28
|
+
* | `locale` | `string` | ❌ | Locale to use for localized fields (e.g., `name`). |
|
|
29
|
+
*
|
|
30
|
+
* 📤 **Returns**:
|
|
31
|
+
* A `Promise` resolving to a single `GetOperationsResponse` object representing the page of operations.
|
|
32
|
+
*
|
|
33
|
+
* 🛠 **Example usage**:
|
|
34
|
+
* ```ts
|
|
35
|
+
* const operations = await getOperations({
|
|
36
|
+
* page: 0,
|
|
37
|
+
* size: 10,
|
|
38
|
+
* status: OperationStatus.ACTIVE,
|
|
39
|
+
* type: OperationType.PUBLIC
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param {GetOperationsParameters} params - The parameters for the request.
|
|
44
|
+
* @returns {Promise<GetOperationsResponse>} A promise resolving to the response containing page object.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getOperations({ page, size, sort, type, status, ids, name, startDateFrom, startDateTo, endDateFrom, endDateTo, ownerIds, idType, locale, }: GetOperationsParameters): Promise<GetOperationsResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* 🔍 Gets a single operation by ID.
|
|
49
|
+
*
|
|
50
|
+
* This function retrieves detailed information about a specific operation
|
|
51
|
+
* including custom field values, owner information, and localized content.
|
|
52
|
+
*
|
|
53
|
+
* 🛠 **Endpoint**: `GET /v1/operations/{operationId}`
|
|
54
|
+
*
|
|
55
|
+
* | Parameter | Type | Required | Description |
|
|
56
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
57
|
+
* | `operationId` | `string` | ✅ | Operation identifier to retrieve. |
|
|
58
|
+
*
|
|
59
|
+
* 📤 **Returns**:
|
|
60
|
+
* A `Promise` resolving to a single `GetOperationResponse` object containing the operation details.
|
|
61
|
+
*
|
|
62
|
+
* 🛠 **Example usage**:
|
|
63
|
+
* ```ts
|
|
64
|
+
* const operation = await getOperation({
|
|
65
|
+
* operationId: "ope_123"
|
|
66
|
+
* });
|
|
67
|
+
* console.log(operation.name);
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param {GetOperationParameters} params - The parameters for retrieving the operation.
|
|
71
|
+
* @returns {Promise<GetOperationResponse>} A promise resolving to the operation details.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getOperation({ operationId, }: GetOperationParameters): Promise<GetOperationResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* ✏️ Updates an operation status.
|
|
76
|
+
*
|
|
77
|
+
* This function updates the status of an existing operation.
|
|
78
|
+
* The operation must exist and the user must have the appropriate permissions.
|
|
79
|
+
*
|
|
80
|
+
* 🛠 **Endpoint**: `PATCH /v1/operations/{operationId}`
|
|
81
|
+
*
|
|
82
|
+
* | Parameter | Type | Required | Description |
|
|
83
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
84
|
+
* | `operationId` | `string` | ✅ | Operation identifier to update. |
|
|
85
|
+
* | `status` | `OperationStatus` | ✅ | New status for the operation (OperationStatus.DRAFT, OperationStatus.ACTIVE, or OperationStatus.INACTIVE). |
|
|
86
|
+
*
|
|
87
|
+
* 📤 **Returns**:
|
|
88
|
+
* A `Promise` resolving to `void` when the operation status is successfully updated.
|
|
89
|
+
*
|
|
90
|
+
* 🛠 **Example usage**:
|
|
91
|
+
* ```ts
|
|
92
|
+
* await updateOperation({
|
|
93
|
+
* operationId: "ope_456",
|
|
94
|
+
* status: OperationStatus.ACTIVE
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param {UpdateOperationParameters} params - The parameters for updating the operation.
|
|
99
|
+
* @returns {Promise<void>} A promise that resolves when the operation is updated.
|
|
100
|
+
*/
|
|
101
|
+
export declare function updateOperation({ operationId, status, }: UpdateOperationParameters): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* ✏️ Updates operation details.
|
|
104
|
+
*
|
|
105
|
+
* This function updates the details of an existing operation including
|
|
106
|
+
* custom field values, descriptions, names, and date ranges.
|
|
107
|
+
*
|
|
108
|
+
* 🛠 **Endpoint**: `PUT /v1/operations/{operationId}`
|
|
109
|
+
*
|
|
110
|
+
* | Parameter | Type | Required | Description |
|
|
111
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
112
|
+
* | `operationId` | `string` | ✅ | Operation identifier to update. |
|
|
113
|
+
* | `customFieldValues` | `object[]` | ❌ | Array of custom field values. |
|
|
114
|
+
* | `descriptions` | `string` | ❌ | Localized descriptions in JSON format. |
|
|
115
|
+
* | `endDate` | `string` | ❌ | End date of the operation in ISO format. |
|
|
116
|
+
* | `names` | `string` | ❌ | Localized names in JSON format. |
|
|
117
|
+
* | `startDate` | `string` | ❌ | Start date of the operation in ISO format. |
|
|
118
|
+
*
|
|
119
|
+
* 📤 **Returns**:
|
|
120
|
+
* A `Promise` resolving to a single `UpdateOperationDetailsResponse` object containing the updated operation ID.
|
|
121
|
+
*
|
|
122
|
+
* 🛠 **Example usage**:
|
|
123
|
+
* ```ts
|
|
124
|
+
* const updatedOperation = await updateOperationDetails({
|
|
125
|
+
* operationId: "ope_456",
|
|
126
|
+
* names: "{\"en-GB\": \"Updated Operation\", \"fr-FR\": \"Opération Mise à Jour\"}",
|
|
127
|
+
* descriptions: "{\"en-GB\": \"Updated Description\", \"fr-FR\": \"Description Mise à Jour\"}",
|
|
128
|
+
* startDate: "2025-12-01T00:00:00Z",
|
|
129
|
+
* endDate: "2025-12-31T23:59:59Z",
|
|
130
|
+
* customFieldValues: [
|
|
131
|
+
* {
|
|
132
|
+
* customFieldId: "field123",
|
|
133
|
+
* customFieldValue: "updated_value"
|
|
134
|
+
* }
|
|
135
|
+
* ]
|
|
136
|
+
* });
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @param {UpdateOperationDetailsParameters} params - The parameters for updating the operation details.
|
|
140
|
+
* @returns {Promise<UpdateOperationDetailsResponse>} A promise resolving to the response containing the operation ID.
|
|
141
|
+
*/
|
|
142
|
+
export declare function updateOperationDetails({ operationId, customFieldValues, descriptions, endDate, names, startDate, }: UpdateOperationDetailsParameters): Promise<UpdateOperationDetailsResponse>;
|
|
143
|
+
/**
|
|
144
|
+
* 🗑️ Removes accounts from an operation.
|
|
145
|
+
*
|
|
146
|
+
* This function removes one or more accounts from an existing operation.
|
|
147
|
+
* The operation must exist and the user must have the appropriate permissions.
|
|
148
|
+
*
|
|
149
|
+
* 🛠 **Endpoint**: `DELETE /v1/operations/{operationId}/accounts`
|
|
150
|
+
*
|
|
151
|
+
* | Parameter | Type | Required | Description |
|
|
152
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
153
|
+
* | `operationId` | `string` | ✅ | Operation identifier to remove accounts from. |
|
|
154
|
+
* | `accountIds` | `string[]` | ✅ | Array of account identifiers to remove. |
|
|
155
|
+
*
|
|
156
|
+
* 📤 **Returns**:
|
|
157
|
+
* A `Promise` resolving to `void` when the accounts are successfully removed from the operation.
|
|
158
|
+
*
|
|
159
|
+
* 🛠 **Example usage**:
|
|
160
|
+
* ```ts
|
|
161
|
+
* await removeOperationAccounts({
|
|
162
|
+
* operationId: "ope_123",
|
|
163
|
+
* accountIds: ["acc_123", "acc_456"]
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @param {RemoveOperationAccountsParameters} params - The parameters for removing accounts from the operation.
|
|
168
|
+
* @returns {Promise<void>} A promise that resolves when the accounts are removed.
|
|
169
|
+
*/
|
|
170
|
+
export declare function removeOperationAccounts({ operationId, accountIds, }: RemoveOperationAccountsParameters): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* 👥 Gets accounts linked to an operation.
|
|
173
|
+
*
|
|
174
|
+
* This function retrieves a paginated list of accounts linked to a specific operation.
|
|
175
|
+
* The operation must be PRIVATE and the user must have the appropriate permissions.
|
|
176
|
+
*
|
|
177
|
+
* 🛠 **Endpoint**: `GET /v1/operations/{operationId}/accounts`
|
|
178
|
+
*
|
|
179
|
+
* | Parameter | Type | Required | Description |
|
|
180
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
181
|
+
* | `operationId` | `string` | ✅ | Operation identifier (must be PRIVATE). |
|
|
182
|
+
* | `page` | `number` | ❌ | The page number to retrieve (0-based). |
|
|
183
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
184
|
+
* | `sort` | `string[]` | ❌ | The sort to apply to the results. |
|
|
185
|
+
* | `accountIds` | `string[]` | ❌ | Filter by a list of external account identifiers. |
|
|
186
|
+
* | `accountName` | `string` | ❌ | Filter by account name (case-insensitive substring). |
|
|
187
|
+
*
|
|
188
|
+
* 📤 **Returns**:
|
|
189
|
+
* A `Promise` resolving to a single `GetOperationAccountsResponse` object representing the page of accounts.
|
|
190
|
+
*
|
|
191
|
+
* 🛠 **Example usage**:
|
|
192
|
+
* ```ts
|
|
193
|
+
* const accounts = await getOperationAccounts({
|
|
194
|
+
* operationId: "ope_123",
|
|
195
|
+
* page: 0,
|
|
196
|
+
* size: 20,
|
|
197
|
+
* accountName: "Store"
|
|
198
|
+
* });
|
|
199
|
+
* console.log('Linked accounts:', accounts.content);
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @param {GetOperationAccountsParameters} params - The parameters for the request.
|
|
203
|
+
* @returns {Promise<GetOperationAccountsResponse>} A promise resolving to the response containing page of accounts.
|
|
204
|
+
*/
|
|
205
|
+
export declare function getOperationAccounts({ operationId, page, size, sort, accountIds, accountName, }: GetOperationAccountsParameters): Promise<GetOperationAccountsResponse>;
|
|
206
|
+
/**
|
|
207
|
+
* ➕ Adds accounts to an operation.
|
|
208
|
+
*
|
|
209
|
+
* This function adds one or more accounts to an existing operation.
|
|
210
|
+
* The operation must exist and the user must have the appropriate permissions.
|
|
211
|
+
*
|
|
212
|
+
* 🛠 **Endpoint**: `PUT /v1/operations/{operationId}/accounts`
|
|
213
|
+
*
|
|
214
|
+
* | Parameter | Type | Required | Description |
|
|
215
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
216
|
+
* | `operationId` | `string` | ✅ | Operation identifier to add accounts to. |
|
|
217
|
+
* | `accountIds` | `string[]` | ✅ | Array of account identifiers to add. |
|
|
218
|
+
*
|
|
219
|
+
* 📤 **Returns**:
|
|
220
|
+
* A `Promise` resolving to `void` when the accounts are successfully added to the operation.
|
|
221
|
+
*
|
|
222
|
+
* 🛠 **Example usage**:
|
|
223
|
+
* ```ts
|
|
224
|
+
* await addOperationAccounts({
|
|
225
|
+
* operationId: "ope_123",
|
|
226
|
+
* accountIds: ["ACC-001", "ACC-002", "ACC-XYZ"]
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @param {AddOperationAccountsParameters} params - The parameters for adding accounts to the operation.
|
|
231
|
+
* @returns {Promise<void>} A promise that resolves when the accounts are added.
|
|
232
|
+
*/
|
|
233
|
+
export declare function addOperationAccounts({ operationId, accountIds, }: AddOperationAccountsParameters): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* 🗑️ Removes variants from an operation.
|
|
236
|
+
*
|
|
237
|
+
* This function removes one or more variants from an existing operation.
|
|
238
|
+
* The operation must exist and the user must have the appropriate permissions.
|
|
239
|
+
*
|
|
240
|
+
* 🛠 **Endpoint**: `DELETE /v1/operations/{operationId}/lines`
|
|
241
|
+
*
|
|
242
|
+
* | Parameter | Type | Required | Description |
|
|
243
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
244
|
+
* | `operationId` | `string` | ✅ | Operation identifier to remove variants from. |
|
|
245
|
+
* | `variantIds` | `string[]` | ✅ | Array of variant identifiers to remove. |
|
|
246
|
+
*
|
|
247
|
+
* 📤 **Returns**:
|
|
248
|
+
* A `Promise` resolving to `void` when the variants are successfully removed from the operation.
|
|
249
|
+
*
|
|
250
|
+
* 🛠 **Example usage**:
|
|
251
|
+
* ```ts
|
|
252
|
+
* await removeOperationLines({
|
|
253
|
+
* operationId: "ope_123",
|
|
254
|
+
* variantIds: ["VAR-001", "VAR-002", "VAR-003"]
|
|
255
|
+
* });
|
|
256
|
+
* ```
|
|
257
|
+
*
|
|
258
|
+
* @param {RemoveOperationLinesParameters} params - The parameters for removing variants from the operation.
|
|
259
|
+
* @returns {Promise<void>} A promise that resolves when the variants are removed.
|
|
260
|
+
*/
|
|
261
|
+
export declare function removeOperationLines({ operationId, variantIds, }: RemoveOperationLinesParameters): Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* 📦 Gets variants linked to an operation.
|
|
264
|
+
*
|
|
265
|
+
* This function retrieves a paginated list of variants linked to a specific operation
|
|
266
|
+
* with various filtering options including quantity ranges and variant names.
|
|
267
|
+
*
|
|
268
|
+
* 🛠 **Endpoint**: `GET /v1/operations/{operationId}/lines`
|
|
269
|
+
*
|
|
270
|
+
* | Parameter | Type | Required | Description |
|
|
271
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
272
|
+
* | `operationId` | `string` | ✅ | Operation identifier. |
|
|
273
|
+
* | `page` | `number` | ❌ | The page number to retrieve (0-based). |
|
|
274
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
275
|
+
* | `sort` | `string[]` | ❌ | The sort to apply to the results. |
|
|
276
|
+
* | `variantIds` | `string[]` | ❌ | Filter by a list of external variant IDs. |
|
|
277
|
+
* | `variantName` | `string` | ❌ | Filter by variant name (case-insensitive, partial or exact match). |
|
|
278
|
+
* | `minQuantity` | `number` | ❌ | Filter variants where minQuantity equals this value. |
|
|
279
|
+
* | `maxQuantity` | `number` | ❌ | Filter variants where maxQuantity equals this value. |
|
|
280
|
+
* | `recommendedQuantity` | `number` | ❌ | Filter variants where recommendedQuantity equals this value. |
|
|
281
|
+
* | `locale` | `string` | ❌ | Locale to use for localized fields. |
|
|
282
|
+
*
|
|
283
|
+
* 📤 **Returns**:
|
|
284
|
+
* A `Promise` resolving to a single `GetOperationLinesResponse` object representing the page of variants.
|
|
285
|
+
*
|
|
286
|
+
* 🛠 **Example usage**:
|
|
287
|
+
* ```ts
|
|
288
|
+
* const variants = await getOperationLines({
|
|
289
|
+
* operationId: "ope_123",
|
|
290
|
+
* page: 0,
|
|
291
|
+
* size: 20,
|
|
292
|
+
* variantName: "Shirt",
|
|
293
|
+
* minQuantity: 2,
|
|
294
|
+
* maxQuantity: 10
|
|
295
|
+
* });
|
|
296
|
+
* console.log('Linked variants:', variants.content);
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @param {GetOperationLinesParameters} params - The parameters for the request.
|
|
300
|
+
* @returns {Promise<GetOperationLinesResponse>} A promise resolving to the response containing page of variants.
|
|
301
|
+
*/
|
|
302
|
+
export declare function getOperationLines({ operationId, page, size, sort, variantIds, variantName, minQuantity, maxQuantity, recommendedQuantity, locale, }: GetOperationLinesParameters): Promise<GetOperationLinesResponse>;
|
|
303
|
+
/**
|
|
304
|
+
* ➕ Adds variants to an operation.
|
|
305
|
+
*
|
|
306
|
+
* This function adds one or more variants to an existing operation with
|
|
307
|
+
* their associated quantity constraints (min, max, and recommended quantities).
|
|
308
|
+
*
|
|
309
|
+
* 🛠 **Endpoint**: `PUT /v1/operations/{operationId}/lines`
|
|
310
|
+
*
|
|
311
|
+
* | Parameter | Type | Required | Description |
|
|
312
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
313
|
+
* | `operationId` | `string` | ✅ | Operation identifier to add variants to. |
|
|
314
|
+
* | `lines` | `object[]` | ✅ | Array of variant lines with quantity constraints. |
|
|
315
|
+
* | `lines[].variantId` | `string` | ✅ | Variant identifier to add. |
|
|
316
|
+
* | `lines[].minQuantity` | `number` | ✅ | Minimum quantity for this variant. |
|
|
317
|
+
* | `lines[].maxQuantity` | `number` | ✅ | Maximum quantity for this variant. |
|
|
318
|
+
* | `lines[].recommendedQuantity` | `number` | ✅ | Recommended quantity for this variant. |
|
|
319
|
+
*
|
|
320
|
+
* 📤 **Returns**:
|
|
321
|
+
* A `Promise` resolving to `void` when the variants are successfully added to the operation.
|
|
322
|
+
*
|
|
323
|
+
* 🛠 **Example usage**:
|
|
324
|
+
* ```ts
|
|
325
|
+
* await addOperationLines({
|
|
326
|
+
* operationId: "ope_123",
|
|
327
|
+
* lines: [
|
|
328
|
+
* {
|
|
329
|
+
* variantId: "VAR-001",
|
|
330
|
+
* minQuantity: 2,
|
|
331
|
+
* maxQuantity: 10,
|
|
332
|
+
* recommendedQuantity: 5
|
|
333
|
+
* },
|
|
334
|
+
* {
|
|
335
|
+
* variantId: "VAR-002",
|
|
336
|
+
* minQuantity: 1,
|
|
337
|
+
* maxQuantity: 5,
|
|
338
|
+
* recommendedQuantity: 3
|
|
339
|
+
* }
|
|
340
|
+
* ]
|
|
341
|
+
* });
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* @param {AddOperationLinesParameters} params - The parameters for adding variants to the operation.
|
|
345
|
+
* @returns {Promise<void>} A promise that resolves when the variants are added.
|
|
346
|
+
*/
|
|
347
|
+
export declare function addOperationLines({ operationId, lines, }: AddOperationLinesParameters): Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* ➕ Creates a new operation.
|
|
350
|
+
*
|
|
351
|
+
* This function creates a new operation with the provided parameters.
|
|
352
|
+
* The function supports custom field values, localized descriptions and names.
|
|
353
|
+
*
|
|
354
|
+
* 🛠 **Endpoint**: `POST /v1/operations`
|
|
355
|
+
*
|
|
356
|
+
* | Parameter | Type | Required | Description |
|
|
357
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
358
|
+
* | `customFieldValues` | `object[]` | ❌ | Array of custom field values. |
|
|
359
|
+
* | `descriptions` | `string` | ❌ | Localized descriptions in JSON format. |
|
|
360
|
+
* | `endDate` | `string` | ✅ | End date of the operation in ISO format. |
|
|
361
|
+
* | `externalId` | `string` | ✅ | External identifier for the operation. |
|
|
362
|
+
* | `names` | `string` | ✅ | Localized names in JSON format. |
|
|
363
|
+
* | `startDate` | `string` | ✅ | Start date of the operation in ISO format. |
|
|
364
|
+
* | `type` | `OperationType` | ✅ | Type of the operation (OperationType.PUBLIC or OperationType.PRIVATE). |
|
|
365
|
+
*
|
|
366
|
+
* 📤 **Returns**:
|
|
367
|
+
* A `Promise` resolving to a single `CreateOperationResponse` object containing the created operation ID.
|
|
368
|
+
*
|
|
369
|
+
* 🛠 **Example usage**:
|
|
370
|
+
* ```ts
|
|
371
|
+
* const operation = await createOperation({
|
|
372
|
+
* externalId: "SUMMER_OPE_0825",
|
|
373
|
+
* names: "{\"en-GB\": \"Summer Operation\", \"fr-FR\": \"Opération Été\"}",
|
|
374
|
+
* descriptions: "{\"en-GB\": \"Summer Operation · Fine Food\", \"fr-FR\": \"Opération Été · Produits raffinés\"}",
|
|
375
|
+
* startDate: "2025-11-21T00:00:00Z",
|
|
376
|
+
* endDate: "2025-11-28T23:59:59Z",
|
|
377
|
+
* type: OperationType.PRIVATE,
|
|
378
|
+
* customFieldValues: [
|
|
379
|
+
* {
|
|
380
|
+
* customFieldId: "field123",
|
|
381
|
+
* customFieldValue: "value456"
|
|
382
|
+
* }
|
|
383
|
+
* ]
|
|
384
|
+
* });
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* @param {CreateOperationParameters} params - The parameters for creating the operation.
|
|
388
|
+
* @returns {Promise<CreateOperationResponse>} A promise resolving to the response containing the operation ID.
|
|
389
|
+
*/
|
|
390
|
+
export declare function createOperation({ customFieldValues, descriptions, endDate, externalId, names, startDate, type, }: CreateOperationParameters): Promise<CreateOperationResponse>;
|
|
391
|
+
/**
|
|
392
|
+
* 🗑️ Deletes an operation.
|
|
393
|
+
*
|
|
394
|
+
* This function deletes an operation by its identifier.
|
|
395
|
+
* The operation must not be linked to carts or orders to be deletable.
|
|
396
|
+
*
|
|
397
|
+
* 🛠 **Endpoint**: `DELETE /v1/operations/{operationId}`
|
|
398
|
+
*
|
|
399
|
+
* | Parameter | Type | Required | Description |
|
|
400
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
401
|
+
* | `operationId` | `string` | ✅ | Operation identifier to delete. |
|
|
402
|
+
*
|
|
403
|
+
* 📤 **Returns**:
|
|
404
|
+
* A `Promise` resolving to `void` when the operation is successfully deleted.
|
|
405
|
+
*
|
|
406
|
+
* 🛠 **Example usage**:
|
|
407
|
+
* ```ts
|
|
408
|
+
* await deleteOperation({
|
|
409
|
+
* operationId: "ope_123"
|
|
410
|
+
* });
|
|
411
|
+
* ```
|
|
412
|
+
*
|
|
413
|
+
* @param {DeleteOperationParameters} params - The parameters for deleting the operation.
|
|
414
|
+
* @returns {Promise<void>} A promise that resolves when the operation is deleted.
|
|
415
|
+
*/
|
|
416
|
+
export declare function deleteOperation({ operationId, }: DeleteOperationParameters): Promise<void>;
|
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOperations = getOperations;
|
|
4
|
+
exports.getOperation = getOperation;
|
|
5
|
+
exports.updateOperation = updateOperation;
|
|
6
|
+
exports.updateOperationDetails = updateOperationDetails;
|
|
7
|
+
exports.removeOperationAccounts = removeOperationAccounts;
|
|
8
|
+
exports.getOperationAccounts = getOperationAccounts;
|
|
9
|
+
exports.addOperationAccounts = addOperationAccounts;
|
|
10
|
+
exports.removeOperationLines = removeOperationLines;
|
|
11
|
+
exports.getOperationLines = getOperationLines;
|
|
12
|
+
exports.addOperationLines = addOperationLines;
|
|
13
|
+
exports.createOperation = createOperation;
|
|
14
|
+
exports.deleteOperation = deleteOperation;
|
|
15
|
+
const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
16
|
+
/**
|
|
17
|
+
* OPERATION ENDPOINT
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* 🎯 Gets operations.
|
|
21
|
+
*
|
|
22
|
+
* This function retrieves all operations with optional filtering and pagination.
|
|
23
|
+
* The function supports various filters including type, status, date ranges, and more.
|
|
24
|
+
*
|
|
25
|
+
* 🛠 **Endpoint**: `GET /v1/operations`
|
|
26
|
+
*
|
|
27
|
+
* | Parameter | Type | Required | Description |
|
|
28
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
29
|
+
* | `page` | `number` | ❌ | The page number to retrieve (0-based). |
|
|
30
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
31
|
+
* | `sort` | `string[]` | ❌ | The sort to apply to the results. |
|
|
32
|
+
* | `type` | `OperationType` | ❌ | Visibility type filter; accepts OperationType.PUBLIC or OperationType.PRIVATE. |
|
|
33
|
+
* | `status` | `OperationStatus` | ❌ | Operation status filter; accepts OperationStatus.DRAFT, OperationStatus.ACTIVE or OperationStatus.INACTIVE. |
|
|
34
|
+
* | `ids` | `string[]` | ❌ | Filter by operation IDs. |
|
|
35
|
+
* | `name` | `string` | ❌ | Case-insensitive substring match on Operation name. |
|
|
36
|
+
* | `startDateFrom` | `string` | ❌ | Return Operations starting on or after this ISO date (inclusive). |
|
|
37
|
+
* | `startDateTo` | `string` | ❌ | Return Operations starting on or before this ISO date (inclusive). |
|
|
38
|
+
* | `endDateFrom` | `string` | ❌ | Return Operations ending on or after this ISO date (inclusive). |
|
|
39
|
+
* | `endDateTo` | `string` | ❌ | Return Operations ending on or before this ISO date (inclusive). |
|
|
40
|
+
* | `ownerIds` | `string[]` | ❌ | Filter by Owner user identifier (Operator only). |
|
|
41
|
+
* | `idType` | `string` | ❌ | Type of operation identifiers provided in the id query parameter. |
|
|
42
|
+
* | `locale` | `string` | ❌ | Locale to use for localized fields (e.g., `name`). |
|
|
43
|
+
*
|
|
44
|
+
* 📤 **Returns**:
|
|
45
|
+
* A `Promise` resolving to a single `GetOperationsResponse` object representing the page of operations.
|
|
46
|
+
*
|
|
47
|
+
* 🛠 **Example usage**:
|
|
48
|
+
* ```ts
|
|
49
|
+
* const operations = await getOperations({
|
|
50
|
+
* page: 0,
|
|
51
|
+
* size: 10,
|
|
52
|
+
* status: OperationStatus.ACTIVE,
|
|
53
|
+
* type: OperationType.PUBLIC
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param {GetOperationsParameters} params - The parameters for the request.
|
|
58
|
+
* @returns {Promise<GetOperationsResponse>} A promise resolving to the response containing page object.
|
|
59
|
+
*/
|
|
60
|
+
async function getOperations({ page, size, sort, type, status, ids, name, startDateFrom, startDateTo, endDateFrom, endDateTo, ownerIds, idType, locale, }) {
|
|
61
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
62
|
+
method: "GET",
|
|
63
|
+
path: `/v1/operations`,
|
|
64
|
+
params: {
|
|
65
|
+
page,
|
|
66
|
+
size,
|
|
67
|
+
sort,
|
|
68
|
+
type,
|
|
69
|
+
status,
|
|
70
|
+
ids,
|
|
71
|
+
name,
|
|
72
|
+
startDateFrom,
|
|
73
|
+
startDateTo,
|
|
74
|
+
endDateFrom,
|
|
75
|
+
endDateTo,
|
|
76
|
+
ownerIds,
|
|
77
|
+
idType,
|
|
78
|
+
locale,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 🔍 Gets a single operation by ID.
|
|
85
|
+
*
|
|
86
|
+
* This function retrieves detailed information about a specific operation
|
|
87
|
+
* including custom field values, owner information, and localized content.
|
|
88
|
+
*
|
|
89
|
+
* 🛠 **Endpoint**: `GET /v1/operations/{operationId}`
|
|
90
|
+
*
|
|
91
|
+
* | Parameter | Type | Required | Description |
|
|
92
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
93
|
+
* | `operationId` | `string` | ✅ | Operation identifier to retrieve. |
|
|
94
|
+
*
|
|
95
|
+
* 📤 **Returns**:
|
|
96
|
+
* A `Promise` resolving to a single `GetOperationResponse` object containing the operation details.
|
|
97
|
+
*
|
|
98
|
+
* 🛠 **Example usage**:
|
|
99
|
+
* ```ts
|
|
100
|
+
* const operation = await getOperation({
|
|
101
|
+
* operationId: "ope_123"
|
|
102
|
+
* });
|
|
103
|
+
* console.log(operation.name);
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @param {GetOperationParameters} params - The parameters for retrieving the operation.
|
|
107
|
+
* @returns {Promise<GetOperationResponse>} A promise resolving to the operation details.
|
|
108
|
+
*/
|
|
109
|
+
async function getOperation({ operationId, }) {
|
|
110
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
111
|
+
method: "GET",
|
|
112
|
+
path: `/v1/operations/${operationId}`,
|
|
113
|
+
});
|
|
114
|
+
return data;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* ✏️ Updates an operation status.
|
|
118
|
+
*
|
|
119
|
+
* This function updates the status of an existing operation.
|
|
120
|
+
* The operation must exist and the user must have the appropriate permissions.
|
|
121
|
+
*
|
|
122
|
+
* 🛠 **Endpoint**: `PATCH /v1/operations/{operationId}`
|
|
123
|
+
*
|
|
124
|
+
* | Parameter | Type | Required | Description |
|
|
125
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
126
|
+
* | `operationId` | `string` | ✅ | Operation identifier to update. |
|
|
127
|
+
* | `status` | `OperationStatus` | ✅ | New status for the operation (OperationStatus.DRAFT, OperationStatus.ACTIVE, or OperationStatus.INACTIVE). |
|
|
128
|
+
*
|
|
129
|
+
* 📤 **Returns**:
|
|
130
|
+
* A `Promise` resolving to `void` when the operation status is successfully updated.
|
|
131
|
+
*
|
|
132
|
+
* 🛠 **Example usage**:
|
|
133
|
+
* ```ts
|
|
134
|
+
* await updateOperation({
|
|
135
|
+
* operationId: "ope_456",
|
|
136
|
+
* status: OperationStatus.ACTIVE
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @param {UpdateOperationParameters} params - The parameters for updating the operation.
|
|
141
|
+
* @returns {Promise<void>} A promise that resolves when the operation is updated.
|
|
142
|
+
*/
|
|
143
|
+
async function updateOperation({ operationId, status, }) {
|
|
144
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
145
|
+
method: "PATCH",
|
|
146
|
+
path: `/v1/operations/${operationId}`,
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
status,
|
|
149
|
+
}),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* ✏️ Updates operation details.
|
|
154
|
+
*
|
|
155
|
+
* This function updates the details of an existing operation including
|
|
156
|
+
* custom field values, descriptions, names, and date ranges.
|
|
157
|
+
*
|
|
158
|
+
* 🛠 **Endpoint**: `PUT /v1/operations/{operationId}`
|
|
159
|
+
*
|
|
160
|
+
* | Parameter | Type | Required | Description |
|
|
161
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
162
|
+
* | `operationId` | `string` | ✅ | Operation identifier to update. |
|
|
163
|
+
* | `customFieldValues` | `object[]` | ❌ | Array of custom field values. |
|
|
164
|
+
* | `descriptions` | `string` | ❌ | Localized descriptions in JSON format. |
|
|
165
|
+
* | `endDate` | `string` | ❌ | End date of the operation in ISO format. |
|
|
166
|
+
* | `names` | `string` | ❌ | Localized names in JSON format. |
|
|
167
|
+
* | `startDate` | `string` | ❌ | Start date of the operation in ISO format. |
|
|
168
|
+
*
|
|
169
|
+
* 📤 **Returns**:
|
|
170
|
+
* A `Promise` resolving to a single `UpdateOperationDetailsResponse` object containing the updated operation ID.
|
|
171
|
+
*
|
|
172
|
+
* 🛠 **Example usage**:
|
|
173
|
+
* ```ts
|
|
174
|
+
* const updatedOperation = await updateOperationDetails({
|
|
175
|
+
* operationId: "ope_456",
|
|
176
|
+
* names: "{\"en-GB\": \"Updated Operation\", \"fr-FR\": \"Opération Mise à Jour\"}",
|
|
177
|
+
* descriptions: "{\"en-GB\": \"Updated Description\", \"fr-FR\": \"Description Mise à Jour\"}",
|
|
178
|
+
* startDate: "2025-12-01T00:00:00Z",
|
|
179
|
+
* endDate: "2025-12-31T23:59:59Z",
|
|
180
|
+
* customFieldValues: [
|
|
181
|
+
* {
|
|
182
|
+
* customFieldId: "field123",
|
|
183
|
+
* customFieldValue: "updated_value"
|
|
184
|
+
* }
|
|
185
|
+
* ]
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @param {UpdateOperationDetailsParameters} params - The parameters for updating the operation details.
|
|
190
|
+
* @returns {Promise<UpdateOperationDetailsResponse>} A promise resolving to the response containing the operation ID.
|
|
191
|
+
*/
|
|
192
|
+
async function updateOperationDetails({ operationId, customFieldValues, descriptions, endDate, names, startDate, }) {
|
|
193
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
194
|
+
method: "PUT",
|
|
195
|
+
path: `/v1/operations/${operationId}`,
|
|
196
|
+
body: JSON.stringify({
|
|
197
|
+
customFieldValues,
|
|
198
|
+
descriptions,
|
|
199
|
+
endDate,
|
|
200
|
+
names,
|
|
201
|
+
startDate,
|
|
202
|
+
}),
|
|
203
|
+
});
|
|
204
|
+
return data;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 🗑️ Removes accounts from an operation.
|
|
208
|
+
*
|
|
209
|
+
* This function removes one or more accounts from an existing operation.
|
|
210
|
+
* The operation must exist and the user must have the appropriate permissions.
|
|
211
|
+
*
|
|
212
|
+
* 🛠 **Endpoint**: `DELETE /v1/operations/{operationId}/accounts`
|
|
213
|
+
*
|
|
214
|
+
* | Parameter | Type | Required | Description |
|
|
215
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
216
|
+
* | `operationId` | `string` | ✅ | Operation identifier to remove accounts from. |
|
|
217
|
+
* | `accountIds` | `string[]` | ✅ | Array of account identifiers to remove. |
|
|
218
|
+
*
|
|
219
|
+
* 📤 **Returns**:
|
|
220
|
+
* A `Promise` resolving to `void` when the accounts are successfully removed from the operation.
|
|
221
|
+
*
|
|
222
|
+
* 🛠 **Example usage**:
|
|
223
|
+
* ```ts
|
|
224
|
+
* await removeOperationAccounts({
|
|
225
|
+
* operationId: "ope_123",
|
|
226
|
+
* accountIds: ["acc_123", "acc_456"]
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @param {RemoveOperationAccountsParameters} params - The parameters for removing accounts from the operation.
|
|
231
|
+
* @returns {Promise<void>} A promise that resolves when the accounts are removed.
|
|
232
|
+
*/
|
|
233
|
+
async function removeOperationAccounts({ operationId, accountIds, }) {
|
|
234
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
235
|
+
method: "DELETE",
|
|
236
|
+
path: `/v1/operations/${operationId}/accounts`,
|
|
237
|
+
body: JSON.stringify({
|
|
238
|
+
accountIds,
|
|
239
|
+
}),
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 👥 Gets accounts linked to an operation.
|
|
244
|
+
*
|
|
245
|
+
* This function retrieves a paginated list of accounts linked to a specific operation.
|
|
246
|
+
* The operation must be PRIVATE and the user must have the appropriate permissions.
|
|
247
|
+
*
|
|
248
|
+
* 🛠 **Endpoint**: `GET /v1/operations/{operationId}/accounts`
|
|
249
|
+
*
|
|
250
|
+
* | Parameter | Type | Required | Description |
|
|
251
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
252
|
+
* | `operationId` | `string` | ✅ | Operation identifier (must be PRIVATE). |
|
|
253
|
+
* | `page` | `number` | ❌ | The page number to retrieve (0-based). |
|
|
254
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
255
|
+
* | `sort` | `string[]` | ❌ | The sort to apply to the results. |
|
|
256
|
+
* | `accountIds` | `string[]` | ❌ | Filter by a list of external account identifiers. |
|
|
257
|
+
* | `accountName` | `string` | ❌ | Filter by account name (case-insensitive substring). |
|
|
258
|
+
*
|
|
259
|
+
* 📤 **Returns**:
|
|
260
|
+
* A `Promise` resolving to a single `GetOperationAccountsResponse` object representing the page of accounts.
|
|
261
|
+
*
|
|
262
|
+
* 🛠 **Example usage**:
|
|
263
|
+
* ```ts
|
|
264
|
+
* const accounts = await getOperationAccounts({
|
|
265
|
+
* operationId: "ope_123",
|
|
266
|
+
* page: 0,
|
|
267
|
+
* size: 20,
|
|
268
|
+
* accountName: "Store"
|
|
269
|
+
* });
|
|
270
|
+
* console.log('Linked accounts:', accounts.content);
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* @param {GetOperationAccountsParameters} params - The parameters for the request.
|
|
274
|
+
* @returns {Promise<GetOperationAccountsResponse>} A promise resolving to the response containing page of accounts.
|
|
275
|
+
*/
|
|
276
|
+
async function getOperationAccounts({ operationId, page, size, sort, accountIds, accountName, }) {
|
|
277
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
278
|
+
method: "GET",
|
|
279
|
+
path: `/v1/operations/${operationId}/accounts`,
|
|
280
|
+
params: {
|
|
281
|
+
page,
|
|
282
|
+
size,
|
|
283
|
+
sort,
|
|
284
|
+
accountIds,
|
|
285
|
+
accountName,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
return data;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* ➕ Adds accounts to an operation.
|
|
292
|
+
*
|
|
293
|
+
* This function adds one or more accounts to an existing operation.
|
|
294
|
+
* The operation must exist and the user must have the appropriate permissions.
|
|
295
|
+
*
|
|
296
|
+
* 🛠 **Endpoint**: `PUT /v1/operations/{operationId}/accounts`
|
|
297
|
+
*
|
|
298
|
+
* | Parameter | Type | Required | Description |
|
|
299
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
300
|
+
* | `operationId` | `string` | ✅ | Operation identifier to add accounts to. |
|
|
301
|
+
* | `accountIds` | `string[]` | ✅ | Array of account identifiers to add. |
|
|
302
|
+
*
|
|
303
|
+
* 📤 **Returns**:
|
|
304
|
+
* A `Promise` resolving to `void` when the accounts are successfully added to the operation.
|
|
305
|
+
*
|
|
306
|
+
* 🛠 **Example usage**:
|
|
307
|
+
* ```ts
|
|
308
|
+
* await addOperationAccounts({
|
|
309
|
+
* operationId: "ope_123",
|
|
310
|
+
* accountIds: ["ACC-001", "ACC-002", "ACC-XYZ"]
|
|
311
|
+
* });
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @param {AddOperationAccountsParameters} params - The parameters for adding accounts to the operation.
|
|
315
|
+
* @returns {Promise<void>} A promise that resolves when the accounts are added.
|
|
316
|
+
*/
|
|
317
|
+
async function addOperationAccounts({ operationId, accountIds, }) {
|
|
318
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
319
|
+
method: "PUT",
|
|
320
|
+
path: `/v1/operations/${operationId}/accounts`,
|
|
321
|
+
body: JSON.stringify({
|
|
322
|
+
accountIds,
|
|
323
|
+
}),
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* 🗑️ Removes variants from an operation.
|
|
328
|
+
*
|
|
329
|
+
* This function removes one or more variants from an existing operation.
|
|
330
|
+
* The operation must exist and the user must have the appropriate permissions.
|
|
331
|
+
*
|
|
332
|
+
* 🛠 **Endpoint**: `DELETE /v1/operations/{operationId}/lines`
|
|
333
|
+
*
|
|
334
|
+
* | Parameter | Type | Required | Description |
|
|
335
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
336
|
+
* | `operationId` | `string` | ✅ | Operation identifier to remove variants from. |
|
|
337
|
+
* | `variantIds` | `string[]` | ✅ | Array of variant identifiers to remove. |
|
|
338
|
+
*
|
|
339
|
+
* 📤 **Returns**:
|
|
340
|
+
* A `Promise` resolving to `void` when the variants are successfully removed from the operation.
|
|
341
|
+
*
|
|
342
|
+
* 🛠 **Example usage**:
|
|
343
|
+
* ```ts
|
|
344
|
+
* await removeOperationLines({
|
|
345
|
+
* operationId: "ope_123",
|
|
346
|
+
* variantIds: ["VAR-001", "VAR-002", "VAR-003"]
|
|
347
|
+
* });
|
|
348
|
+
* ```
|
|
349
|
+
*
|
|
350
|
+
* @param {RemoveOperationLinesParameters} params - The parameters for removing variants from the operation.
|
|
351
|
+
* @returns {Promise<void>} A promise that resolves when the variants are removed.
|
|
352
|
+
*/
|
|
353
|
+
async function removeOperationLines({ operationId, variantIds, }) {
|
|
354
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
355
|
+
method: "DELETE",
|
|
356
|
+
path: `/v1/operations/${operationId}/lines`,
|
|
357
|
+
body: JSON.stringify({
|
|
358
|
+
variantIds,
|
|
359
|
+
}),
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* 📦 Gets variants linked to an operation.
|
|
364
|
+
*
|
|
365
|
+
* This function retrieves a paginated list of variants linked to a specific operation
|
|
366
|
+
* with various filtering options including quantity ranges and variant names.
|
|
367
|
+
*
|
|
368
|
+
* 🛠 **Endpoint**: `GET /v1/operations/{operationId}/lines`
|
|
369
|
+
*
|
|
370
|
+
* | Parameter | Type | Required | Description |
|
|
371
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
372
|
+
* | `operationId` | `string` | ✅ | Operation identifier. |
|
|
373
|
+
* | `page` | `number` | ❌ | The page number to retrieve (0-based). |
|
|
374
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
375
|
+
* | `sort` | `string[]` | ❌ | The sort to apply to the results. |
|
|
376
|
+
* | `variantIds` | `string[]` | ❌ | Filter by a list of external variant IDs. |
|
|
377
|
+
* | `variantName` | `string` | ❌ | Filter by variant name (case-insensitive, partial or exact match). |
|
|
378
|
+
* | `minQuantity` | `number` | ❌ | Filter variants where minQuantity equals this value. |
|
|
379
|
+
* | `maxQuantity` | `number` | ❌ | Filter variants where maxQuantity equals this value. |
|
|
380
|
+
* | `recommendedQuantity` | `number` | ❌ | Filter variants where recommendedQuantity equals this value. |
|
|
381
|
+
* | `locale` | `string` | ❌ | Locale to use for localized fields. |
|
|
382
|
+
*
|
|
383
|
+
* 📤 **Returns**:
|
|
384
|
+
* A `Promise` resolving to a single `GetOperationLinesResponse` object representing the page of variants.
|
|
385
|
+
*
|
|
386
|
+
* 🛠 **Example usage**:
|
|
387
|
+
* ```ts
|
|
388
|
+
* const variants = await getOperationLines({
|
|
389
|
+
* operationId: "ope_123",
|
|
390
|
+
* page: 0,
|
|
391
|
+
* size: 20,
|
|
392
|
+
* variantName: "Shirt",
|
|
393
|
+
* minQuantity: 2,
|
|
394
|
+
* maxQuantity: 10
|
|
395
|
+
* });
|
|
396
|
+
* console.log('Linked variants:', variants.content);
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @param {GetOperationLinesParameters} params - The parameters for the request.
|
|
400
|
+
* @returns {Promise<GetOperationLinesResponse>} A promise resolving to the response containing page of variants.
|
|
401
|
+
*/
|
|
402
|
+
async function getOperationLines({ operationId, page, size, sort, variantIds, variantName, minQuantity, maxQuantity, recommendedQuantity, locale, }) {
|
|
403
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
404
|
+
method: "GET",
|
|
405
|
+
path: `/v1/operations/${operationId}/lines`,
|
|
406
|
+
params: {
|
|
407
|
+
page,
|
|
408
|
+
size,
|
|
409
|
+
sort,
|
|
410
|
+
variantIds,
|
|
411
|
+
variantName,
|
|
412
|
+
minQuantity,
|
|
413
|
+
maxQuantity,
|
|
414
|
+
recommendedQuantity,
|
|
415
|
+
locale,
|
|
416
|
+
},
|
|
417
|
+
});
|
|
418
|
+
return data;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* ➕ Adds variants to an operation.
|
|
422
|
+
*
|
|
423
|
+
* This function adds one or more variants to an existing operation with
|
|
424
|
+
* their associated quantity constraints (min, max, and recommended quantities).
|
|
425
|
+
*
|
|
426
|
+
* 🛠 **Endpoint**: `PUT /v1/operations/{operationId}/lines`
|
|
427
|
+
*
|
|
428
|
+
* | Parameter | Type | Required | Description |
|
|
429
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
430
|
+
* | `operationId` | `string` | ✅ | Operation identifier to add variants to. |
|
|
431
|
+
* | `lines` | `object[]` | ✅ | Array of variant lines with quantity constraints. |
|
|
432
|
+
* | `lines[].variantId` | `string` | ✅ | Variant identifier to add. |
|
|
433
|
+
* | `lines[].minQuantity` | `number` | ✅ | Minimum quantity for this variant. |
|
|
434
|
+
* | `lines[].maxQuantity` | `number` | ✅ | Maximum quantity for this variant. |
|
|
435
|
+
* | `lines[].recommendedQuantity` | `number` | ✅ | Recommended quantity for this variant. |
|
|
436
|
+
*
|
|
437
|
+
* 📤 **Returns**:
|
|
438
|
+
* A `Promise` resolving to `void` when the variants are successfully added to the operation.
|
|
439
|
+
*
|
|
440
|
+
* 🛠 **Example usage**:
|
|
441
|
+
* ```ts
|
|
442
|
+
* await addOperationLines({
|
|
443
|
+
* operationId: "ope_123",
|
|
444
|
+
* lines: [
|
|
445
|
+
* {
|
|
446
|
+
* variantId: "VAR-001",
|
|
447
|
+
* minQuantity: 2,
|
|
448
|
+
* maxQuantity: 10,
|
|
449
|
+
* recommendedQuantity: 5
|
|
450
|
+
* },
|
|
451
|
+
* {
|
|
452
|
+
* variantId: "VAR-002",
|
|
453
|
+
* minQuantity: 1,
|
|
454
|
+
* maxQuantity: 5,
|
|
455
|
+
* recommendedQuantity: 3
|
|
456
|
+
* }
|
|
457
|
+
* ]
|
|
458
|
+
* });
|
|
459
|
+
* ```
|
|
460
|
+
*
|
|
461
|
+
* @param {AddOperationLinesParameters} params - The parameters for adding variants to the operation.
|
|
462
|
+
* @returns {Promise<void>} A promise that resolves when the variants are added.
|
|
463
|
+
*/
|
|
464
|
+
async function addOperationLines({ operationId, lines, }) {
|
|
465
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
466
|
+
method: "PUT",
|
|
467
|
+
path: `/v1/operations/${operationId}/lines`,
|
|
468
|
+
body: JSON.stringify(lines),
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* ➕ Creates a new operation.
|
|
473
|
+
*
|
|
474
|
+
* This function creates a new operation with the provided parameters.
|
|
475
|
+
* The function supports custom field values, localized descriptions and names.
|
|
476
|
+
*
|
|
477
|
+
* 🛠 **Endpoint**: `POST /v1/operations`
|
|
478
|
+
*
|
|
479
|
+
* | Parameter | Type | Required | Description |
|
|
480
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
481
|
+
* | `customFieldValues` | `object[]` | ❌ | Array of custom field values. |
|
|
482
|
+
* | `descriptions` | `string` | ❌ | Localized descriptions in JSON format. |
|
|
483
|
+
* | `endDate` | `string` | ✅ | End date of the operation in ISO format. |
|
|
484
|
+
* | `externalId` | `string` | ✅ | External identifier for the operation. |
|
|
485
|
+
* | `names` | `string` | ✅ | Localized names in JSON format. |
|
|
486
|
+
* | `startDate` | `string` | ✅ | Start date of the operation in ISO format. |
|
|
487
|
+
* | `type` | `OperationType` | ✅ | Type of the operation (OperationType.PUBLIC or OperationType.PRIVATE). |
|
|
488
|
+
*
|
|
489
|
+
* 📤 **Returns**:
|
|
490
|
+
* A `Promise` resolving to a single `CreateOperationResponse` object containing the created operation ID.
|
|
491
|
+
*
|
|
492
|
+
* 🛠 **Example usage**:
|
|
493
|
+
* ```ts
|
|
494
|
+
* const operation = await createOperation({
|
|
495
|
+
* externalId: "SUMMER_OPE_0825",
|
|
496
|
+
* names: "{\"en-GB\": \"Summer Operation\", \"fr-FR\": \"Opération Été\"}",
|
|
497
|
+
* descriptions: "{\"en-GB\": \"Summer Operation · Fine Food\", \"fr-FR\": \"Opération Été · Produits raffinés\"}",
|
|
498
|
+
* startDate: "2025-11-21T00:00:00Z",
|
|
499
|
+
* endDate: "2025-11-28T23:59:59Z",
|
|
500
|
+
* type: OperationType.PRIVATE,
|
|
501
|
+
* customFieldValues: [
|
|
502
|
+
* {
|
|
503
|
+
* customFieldId: "field123",
|
|
504
|
+
* customFieldValue: "value456"
|
|
505
|
+
* }
|
|
506
|
+
* ]
|
|
507
|
+
* });
|
|
508
|
+
* ```
|
|
509
|
+
*
|
|
510
|
+
* @param {CreateOperationParameters} params - The parameters for creating the operation.
|
|
511
|
+
* @returns {Promise<CreateOperationResponse>} A promise resolving to the response containing the operation ID.
|
|
512
|
+
*/
|
|
513
|
+
async function createOperation({ customFieldValues, descriptions, endDate, externalId, names, startDate, type, }) {
|
|
514
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
515
|
+
method: "POST",
|
|
516
|
+
path: `/v1/operations`,
|
|
517
|
+
body: JSON.stringify({
|
|
518
|
+
customFieldValues,
|
|
519
|
+
descriptions,
|
|
520
|
+
endDate,
|
|
521
|
+
externalId,
|
|
522
|
+
names,
|
|
523
|
+
startDate,
|
|
524
|
+
type,
|
|
525
|
+
}),
|
|
526
|
+
});
|
|
527
|
+
return data;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* 🗑️ Deletes an operation.
|
|
531
|
+
*
|
|
532
|
+
* This function deletes an operation by its identifier.
|
|
533
|
+
* The operation must not be linked to carts or orders to be deletable.
|
|
534
|
+
*
|
|
535
|
+
* 🛠 **Endpoint**: `DELETE /v1/operations/{operationId}`
|
|
536
|
+
*
|
|
537
|
+
* | Parameter | Type | Required | Description |
|
|
538
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
539
|
+
* | `operationId` | `string` | ✅ | Operation identifier to delete. |
|
|
540
|
+
*
|
|
541
|
+
* 📤 **Returns**:
|
|
542
|
+
* A `Promise` resolving to `void` when the operation is successfully deleted.
|
|
543
|
+
*
|
|
544
|
+
* 🛠 **Example usage**:
|
|
545
|
+
* ```ts
|
|
546
|
+
* await deleteOperation({
|
|
547
|
+
* operationId: "ope_123"
|
|
548
|
+
* });
|
|
549
|
+
* ```
|
|
550
|
+
*
|
|
551
|
+
* @param {DeleteOperationParameters} params - The parameters for deleting the operation.
|
|
552
|
+
* @returns {Promise<void>} A promise that resolves when the operation is deleted.
|
|
553
|
+
*/
|
|
554
|
+
async function deleteOperation({ operationId, }) {
|
|
555
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
556
|
+
method: "DELETE",
|
|
557
|
+
path: `/v1/operations/${operationId}`,
|
|
558
|
+
});
|
|
559
|
+
}
|