forked from orkestral/venom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
business.layer.ts
44 lines (41 loc) · 1.2 KB
/
business.layer.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
import { Browser, Page } from 'puppeteer';
import { ControlsLayer } from './controls.layer';
export class BusinessLayer extends ControlsLayer {
constructor(public page: Page, public browser: Browser) {
super(browser, page);
}
/**
* Querys product catalog
* @param id Buisness profile id ('[email protected]')
*/
public async getBusinessProfilesProducts(id: string) {
return this.page.evaluate(
({ id }) => {
WAPI.getBusinessProfilesProducts(id);
},
{ id }
);
}
/**
* Sends product with product image to given chat id
* @param to Chat id
* @param base64 Base64 image data
* @param caption Message body
* @param businessId Business id number that owns the product ('[email protected]')
* @param productId Product id, see method getBusinessProfilesProducts for more info
*/
public async sendImageWithProduct(
to: string,
base64: string,
caption: string,
businessId: string,
productId: string
) {
return this.page.evaluate(
({ to, base64, businessId, caption, productId }) => {
WAPI.sendImageWithProduct(base64, to, caption, businessId, productId);
},
{ to, base64, businessId, caption, productId }
);
}
}