-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
473 lines (427 loc) · 18.1 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
import { TCommission, TCommissionQueries } from './types/commissions';
import {
TInsights,
TOfferInsightQueryParams,
TPerformanceIndicator,
TPerformanceIndicatorQueryParams,
TSalesForecast,
TSalesForecastQueryParams,
TSearchTerm,
TSearchTermsQueryParams,
} from './types/insights';
import { TGetInventoryQueryParams, TInventory } from './types/inventory';
import { TGetInvoicesQueryParams } from './types/invoices';
import {
TCreateOfferResult,
TExportOffer,
TOffer,
TOfferData,
TOfferPrices,
TOfferStocks,
TUpdateOfferData,
} from './types/offers';
import { IBolOrderData, IQueryParams } from './types/orders';
import { IBolShipmentDetails } from './types/shipment';
import { TCurrentRetailerShortResponse, TRetailerResponse } from './types/retailer';
export default class Bol {
constructor(APIKEY: string, SECRET: string, bol_token?: string, expires_in?: number);
bolHeader(tries?: number): Promise<{ [key: string]: string }>;
bolAccess(tries?: number): Promise<void>;
//////////////////////////////////////////////////
// --- Commissions --- //
//////////////////////////////////////////////////
/**
* Get all commissions and reductions by EAN per single EAN
* @description Commissions can be filtered by condition, which defaults to NEW. We will calculate the commission amount from the EAN and price
* @param {string} ean - product EAN
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const commissions = await bol.commissionList('0000007740404');
*/
commission(ean: string, tries?: number): Promise<TCommission>;
/**
* Get all commissions and reductions by EAN in bulk
* @description Gets all commissions and possible reductions by EAN, price, and optionally condition.
* @param {Object} commissionQueries - Array of objects
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const commissionQueries = [
{
"ean": "0000007740404",
"condition": "NEW",
"unitPrice": 59
}
]
* const commissions = await bol.commissionList(commissionQueries);
*/
commissionList(commissionQueries: TCommissionQueries, tries?: number): Promise<TCommission[]>;
//////////////////////////////////////////////////
// --- Insights --- //
//////////////////////////////////////////////////
/**
* Get offer insights
* @description Get the product visits and the buy box percentage for an offer during a given period.
* @param {Object} queryParams - The query parameters.
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const insight = await bol.offerInsights({
* offerId: '1234567',
* period: 'lastWeek',
* numberOfPeriods: 1,
* name : 'BUY_BOX_PERCENTAGE'
* });
*/
offerInsights(queryParams: TOfferInsightQueryParams, tries?: number): Promise<TInsights>;
/**
* Get performance indicators
* @description Gets the measurements for your performance indicators per week.
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const insight = await bol.offerInsight({
* name: 'REVIEWS',
* year: 2020,
* week: 1
* });
*/
performanceIndicators(
queryParams: TPerformanceIndicatorQueryParams,
tries?: number
): Promise<TPerformanceIndicator[]>;
/**
* Get performance indicators
* @description Gets the measurements for your performance indicators per week.
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const insight = await bol.offerInsight({
* offerId: '123456',
* weeksAhead: 1,
* });
*/
salesForecast(queryParams: TSalesForecastQueryParams, tries?: number): Promise<TSalesForecast>;
/**
* Get search terms
* @description Retrieves the search volume for a specified search term and period.
* The search volume allows you to see what bol.com customers are searching for.
* Based on the search volume per search term you can optimize your product content,
* or spot opportunities to extend your assortment, or analyzing trends for inventory management.
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const insight = await bol.offerInsight({
* searchTerm: 'Iphone',
* period: 'DAY',
* numberOfPeriods: 12,
* relatedSearchTerms: true,
* });
*/
searchTerms(queryParams: TSearchTermsQueryParams, tries?: number): Promise<TSearchTerm>;
//////////////////////////////////////////////////
// --- Inventory --- //
//////////////////////////////////////////////////
/**
* Get search terms
* @description The inventory endpoint is a specific LVB/FBB endpoint.
* It provides a paginated list containing your fulfilment by bol.com inventory.
* This endpoint does not provide information about your own stock.
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const insight = await bol.getInventory();
*/
getLVBInventory(queryParams: TGetInventoryQueryParams, tries?: number): Promise<TInventory[]>;
//////////////////////////////////////////////////
// --- Invoices --- //
//////////////////////////////////////////////////
/**
* Get all invoices
* @description Gets a list of invoices, by default from the past 4 weeks.
* The optional period-start-date and period-end-date-date parameters can be
* used together to retrieve invoices from a specific date range in the past,
* the period can be no longer than 31 days. Invoices and their specifications
* can be downloaded separately in different media formats with the
* ‘GET an invoice by id’ and the ‘GET an invoice specification by id’ calls.
* The available media types differ per invoice and are listed per invoice
* within the response. Note: the media types listed in the response must be
* given in our standard API format.
* @param {Object} [queryParams] - The query parameters
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const invoices = await bol.getInvoices({
* periodStartDate: '2020-01-01',
* periodEndDate: '2020-01-31',
* });
*/
getInvoices(queryParams: TGetInvoicesQueryParams, tries?: number): Promise<string>;
/**
* Get an invoice by invoice id
* @description Gets an invoice by invoice id.
* The available media types differ per invoice and are listed within the response from the
* ‘GET all invoices’ call. Note: the media types listed in the response must
* be given in our standard API format.
* @param {string} [invoiceId] - The ID of the invoice
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const invoice = await bol.getInvoiceById('123456');
*/
getInvoiceById(invoiceId: string, tries?: number): Promise<string>;
/**
* Get an invoice specification by invoice id
* @description Gets an invoice specification for an invoice
* with a paginated list of its transactions. The available
* media types differ per invoice specification and are
* listed within the response from the ‘GET all invoices’ call.
* Note, the media types listed in the response must be given in our standard API format.
* @param {string} [invoiceId] - The ID of the invoice
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const invoiceSpecificatoin = await bol.getInvoiceSpecificationById('123456');
*/
getInvoiceSpecificationById(invoiceId: string, tries?: number): Promise<string>;
//////////////////////////////////////////////////
// --- Offers --- //
//////////////////////////////////////////////////
/**
*Create a new offer
* @description Creates a new offer, and adds it to the catalog. After creation,
* status information can be retrieved to review if the offer is valid and published to the shop.
* @param {TBolOffer} [offer] - The ID of the invoice
* @param {number} [tries=3] - The number of attempts to fetch the commissions.
* @returns {Promise<Object>} - A promise that resolves with the commission list.
* @example
* const insight = await bol.createNewOffer();
*/
createOffer(offerData: TOfferData, tries?: number): Promise<TCreateOfferResult>;
/**
* Export offers from the Bol platform.
* @param {number} [tries=3] - The number of attempts to export the offers.
* @returns {Promise<Array<Object>>} - A promise that resolves with an array of exported offers.
*/
exportOffers(tries?: number): Promise<TExportOffer[]>; // #REPLACE
/**
* Retrieve an unpublished offer report by report id
* @description Retrieve an unpublished offer report containing all unpublished offers and reasons.
* @param {string} [reportId] - Unique identifier for unpublished offer report.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.createNewOffer();
*/
retrieveOfferReportById(reportId: string, tries?: number): Promise<string>;
/**
* Retrieve an unpublished offer report by report id
* @description Retrieve an unpublished offer report containing all unpublished offers and reasons.
* @param {string} [reportId] - Unique identifier for unpublished offer report.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.createNewOffer();
*/
exportStatus(url: string, tries?: number): Promise<string>;
/**
* Retrieve an unpublished offer report by report id
* @description Retrieve an unpublished offer report containing all unpublished offers and reasons.
* @param {string} [reportId] - Unique identifier for unpublished offer report.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.createNewOffer();
*/
retrieveUnpublishedOfferReportById(reportId: string, tries?: number): Promise<string>;
/**
* Retrieve an offer by its offer id
* @description Retrieve an offer by using the offer id provided to you when creating or listing your offers.
* @param {string} [offerId] - Unique identifier for offer.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.createNewOffer();
*/
retrieveOfferByOfferId(offerId: string, tries?: number): Promise<TOffer>;
/**
* Update an offer
* @description Update an offer by using the offer id provided to you when creating or listing your offers.
* @param {string} [offerId] - Unique identifier for offer.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.createNewOffer();
*/
updateOffer(offerId: string, offerData: TUpdateOfferData, tries?: number): Promise<TCreateOfferResult>;
/**
* Delete offer by id
* @description Delete an offer by id.
* @param {string} [offerId] - Unique identifier for offer.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.createNewOffer();
*/
deleteOffer(offerId: string, tries?: number): Promise<void>;
/**
* Update price(s) for offer by id
* @description Update price(s) for offer by id.
* @param {string} [offerId] - Unique identifier for offer.
* @param {number} [offerPrice] - The new price of the offer.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.createNewOffer();
*/
updateOfferPrice(offerId: string, offerPrice: TOfferPrices, tries?: number): Promise<void>;
/**
* Update stock for offer by id
* @description Update stock for offer by id.
* @param {string} [offerId] - Unique identifier for offer.
* @param {number} [offerStock] - The new stock of the offer.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.createNewOffer();
*/
updateOfferStock(offerId: string, offerStock: TOfferStocks, tries?: number): Promise<void>;
//////////////////////////////////////////////////
// --- orders --- //
//////////////////////////////////////////////////
orders(queryParams?: IQueryParams, tries?: number): Promise<IBolOrderData[]>;
getOrderByOrderId(orderId: string, tries?: number): Promise<any>;
//////////////////////////////////////////////////
// --- content --- //
//////////////////////////////////////////////////
/**
* Get catalog product details by EAN
* @description Gets the details of a catalog product by means of its EAN.
* @param {string} [ean] - The EAN number associated with this product.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const content = await bol.getCatalogProductDetailsByEAN('0000007740404');
*/
getCatalogProductDetailsByEAN(ean: string, tries?: number): Promise<void>;
//////////////////////////////////////////////////
// --- product --- //
//////////////////////////////////////////////////
/**
* Get product content
* @description Gets the content of a product by EAN.
* @param {string} [ean] - The EAN number associated with this product.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const content = await bol.getProductContent('0000007740404');
*/
getProductList(getProductListProps: getProductListProps, tries?: number): Promise<any[]>;
/**
* Get product ids by EAN
* @description Get the bol.com specific product identifier and the related EANs.
* @param {string} [ean] - The EAN number associated with this product.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.getProductIdsByEan();
*/
getProductIdsByEan(ean: string, tries?: number): Promise<string[]>;
/**
* Get product assets
* @description Gets the list of asset available for the product by EAN.
* @param {string} [ean] - The EAN number associated with this product.
* @param {number} [tries=3] - The number of attempts
* @returns {Promise<Object>}
* @example
* const insight = await bol.getProductAssets();
*/
getProductAssets(ean: string, tries?: number): Promise<string[]>;
//////////////////////////////////////////////////
// --- shipments --- //
//////////////////////////////////////////////////
getShipmentList(page?: number, fulfilmentMethod?: string, orderId?: string, tries?: number): Promise<any[]>;
getAShipmentByShipmentId(shipmentId: string, tries?: number): Promise<IBolShipmentDetails>;
//////////////////////////////////////////////////
// --- retailer --- //
//////////////////////////////////////////////////
getRetailer(retailerID: string, tries?: number): Promise<TRetailerResponse>;
getCurrentRetailer(short?: boolean, tries?: number): Promise<TRetailerResponse | TCurrentRetailerShortResponse>;
}
// Other
type TCountry = {
countryCode: string;
value: number;
};
type getProductListProps = {
countryCode?: string;
searchTerm?: string;
categoryId?: string;
filterRanges?: unknown[];
filterValues?: unknown[];
sort?: string;
page?: number;
};
// orders
export type TShipmentDetails = {
salutation: string;
firstName: string;
surname: string;
streetName: string;
houseNumber: string;
zipCode: string;
city: string;
countryCode: string;
email: string;
company: string;
language: string;
};
export type TBillingDetails = {
salutation: string;
firstName: string;
surname: string;
streetName: string;
houseNumber: string;
zipCode: string;
city: string;
countryCode: string;
email: string;
orderReference: string;
};
export type TOrderDataFulfilment = {
method: string;
distributionParty: string;
latestDeliveryDate: string;
expiryDate: string;
timeFrameType: string;
};
export type TOrderDataOffer = {
offerId: string;
reference: string;
};
export type TOrderDataProduct = {
ean: string;
title: string;
};
export type TOrderItems = {
orderItemId: string;
cancellationRequest: boolean;
fulfilment: TOrderDataFulfilment;
offer: TOrderDataOffer;
product: TOrderDataProduct;
quantity: number;
quantityShipped: number;
quantityCancelled: number;
unitPrice: number;
commission: number;
latestChangedDateTime: string;
};
export type TBolOrderData = {
orderId: string;
pickupPoint: boolean;
orderPlacedDateTime: string;
shipmentDetails: TShipmentDetails;
billingDetails: TBillingDetails;
orderItems: TOrderItems[];
};