rerobe-js-orm 4.7.2 → 4.7.3

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.
@@ -1,6 +1,7 @@
1
1
  import Utilities from '../../helpers/Utilities';
2
2
  export default class OrderFromTraderaEmail {
3
3
  utilities: Utilities;
4
+ getObjectNumbers(emailHtml: any): string[];
4
5
  createOrderFromLineItems(emailHtml: any, providedLineItems?: ReRobeOrderLineItem[]): ReRobeOrderObj;
5
6
  private normalizeEmailHtml;
6
7
  private getMatch;
@@ -7,6 +7,19 @@ class OrderFromTraderaEmail {
7
7
  constructor() {
8
8
  this.utilities = new Utilities_1.default();
9
9
  }
10
+ // Extracts all Tradera listing ids ("Object No") from the email HTML
11
+ getObjectNumbers(emailHtml) {
12
+ const html = typeof emailHtml === 'string' ? emailHtml : String((emailHtml === null || emailHtml === void 0 ? void 0 : emailHtml.html) || emailHtml || '');
13
+ const normalized = this.normalizeEmailHtml(html);
14
+ const results = [];
15
+ const regex = /Object\s+No\s+(\d+)/gi;
16
+ for (const m of normalized.matchAll(regex)) {
17
+ const id = (m && m[1]) || '';
18
+ if (id && !results.includes(id))
19
+ results.push(id);
20
+ }
21
+ return results;
22
+ }
10
23
  // Builds an order from raw email HTML and provided ReRobe line items (does not derive line items from email)
11
24
  // Uses fixed shopper identity (email + customerName) for Tradera orders created via this method
12
25
  createOrderFromLineItems(emailHtml, providedLineItems = []) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.7.2",
3
+ "version": "4.7.3",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",