-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf7e60b
commit 76683b6
Showing
47 changed files
with
1,919 additions
and
2,084 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Layers | ||
|
||
#### Each layer should extends the previous one in the next order: | ||
|
||
1. Host layer | ||
2. Profile layer | ||
3. Listener layer | ||
4. Sender layer | ||
5. Retriever layer | ||
6. Group layer | ||
7. Controls layer | ||
8. Business layer (Optional) | ||
|
||
**Controls layer** should be enough |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Page } from 'puppeteer'; | ||
import { ControlsLayer } from './controls.layer'; | ||
|
||
declare module WAPI { | ||
const getBusinessProfilesProducts: (to: string) => any; | ||
const sendImageWithProduct: ( | ||
base64: string, | ||
to: string, | ||
caption: string, | ||
bizNumber: string, | ||
productId: string | ||
) => any; | ||
} | ||
|
||
export class BusinessLayer extends ControlsLayer { | ||
constructor(page: Page) { | ||
super(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 } | ||
); | ||
} | ||
} |
Oops, something went wrong.