oneentry 1.0.142 → 1.0.144
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/configure.js +2 -2
- package/dist/admins/adminsApi.d.ts +50 -0
- package/dist/admins/adminsApi.js +65 -0
- package/dist/admins/adminsInterfaces.d.ts +98 -0
- package/dist/admins/adminsInterfaces.js +2 -0
- package/dist/admins/adminsSchemas.d.ts +30 -0
- package/dist/admins/adminsSchemas.js +27 -0
- package/dist/attribute-sets/attributeSetsApi.d.ts +63 -0
- package/dist/attribute-sets/attributeSetsApi.js +98 -0
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +185 -0
- package/dist/attribute-sets/attributeSetsInterfaces.js +2 -0
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
- package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
- package/dist/auth-provider/authProviderApi.d.ts +249 -0
- package/dist/auth-provider/authProviderApi.js +354 -0
- package/dist/auth-provider/authProviderSchemas.d.ts +131 -0
- package/dist/auth-provider/authProviderSchemas.js +82 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +412 -0
- package/dist/auth-provider/authProvidersInterfaces.js +2 -0
- package/dist/base/asyncModules.d.ts +80 -0
- package/dist/base/asyncModules.js +448 -0
- package/dist/base/result.d.ts +39 -0
- package/dist/base/result.js +154 -0
- package/dist/base/stateModule.d.ts +41 -0
- package/dist/base/stateModule.js +128 -0
- package/dist/base/syncModules.d.ts +286 -0
- package/dist/base/syncModules.js +716 -0
- package/dist/base/utils.d.ts +197 -0
- package/dist/base/utils.js +2 -0
- package/dist/base/validation.d.ts +118 -0
- package/dist/base/validation.js +132 -0
- package/dist/blocks/blocksApi.d.ts +88 -0
- package/dist/blocks/blocksApi.js +207 -0
- package/dist/blocks/blocksInterfaces.d.ts +179 -0
- package/dist/blocks/blocksInterfaces.js +2 -0
- package/dist/blocks/blocksSchemas.d.ts +195 -0
- package/dist/blocks/blocksSchemas.js +43 -0
- package/dist/discounts/discountsApi.d.ts +76 -0
- package/dist/discounts/discountsApi.js +116 -0
- package/dist/discounts/discountsInterfaces.d.ts +217 -0
- package/dist/discounts/discountsInterfaces.js +2 -0
- package/dist/events/eventsApi.d.ts +60 -0
- package/dist/events/eventsApi.js +97 -0
- package/dist/events/eventsInterfaces.d.ts +87 -0
- package/dist/events/eventsInterfaces.js +2 -0
- package/dist/file-uploading/fileUploadingApi.d.ts +88 -0
- package/dist/file-uploading/fileUploadingApi.js +129 -0
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +114 -0
- package/dist/file-uploading/fileUploadingInterfaces.js +2 -0
- package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
- package/dist/file-uploading/fileUploadingSchemas.js +21 -0
- package/dist/forms/formsApi.d.ts +42 -0
- package/dist/forms/formsApi.js +57 -0
- package/dist/forms/formsInterfaces.d.ts +144 -0
- package/dist/forms/formsInterfaces.js +2 -0
- package/dist/forms/formsSchemas.d.ts +53 -0
- package/dist/forms/formsSchemas.js +34 -0
- package/dist/forms-data/formsDataApi.d.ts +106 -0
- package/dist/forms-data/formsDataApi.js +189 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +522 -0
- package/dist/forms-data/formsDataInterfaces.js +2 -0
- package/dist/forms-data/formsDataSchemas.d.ts +115 -0
- package/dist/forms-data/formsDataSchemas.js +86 -0
- package/dist/general-types/generalTypesApi.d.ts +28 -0
- package/dist/general-types/generalTypesApi.js +38 -0
- package/dist/general-types/generalTypesInterfaces.d.ts +29 -0
- package/dist/general-types/generalTypesInterfaces.js +2 -0
- package/dist/general-types/generalTypesSchemas.d.ts +52 -0
- package/dist/general-types/generalTypesSchemas.js +36 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +103 -0
- package/dist/integration-collections/integrationCollectionsApi.d.ts +163 -0
- package/dist/integration-collections/integrationCollectionsApi.js +220 -0
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +313 -0
- package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +80 -0
- package/dist/integration-collections/integrationCollectionsSchemas.js +61 -0
- package/dist/locales/localesApi.d.ts +27 -0
- package/dist/locales/localesApi.js +37 -0
- package/dist/locales/localesInterfaces.d.ts +40 -0
- package/dist/locales/localesInterfaces.js +2 -0
- package/dist/locales/localesSchemas.d.ts +32 -0
- package/dist/locales/localesSchemas.js +26 -0
- package/dist/menus/menusApi.d.ts +29 -0
- package/dist/menus/menusApi.js +39 -0
- package/dist/menus/menusInterfaces.d.ts +87 -0
- package/dist/menus/menusInterfaces.js +3 -0
- package/dist/menus/menusSchemas.d.ts +16 -0
- package/dist/menus/menusSchemas.js +28 -0
- package/dist/orders/ordersApi.d.ts +175 -0
- package/dist/orders/ordersApi.js +247 -0
- package/dist/orders/ordersInterfaces.d.ts +593 -0
- package/dist/orders/ordersInterfaces.js +2 -0
- package/dist/orders/ordersSchemas.d.ts +120 -0
- package/dist/orders/ordersSchemas.js +101 -0
- package/dist/pages/pagesApi.d.ts +151 -0
- package/dist/pages/pagesApi.js +390 -0
- package/dist/pages/pagesInterfaces.d.ts +286 -0
- package/dist/pages/pagesInterfaces.js +2 -0
- package/dist/pages/pagesSchemas.d.ts +85 -0
- package/dist/pages/pagesSchemas.js +46 -0
- package/dist/payments/paymentsApi.d.ts +82 -0
- package/dist/payments/paymentsApi.js +121 -0
- package/dist/payments/paymentsInterfaces.d.ts +200 -0
- package/dist/payments/paymentsInterfaces.js +2 -0
- package/dist/payments/paymentsSchemas.d.ts +100 -0
- package/dist/payments/paymentsSchemas.js +65 -0
- package/dist/product-statuses/productStatusesApi.d.ts +47 -0
- package/dist/product-statuses/productStatusesApi.js +70 -0
- package/dist/product-statuses/productStatusesInterfaces.d.ts +62 -0
- package/dist/product-statuses/productStatusesInterfaces.js +2 -0
- package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
- package/dist/product-statuses/productStatusesSchemas.js +30 -0
- package/dist/products/productsApi.d.ts +366 -0
- package/dist/products/productsApi.js +458 -0
- package/dist/products/productsInterfaces.d.ts +593 -0
- package/dist/products/productsInterfaces.js +2 -0
- package/dist/products/productsSchemas.d.ts +200 -0
- package/dist/products/productsSchemas.js +98 -0
- package/dist/sitemap/sitemapApi.d.ts +35 -0
- package/dist/sitemap/sitemapApi.js +45 -0
- package/dist/sitemap/sitemapInterfaces.d.ts +40 -0
- package/dist/sitemap/sitemapInterfaces.js +2 -0
- package/dist/system/systemApi.d.ts +43 -0
- package/dist/system/systemApi.js +56 -0
- package/dist/system/systemInterfaces.d.ts +29 -0
- package/dist/system/systemInterfaces.js +2 -0
- package/dist/templates/templatesApi.d.ts +49 -0
- package/dist/templates/templatesApi.js +75 -0
- package/dist/templates/templatesInterfaces.d.ts +67 -0
- package/dist/templates/templatesInterfaces.js +2 -0
- package/dist/templates/templatesSchemas.d.ts +48 -0
- package/dist/templates/templatesSchemas.js +31 -0
- package/dist/templates-preview/templatesPreviewApi.d.ts +38 -0
- package/dist/templates-preview/templatesPreviewApi.js +53 -0
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +119 -0
- package/dist/templates-preview/templatesPreviewInterfaces.js +2 -0
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
- package/dist/users/usersApi.d.ts +143 -0
- package/dist/users/usersApi.js +171 -0
- package/dist/users/usersInterfaces.d.ts +231 -0
- package/dist/users/usersInterfaces.js +2 -0
- package/dist/users/usersSchemas.d.ts +38 -0
- package/dist/users/usersSchemas.js +28 -0
- package/dist/web-socket/wsApi.d.ts +25 -0
- package/dist/web-socket/wsApi.js +45 -0
- package/dist/web-socket/wsInterfaces.d.ts +16 -0
- package/dist/web-socket/wsInterfaces.js +2 -0
- package/package.json +2 -80
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
|
+
const ordersSchemas_1 = require("./ordersSchemas");
|
|
8
|
+
/**
|
|
9
|
+
* Controllers for working with orders.
|
|
10
|
+
* @handle /api/content/orders-storage
|
|
11
|
+
* @module OrdersApi
|
|
12
|
+
* @description This module provides methods for working with orders, including retrieving, creating, and updating orders in the order storage.
|
|
13
|
+
*/
|
|
14
|
+
class OrdersApi extends asyncModules_1.default {
|
|
15
|
+
/**
|
|
16
|
+
* Constructs an instance of the OrdersApi class.
|
|
17
|
+
* @param {StateModule} state - The state module containing the necessary information for making API calls.
|
|
18
|
+
* @description Constructor initializes the OrdersApi with a given state.
|
|
19
|
+
*/
|
|
20
|
+
constructor(state) {
|
|
21
|
+
super(state);
|
|
22
|
+
this._url = state.url + '/api/content/orders-storage';
|
|
23
|
+
this._ordersUrl = state.url + '/api/content/orders';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Getting all the order storage objects.
|
|
27
|
+
* @handleName getAllOrdersStorage
|
|
28
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
29
|
+
* @param {number} [offset] - Optional parameter for pagination. Default: 0.
|
|
30
|
+
* @param {number} [limit] - Optional parameter for pagination. Default: 30.
|
|
31
|
+
* @returns {Promise<IOrdersEntity[] | IError>} Returns an array of order storage objects.
|
|
32
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
33
|
+
* @description This method requires user authorization.
|
|
34
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
35
|
+
*/
|
|
36
|
+
async getAllOrdersStorage(langCode = this.state.lang, offset = 0, limit = 30) {
|
|
37
|
+
const result = await this._fetchGet(`?langCode=${langCode}&limit=${limit}&offset=${offset}`);
|
|
38
|
+
return this._normalizeData(result);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Getting all orders from the orders storage object created by the user.
|
|
42
|
+
* @handleName getAllOrdersByMarker
|
|
43
|
+
* @param {string} marker - Textual identifier of the order storage object. Example: "order_storage_1".
|
|
44
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
45
|
+
* @param {number} [offset] - Offset parameter. Default: 0.
|
|
46
|
+
* @param {number} [limit] - Limit parameter. Default: 30.
|
|
47
|
+
* @returns {Promise<IOrdersByMarkerEntity | IError>} Returns an object with the orders.
|
|
48
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
49
|
+
* @description This method requires user authorization.
|
|
50
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
51
|
+
*/
|
|
52
|
+
async getAllOrdersByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
53
|
+
const result = await this._fetchGet(`/marker/${marker}/orders?langCode=${langCode}&limit=${limit}&offset=${offset}`);
|
|
54
|
+
// Validate response if validation is enabled
|
|
55
|
+
const validated = this._validateResponse(result, ordersSchemas_1.OrdersResponseSchema);
|
|
56
|
+
return this._normalizeData(validated);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve one order storage object by marker.
|
|
60
|
+
* @handleName getOrdersStorageByMarker
|
|
61
|
+
* @param {string} marker - Marker of the order object. Example: "order_storage_1".
|
|
62
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
63
|
+
* @returns {Promise<IOrdersEntity | IError>} Return object of order information.
|
|
64
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
65
|
+
* @description This method requires user authorization.
|
|
66
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
67
|
+
*/
|
|
68
|
+
async getOrdersStorageByMarker(marker, langCode = this.state.lang) {
|
|
69
|
+
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
70
|
+
return this._normalizeData(result);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Getting a single order from the order storage object created by the user.
|
|
74
|
+
* @handleName getOrderByMarkerAndId
|
|
75
|
+
* @param {string} marker - The text identifier of the order storage object. Example: "order_storage_1".
|
|
76
|
+
* @param {number} id - ID of the order object. Example: 12345.
|
|
77
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
78
|
+
* @returns {Promise<IOrderByMarkerEntity | IError>} Returns an object with the order.
|
|
79
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
80
|
+
* @description This method requires user authorization.
|
|
81
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
82
|
+
*/
|
|
83
|
+
async getOrderByMarkerAndId(marker, id, langCode = this.state.lang) {
|
|
84
|
+
const result = await this._fetchGet(`/marker/${marker}/orders/${id}?langCode=${langCode}`);
|
|
85
|
+
// Validate response if validation is enabled
|
|
86
|
+
const validated = this._validateResponse(result, ordersSchemas_1.OrderEntitySchema);
|
|
87
|
+
return this._normalizeData(validated);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Preview order calculation with discounts and coupons (without saving).
|
|
91
|
+
* @handleName previewOrder
|
|
92
|
+
* @param {ICreateOrderPreview} body - Order preview body.
|
|
93
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
94
|
+
* @returns {Promise<IOrderPreviewResponse | IError>} Returns an object with the order preview.
|
|
95
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
96
|
+
* @description This method requires user authorization ???.
|
|
97
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
98
|
+
*/
|
|
99
|
+
async previewOrder(body, langCode = this.state.lang) {
|
|
100
|
+
const result = await this._fetchPost(`/orders/preview?langCode=${langCode}`, body);
|
|
101
|
+
return this._normalizeData(result);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creation of an order in the order storage.
|
|
105
|
+
* @handleName createOrder
|
|
106
|
+
* @param {string} marker - Textual identifier of the order storage object. Example: "order_storage_1".
|
|
107
|
+
* @param {IOrderData} body - Object for creating an order.
|
|
108
|
+
* @example
|
|
109
|
+
{
|
|
110
|
+
"formIdentifier": "bar-orders-form",
|
|
111
|
+
"paymentAccountIdentifier": "usd-payment",
|
|
112
|
+
"formData": {
|
|
113
|
+
"marker": "name_1",
|
|
114
|
+
"value": "Name",
|
|
115
|
+
"type": "string"
|
|
116
|
+
},
|
|
117
|
+
"products": [
|
|
118
|
+
{
|
|
119
|
+
"productId": 1,
|
|
120
|
+
"quantity": 2
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
125
|
+
* @returns {Promise<IBaseOrdersEntity | IError>} Returns an object with the created order.
|
|
126
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
127
|
+
* @description This method requires user authorization.
|
|
128
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
129
|
+
*/
|
|
130
|
+
async createOrder(marker, body, langCode = this.state.lang) {
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
132
|
+
const formData = {};
|
|
133
|
+
formData[langCode] = Array.isArray(body.formData)
|
|
134
|
+
? body.formData
|
|
135
|
+
: [body.formData];
|
|
136
|
+
body.formData = formData;
|
|
137
|
+
const result = await this._fetchPost(`/marker/${marker}/orders`, body);
|
|
138
|
+
// Validate response if validation is enabled
|
|
139
|
+
const validated = this._validateResponse(result, ordersSchemas_1.CreateOrderResponseSchema);
|
|
140
|
+
return this._normalizeData(validated);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Changing an order in the orders storage
|
|
144
|
+
* @handleName updateOrderByMarkerAndId
|
|
145
|
+
* @param {string} marker - The text identifier of the order storage object. Example: "order_storage_1".
|
|
146
|
+
* @param {number} id - ID of the order object. Example: 12345.
|
|
147
|
+
* @param {IOrderData} body - Object for updating an order.
|
|
148
|
+
* @example
|
|
149
|
+
{
|
|
150
|
+
"formIdentifier": "bar-orders-form",
|
|
151
|
+
"paymentAccountIdentifier": "usd-payment",
|
|
152
|
+
"formData": {
|
|
153
|
+
"marker": "name_1",
|
|
154
|
+
"value": "Name",
|
|
155
|
+
"type": "string"
|
|
156
|
+
},
|
|
157
|
+
"products": [
|
|
158
|
+
{
|
|
159
|
+
"productId": 1,
|
|
160
|
+
"quantity": 2
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"currency": "USD"
|
|
164
|
+
}
|
|
165
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
166
|
+
* @returns {Promise<IBaseOrdersEntity | IError>} Returns an object with the updated order.
|
|
167
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
168
|
+
* @description This method requires user authorization.
|
|
169
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
170
|
+
*/
|
|
171
|
+
async updateOrderByMarkerAndId(marker, id, body, langCode = this.state.lang) {
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
|
+
const formData = {};
|
|
174
|
+
formData[langCode] = Array.isArray(body.formData)
|
|
175
|
+
? body.formData
|
|
176
|
+
: [body.formData];
|
|
177
|
+
body.formData = formData;
|
|
178
|
+
const result = await this._fetchPut(`/marker/${marker}/orders/${id}?langCode=${langCode}`, body);
|
|
179
|
+
// Validate response if validation is enabled
|
|
180
|
+
const validated = this._validateResponse(result, ordersSchemas_1.UpdateOrderResponseSchema);
|
|
181
|
+
return this._normalizeData(validated);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get all orders statuses by Storage marker
|
|
185
|
+
* @handleName getAllStatusesByStorageMarker
|
|
186
|
+
* @param {string} marker - Textual identifier of the order storage object. Example: "order_storage_1".
|
|
187
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
188
|
+
* @param {number} [offset] - Offset parameter. Default: 0.
|
|
189
|
+
* @param {number} [limit] - Limit parameter. Default: 30.
|
|
190
|
+
* @returns {Promise<IOrderStatus[] | IError>} Returns an object with the orders statuses.
|
|
191
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
192
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
193
|
+
*/
|
|
194
|
+
async getAllStatusesByStorageMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
195
|
+
const query = {
|
|
196
|
+
langCode,
|
|
197
|
+
offset,
|
|
198
|
+
limit,
|
|
199
|
+
};
|
|
200
|
+
const data = await this._fetchGet(`/marker/${marker}/order-statuses?` + this._queryParamsToString(query));
|
|
201
|
+
return this._normalizeData(data);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get all refund requests for an order.
|
|
205
|
+
* @handleName getRefunds
|
|
206
|
+
* @param {number} id - Order id. Example: 1.
|
|
207
|
+
* @returns {Promise<IRefundRequest[] | IError>} Returns array of refund requests.
|
|
208
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
209
|
+
*/
|
|
210
|
+
async getRefunds(id) {
|
|
211
|
+
const savedUrl = this._url;
|
|
212
|
+
this._url = this._ordersUrl;
|
|
213
|
+
const data = await this._fetchGet(`/${id}/refund`);
|
|
214
|
+
this._url = savedUrl;
|
|
215
|
+
return this._normalizeData(data);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Create a refund request for an order.
|
|
219
|
+
* @handleName createRefundRequest
|
|
220
|
+
* @param {number} id - Order id. Example: 1.
|
|
221
|
+
* @param {ICreateRefundRequest} body - Refund request body.
|
|
222
|
+
* @returns {Promise<IOrdersEntity | IError>} Returns order entity.
|
|
223
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
224
|
+
*/
|
|
225
|
+
async createRefundRequest(id, body) {
|
|
226
|
+
const savedUrl = this._url;
|
|
227
|
+
this._url = this._ordersUrl;
|
|
228
|
+
const data = await this._fetchPost(`/${id}/refund`, body);
|
|
229
|
+
this._url = savedUrl;
|
|
230
|
+
return this._normalizeData(data);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Cancel a refund request for an order.
|
|
234
|
+
* @handleName cancelRefundRequest
|
|
235
|
+
* @param {number} id - Order id. Example: 1.
|
|
236
|
+
* @returns {Promise<IOrdersEntity | IError>} Returns order entity.
|
|
237
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
238
|
+
*/
|
|
239
|
+
async cancelRefundRequest(id) {
|
|
240
|
+
const savedUrl = this._url;
|
|
241
|
+
this._url = this._ordersUrl;
|
|
242
|
+
const data = await this._fetchDelete(`/${id}/refund`);
|
|
243
|
+
this._url = savedUrl;
|
|
244
|
+
return this._normalizeData(data);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
exports.default = OrdersApi;
|