Skip to content

Commit

Permalink
halted progress on v9 because of the release of v10
Browse files Browse the repository at this point in the history
  • Loading branch information
oga-sven committed Oct 5, 2023
1 parent deea03d commit bea77ef
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export default class Bol {

createOffer(offerData: TOfferData, tries?: number): Promise<void>;

offerList(tries?: number): Promise<TOffer[]>;

getOffer(order_id: string, tries?: number): Promise<TOffer>;

pause(offer_id: string, hold: boolean, method: string, tries?: number): Promise<void>;
Expand All @@ -18,11 +20,11 @@ export default class Bol {
export(tries?: number): Promise<TExportOffer[]>; // #REPLACE

orders(page: number, status: 'OPEN' | 'SHIPPED' | 'ALL', tries?: number): Promise<any[]>; // #REPLACE
orderById(orderId:string, tries?: number): Promise<any[]>; // #REPLACE

orderById(orderId: string, tries?: number): Promise<any[]>; // #REPLACE

shipments(page: number, fulfilmentMethod: 'FBR' | 'FBB', tries?: number): Promise<any[]>; // #REPLACE

shipmentById(shipmentId: string, tries?: number): Promise<any[]>; // #REPLACE

detail(order_id: string, tries?: number): Promise<any>; // #REPLACE
Expand Down
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ class Bol {

// Offers

/**
* Retrieve a list of offers from the Bol platform.
* @param {number} [tries=3] - The number of attempts to pause the offer.
* @returns {Promise<Object>} - A promise that resolves with the offer list.
* @example
* const offers = await bol.offerList();
* console.log(offers);
*/
async offerList(tries = 3) {
return new Promise(async (resolve, reject) => {
console.log({ ...(await this.bolHeader(2)), 'Accept-Language': 'nl' });
try {
let resp = await fetch('https://api.bol.com/retailer/products/list', {
method: 'GET',
headers: { ...(await this.bolHeader(2)), 'Accept-Language': 'nl' },
});
resp = await resp.json();
return resolve(resp);
} catch (e) {
tries--;
if (tries <= 0) return reject(e);
return setTimeout(() => resolve(this.offerList(tries)), 2000);
}
});
}

/**
* Retrieve a single offer from the Bol platform.
* @param {string} offer_id - The ID of the offer.
Expand Down

0 comments on commit bea77ef

Please sign in to comment.